mirror of https://github.com/apache/maven.git
Fixing some things:
o Artifact attachment via MavenProjectHelper was using string literals of the variables I was trying to use to fill in type and classifier (dumb, I know!) o Source plugin didn't have an @phase for the JarSourceMojo...added, then added the goal configuration in the release profile in the super-pom o Removed the source plugin bindings for the lifecycle mappings in maven-core o Re-added [deprecated] method MavenProjectBuilder.build( File, ArtifactRepository, List )...you should use MavenProjectBuilder.build( File, ArtifactRepository, ProfileManager ) instead. o Added profile handling/injection for the super-pom in two places: in buildStandaloneSuperPom() and in private build(..). This enables injection of the release profile which is provided in the super-pom. o Added integration test to verify that using -DperformRelease=true results in the sources being attached...to override this behavior, another profile keyed on -DperformRelease could turn the 'attach' param for the source plugin off. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@233245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d1a98347dd
commit
659a1f4736
|
@ -36,7 +36,7 @@ public class DefaultArtifactFactory
|
|||
{
|
||||
return createArtifact( groupId, artifactId, version, scope, type, null, null );
|
||||
}
|
||||
|
||||
|
||||
public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope,
|
||||
String type, String classifier )
|
||||
{
|
||||
|
|
|
@ -139,6 +139,9 @@ it0048: Verify that default values for mojo parameters are working (indirectly,
|
|||
|
||||
it0049: Test parameter alias usage.
|
||||
|
||||
it0050: Test surefire inclusion/exclusions
|
||||
|
||||
it0051: Test source attachment when -DperformRelease=true is specified.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
it0051
|
||||
#it0050
|
||||
it0049
|
||||
it0048
|
||||
it0047
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
--check-plugin-latest --no-plugin-registry -DperformRelease=true
|
|
@ -0,0 +1,2 @@
|
|||
target/maven-core-it0051-1.0.jar
|
||||
target/maven-core-it0051-1.0-sources.jar
|
|
@ -0,0 +1 @@
|
|||
package
|
|
@ -0,0 +1,16 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-core-it0051</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
|
@ -0,0 +1,16 @@
|
|||
package org.apache.maven.it0001;
|
||||
|
||||
public class Person
|
||||
{
|
||||
private String name;
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
name = jason
|
|
@ -0,0 +1,16 @@
|
|||
package org.apache.maven.it0001;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class PersonTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testPerson()
|
||||
{
|
||||
Person person = new Person();
|
||||
|
||||
person.setName( "foo" );
|
||||
|
||||
assertEquals( "foo", person.getName() );
|
||||
}
|
||||
}
|
|
@ -208,8 +208,7 @@
|
|||
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||
<package>
|
||||
org.apache.maven.plugins:maven-jar-plugin:jar,
|
||||
org.apache.maven.plugins:maven-source-plugin:jar
|
||||
org.apache.maven.plugins:maven-jar-plugin:jar
|
||||
</package>
|
||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
||||
|
@ -261,8 +260,7 @@
|
|||
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||
<package>
|
||||
org.apache.maven.plugins:maven-ejb-plugin:ejb,
|
||||
org.apache.maven.plugins:maven-source-plugin:jar
|
||||
org.apache.maven.plugins:maven-ejb-plugin:ejb
|
||||
</package>
|
||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
||||
|
@ -321,7 +319,6 @@
|
|||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||
<package>
|
||||
org.apache.maven.plugins:maven-jar-plugin:jar,
|
||||
org.apache.maven.plugins:maven-source-plugin:jar,
|
||||
org.apache.maven.plugins:maven-rar-plugin:rar
|
||||
</package>
|
||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.maven.project.MavenProjectHelper;
|
|||
import org.codehaus.plexus.archiver.jar.JarArchiver;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,10 +33,26 @@ import java.util.List;
|
|||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
* @goal jar
|
||||
* @phase package
|
||||
*/
|
||||
public class JarSourceMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @deprecated ICK! This needs to be generalized OUTSIDE of this mojo!
|
||||
*/
|
||||
private static final List BANNED_PACKAGINGS;
|
||||
|
||||
static
|
||||
{
|
||||
List banned = new ArrayList();
|
||||
|
||||
banned.add( "pom" );
|
||||
|
||||
BANNED_PACKAGINGS = banned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @parameter expression="${project}"
|
||||
* @readonly
|
||||
|
@ -47,6 +64,13 @@ public class JarSourceMojo
|
|||
* @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}
|
||||
*/
|
||||
private MavenProjectHelper projectHelper;
|
||||
|
||||
/**
|
||||
* @parameter expression="${project.packaging}"
|
||||
* @readonly
|
||||
* @required
|
||||
*/
|
||||
private String packaging;
|
||||
|
||||
/**
|
||||
* @parameter expression="${project.build.finalName}"
|
||||
|
@ -80,6 +104,12 @@ public class JarSourceMojo
|
|||
|
||||
return;
|
||||
}
|
||||
else if ( BANNED_PACKAGINGS.contains( packaging ) )
|
||||
{
|
||||
getLog().info( "NOT adding java-sources to attached artifacts for packaging: \'" + packaging + "\'." );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: use a component lookup?
|
||||
JarArchiver archiver = new JarArchiver();
|
||||
|
|
|
@ -227,6 +227,30 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use build( File, ArtifactRepository, ProfileManager)
|
||||
*/
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, List activeExternalProfiles )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
ProfileManager profileManager = new DefaultProfileManager( container );
|
||||
|
||||
if ( activeExternalProfiles != null )
|
||||
{
|
||||
for ( Iterator it = activeExternalProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
// since it's already determined to be active, we'll explicitly set it as activated in the mgr.
|
||||
profileManager.explicitlyActivate( profile.getId() );
|
||||
|
||||
profileManager.addProfile( profile );
|
||||
}
|
||||
}
|
||||
|
||||
return buildFromSourceFile( projectDescriptor, localRepository, profileManager );
|
||||
}
|
||||
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
|
@ -393,7 +417,23 @@ public class DefaultMavenProjectBuilder
|
|||
throws ProjectBuildingException
|
||||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
||||
ProfileManager superProjectProfileManager = new DefaultProfileManager( container );
|
||||
|
||||
List activeProfiles;
|
||||
|
||||
Properties profileProperties = new Properties();
|
||||
|
||||
superProjectProfileManager.addProfiles( superModel.getProfiles() );
|
||||
|
||||
activeProfiles = injectActiveProfiles( superProjectProfileManager, superModel, profileProperties );
|
||||
|
||||
MavenProject superProject = new MavenProject( superModel );
|
||||
|
||||
superProject.addProfileProperties( profileProperties );
|
||||
|
||||
superProject.setActiveProfiles( activeProfiles );
|
||||
|
||||
//noinspection CollectionDeclaredAsConcreteClass
|
||||
LinkedList lineage = new LinkedList();
|
||||
|
||||
|
@ -444,7 +484,7 @@ public class DefaultMavenProjectBuilder
|
|||
project.setOriginalModel( originalModel );
|
||||
|
||||
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
||||
Model previous = superModel;
|
||||
Model previous = superProject.getModel();
|
||||
|
||||
for ( Iterator i = lineage.iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -1000,7 +1040,21 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
||||
|
||||
ProfileManager profileManager = new DefaultProfileManager( container );
|
||||
|
||||
List activeProfiles;
|
||||
|
||||
Properties profileProperties = new Properties();
|
||||
|
||||
profileManager.addProfiles( superModel.getProfiles() );
|
||||
|
||||
activeProfiles = injectActiveProfiles( profileManager, superModel, profileProperties );
|
||||
|
||||
MavenProject project = new MavenProject( superModel );
|
||||
|
||||
project.addProfileProperties( profileProperties );
|
||||
|
||||
project.setActiveProfiles( activeProfiles );
|
||||
|
||||
project.setOriginalModel( superModel );
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@ public class DefaultMavenProjectHelper
|
|||
Artifact artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
|
||||
project.getArtifactId(),
|
||||
project.getVersion(),
|
||||
null,
|
||||
"artifactType",
|
||||
"artifactClassifier" );
|
||||
artifactType,
|
||||
artifactClassifier );
|
||||
|
||||
artifact.setFile( artifactFile );
|
||||
artifact.setResolved( true );
|
||||
|
|
|
@ -34,6 +34,12 @@ public interface MavenProjectBuilder
|
|||
|
||||
String STANDALONE_SUPERPOM_VERSION = "2.0";
|
||||
|
||||
/**
|
||||
* @deprecated Use build( File, ArtifactRepository, ProfileManager)
|
||||
*/
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, List activeExternalProfiles )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
|
|
@ -63,6 +63,15 @@
|
|||
<inherited>true</inherited>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<inherited>true</inherited>
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.project;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -108,7 +109,7 @@ public abstract class MavenProjectTestCase
|
|||
protected MavenProject getProject( File pom )
|
||||
throws Exception
|
||||
{
|
||||
return projectBuilder.build( pom, getLocalRepository(), null );
|
||||
return projectBuilder.build( pom, getLocalRepository(), new DefaultProfileManager( getContainer() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue