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
|
@ -139,6 +139,9 @@ it0048: Verify that default values for mojo parameters are working (indirectly,
|
||||||
|
|
||||||
it0049: Test parameter alias usage.
|
it0049: Test parameter alias usage.
|
||||||
|
|
||||||
|
it0050: Test surefire inclusion/exclusions
|
||||||
|
|
||||||
|
it0051: Test source attachment when -DperformRelease=true is specified.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
- generated sources
|
- generated sources
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
it0051
|
||||||
|
#it0050
|
||||||
it0049
|
it0049
|
||||||
it0048
|
it0048
|
||||||
it0047
|
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-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||||
<package>
|
<package>
|
||||||
org.apache.maven.plugins:maven-jar-plugin:jar,
|
org.apache.maven.plugins:maven-jar-plugin:jar
|
||||||
org.apache.maven.plugins:maven-source-plugin:jar
|
|
||||||
</package>
|
</package>
|
||||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
<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-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||||
<package>
|
<package>
|
||||||
org.apache.maven.plugins:maven-ejb-plugin:ejb,
|
org.apache.maven.plugins:maven-ejb-plugin:ejb
|
||||||
org.apache.maven.plugins:maven-source-plugin:jar
|
|
||||||
</package>
|
</package>
|
||||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
||||||
|
@ -321,7 +319,6 @@
|
||||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||||
<package>
|
<package>
|
||||||
org.apache.maven.plugins:maven-jar-plugin:jar,
|
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-rar-plugin:rar
|
||||||
</package>
|
</package>
|
||||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
import org.codehaus.plexus.archiver.jar.JarArchiver;
|
import org.codehaus.plexus.archiver.jar.JarArchiver;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -32,10 +33,26 @@
|
||||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @goal jar
|
* @goal jar
|
||||||
|
* @phase package
|
||||||
*/
|
*/
|
||||||
public class JarSourceMojo
|
public class JarSourceMojo
|
||||||
extends AbstractMojo
|
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}"
|
* @parameter expression="${project}"
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -48,6 +65,13 @@ public class JarSourceMojo
|
||||||
*/
|
*/
|
||||||
private MavenProjectHelper projectHelper;
|
private MavenProjectHelper projectHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter expression="${project.packaging}"
|
||||||
|
* @readonly
|
||||||
|
* @required
|
||||||
|
*/
|
||||||
|
private String packaging;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${project.build.finalName}"
|
* @parameter expression="${project.build.finalName}"
|
||||||
* @required
|
* @required
|
||||||
|
@ -80,6 +104,12 @@ public void execute()
|
||||||
|
|
||||||
return;
|
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?
|
// TODO: use a component lookup?
|
||||||
JarArchiver archiver = new JarArchiver();
|
JarArchiver archiver = new JarArchiver();
|
||||||
|
|
|
@ -228,6 +228,30 @@ private Map createManagedVersionMap( DependencyManagement dependencyManagement )
|
||||||
return map;
|
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 )
|
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
|
@ -394,6 +418,22 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
||||||
{
|
{
|
||||||
Model superModel = getSuperModel();
|
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
|
//noinspection CollectionDeclaredAsConcreteClass
|
||||||
LinkedList lineage = new LinkedList();
|
LinkedList lineage = new LinkedList();
|
||||||
|
|
||||||
|
@ -444,7 +484,7 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
||||||
project.setOriginalModel( originalModel );
|
project.setOriginalModel( originalModel );
|
||||||
|
|
||||||
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
// 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(); )
|
for ( Iterator i = lineage.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -1000,8 +1040,22 @@ public MavenProject buildStandaloneSuperProject( ArtifactRepository localReposit
|
||||||
|
|
||||||
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
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 );
|
MavenProject project = new MavenProject( superModel );
|
||||||
|
|
||||||
|
project.addProfileProperties( profileProperties );
|
||||||
|
|
||||||
|
project.setActiveProfiles( activeProfiles );
|
||||||
|
|
||||||
project.setOriginalModel( superModel );
|
project.setOriginalModel( superModel );
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -19,9 +19,8 @@ public void attachArtifact( MavenProject project, String artifactType, String ar
|
||||||
Artifact artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
|
Artifact artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
|
||||||
project.getArtifactId(),
|
project.getArtifactId(),
|
||||||
project.getVersion(),
|
project.getVersion(),
|
||||||
null,
|
artifactType,
|
||||||
"artifactType",
|
artifactClassifier );
|
||||||
"artifactClassifier" );
|
|
||||||
|
|
||||||
artifact.setFile( artifactFile );
|
artifact.setFile( artifactFile );
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
|
|
|
@ -34,6 +34,12 @@ public interface MavenProjectBuilder
|
||||||
|
|
||||||
String STANDALONE_SUPERPOM_VERSION = "2.0";
|
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 )
|
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
|
||||||
throws ProjectBuildingException;
|
throws ProjectBuildingException;
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,15 @@
|
||||||
<inherited>true</inherited>
|
<inherited>true</inherited>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<inherited>true</inherited>
|
<inherited>true</inherited>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
|
import org.apache.maven.profiles.DefaultProfileManager;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -108,7 +109,7 @@ protected MavenProject getProjectWithDependencies( File pom )
|
||||||
protected MavenProject getProject( File pom )
|
protected MavenProject getProject( File pom )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
return projectBuilder.build( pom, getLocalRepository(), null );
|
return projectBuilder.build( pom, getLocalRepository(), new DefaultProfileManager( getContainer() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue