diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java index 7c7b4e6db2..4e0e6c4624 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java @@ -36,7 +36,7 @@ public Artifact createArtifact( String groupId, String artifactId, String versio { return createArtifact( groupId, artifactId, version, scope, type, null, null ); } - + public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope, String type, String classifier ) { diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index af9e2cd349..a501a79e34 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -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 diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 17248120fb..07c08c9da8 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,3 +1,5 @@ +it0051 +#it0050 it0049 it0048 it0047 diff --git a/maven-core-it/it0051/cli-options.txt b/maven-core-it/it0051/cli-options.txt new file mode 100644 index 0000000000..22bb982654 --- /dev/null +++ b/maven-core-it/it0051/cli-options.txt @@ -0,0 +1 @@ +--check-plugin-latest --no-plugin-registry -DperformRelease=true diff --git a/maven-core-it/it0051/expected-results.txt b/maven-core-it/it0051/expected-results.txt new file mode 100644 index 0000000000..63b95b06b9 --- /dev/null +++ b/maven-core-it/it0051/expected-results.txt @@ -0,0 +1,2 @@ +target/maven-core-it0051-1.0.jar +target/maven-core-it0051-1.0-sources.jar diff --git a/maven-core-it/it0051/goals.txt b/maven-core-it/it0051/goals.txt new file mode 100644 index 0000000000..ba3bd78738 --- /dev/null +++ b/maven-core-it/it0051/goals.txt @@ -0,0 +1 @@ +package diff --git a/maven-core-it/it0051/pom.xml b/maven-core-it/it0051/pom.xml new file mode 100644 index 0000000000..aca8eef7cd --- /dev/null +++ b/maven-core-it/it0051/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + org.apache.maven.it + maven-core-it0051 + jar + 1.0 + + + junit + junit + 3.8.1 + jar + test + + + diff --git a/maven-core-it/it0051/src/main/java/org/apache/maven/it0001/Person.java b/maven-core-it/it0051/src/main/java/org/apache/maven/it0001/Person.java new file mode 100644 index 0000000000..613e499ae0 --- /dev/null +++ b/maven-core-it/it0051/src/main/java/org/apache/maven/it0001/Person.java @@ -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; + } +} diff --git a/maven-core-it/it0051/src/main/resources/it0001.properties b/maven-core-it/it0051/src/main/resources/it0001.properties new file mode 100644 index 0000000000..f54f8ab106 --- /dev/null +++ b/maven-core-it/it0051/src/main/resources/it0001.properties @@ -0,0 +1 @@ +name = jason diff --git a/maven-core-it/it0051/src/test/java/org/apache/maven/it0001/PersonTest.java b/maven-core-it/it0051/src/test/java/org/apache/maven/it0001/PersonTest.java new file mode 100644 index 0000000000..80014fa03b --- /dev/null +++ b/maven-core-it/it0051/src/test/java/org/apache/maven/it0001/PersonTest.java @@ -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() ); + } +} diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml index b8d62111f1..26696460fd 100644 --- a/maven-core/src/main/resources/META-INF/plexus/components.xml +++ b/maven-core/src/main/resources/META-INF/plexus/components.xml @@ -208,8 +208,7 @@ org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test - org.apache.maven.plugins:maven-jar-plugin:jar, - org.apache.maven.plugins:maven-source-plugin:jar + org.apache.maven.plugins:maven-jar-plugin:jar org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy @@ -261,8 +260,7 @@ org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test - org.apache.maven.plugins:maven-ejb-plugin:ejb, - org.apache.maven.plugins:maven-source-plugin:jar + org.apache.maven.plugins:maven-ejb-plugin:ejb org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy @@ -321,7 +319,6 @@ org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-jar-plugin:jar, - org.apache.maven.plugins:maven-source-plugin:jar, org.apache.maven.plugins:maven-rar-plugin:rar org.apache.maven.plugins:maven-install-plugin:install diff --git a/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java b/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java index e610b63bd4..d59b269b1d 100644 --- a/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java +++ b/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java @@ -23,6 +23,7 @@ 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 @@ * @author Trygve Laugstøl * @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 void execute() 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(); diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 46c2623d38..1e7107b4c4 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -227,6 +227,30 @@ private Map createManagedVersionMap( DependencyManagement dependencyManagement ) } 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 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository 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 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository 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 MavenProject buildStandaloneSuperProject( ArtifactRepository localReposit 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 ); diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java index 599d899529..30218198b7 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java @@ -19,9 +19,8 @@ public void attachArtifact( MavenProject project, String artifactType, String ar Artifact artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(), project.getArtifactId(), project.getVersion(), - null, - "artifactType", - "artifactClassifier" ); + artifactType, + artifactClassifier ); artifact.setFile( artifactFile ); artifact.setResolved( true ); diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java index f6f43374c4..3623c8f30d 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java @@ -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; diff --git a/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml b/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml index 7c413c2b14..59137c6e94 100644 --- a/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml +++ b/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml @@ -63,6 +63,15 @@ true org.apache.maven.plugins maven-source-plugin + + + + attach-sources + + jar + + + true diff --git a/maven-project/src/test/java/org/apache/maven/project/MavenProjectTestCase.java b/maven-project/src/test/java/org/apache/maven/project/MavenProjectTestCase.java index 566c559cd4..2bd900cbc0 100644 --- a/maven-project/src/test/java/org/apache/maven/project/MavenProjectTestCase.java +++ b/maven-project/src/test/java/org/apache/maven/project/MavenProjectTestCase.java @@ -19,6 +19,7 @@ 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 @@ protected MavenProject getProjectWithDependencies( File pom ) protected MavenProject getProject( File pom ) throws Exception { - return projectBuilder.build( pom, getLocalRepository(), null ); + return projectBuilder.build( pom, getLocalRepository(), new DefaultProfileManager( getContainer() ) ); } }