You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by si...@apache.org on 2008/07/10 06:17:09 UTC
svn commit: r675436 - in /maven/sandbox/branches/SI_MAVEN_2_1:
maven-core/src/main/java/org/apache/maven/errors/
maven-core/src/main/java/org/apache/maven/lifecycle/
maven-embedder/src/test/java/org/apache/maven/error/
maven-project/src/main/java/org/a...
Author: sisbell
Date: Wed Jul 9 21:17:08 2008
New Revision: 675436
URL: http://svn.apache.org/viewvc?rev=675436&view=rev
Log:
Merged latest changes from trunk, which fixes IT 0118.
Modified:
maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/CoreErrorTips.java Wed Jul 9 21:17:08 2008
@@ -41,6 +41,7 @@
{
private static final List NO_GOALS_TIPS = Arrays.asList( new String[] {
+ "Introduction to the Build Lifecycle", "\t(http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)",
"Maven in 5 Minutes guide (http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)",
"Maven User's documentation (http://maven.apache.org/users/)",
"Maven Plugins page (http://maven.apache.org/plugins/)",
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/errors/DefaultCoreErrorReporter.java Wed Jul 9 21:17:08 2008
@@ -86,25 +86,39 @@
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
- writer.write( "You have not specified any goals or lifecycle phases for Maven to execute." );
writer.write( NEWLINE );
+ writer.write( "You must specify at least one goal or lifecycle phase to perform build steps." );
writer.write( NEWLINE );
- writer.write( "Either specify a goal or lifecycle phase on the command line" );
+ writer.write( "The following list illustrates some commonly used build commands:" );
writer.write( NEWLINE );
- writer.write( "(you may want to try \'package\' to get started), or configure the " );
writer.write( NEWLINE );
- writer.write( "<defaultGoal/> element in the build section of your project POM." );
+ writer.write( " mvn clean" );
writer.write( NEWLINE );
+ writer.write( " Deletes any build output (e.g. class files or JARs)." );
writer.write( NEWLINE );
+ writer.write( " mvn test" );
writer.write( NEWLINE );
- writer.write( "NOTE: You can also chain multiple goals/phases together, as in the following example:" );
+ writer.write( " Runs the unit tests for the project." );
writer.write( NEWLINE );
- writer.write( "mvn clean package" );
+ writer.write( " mvn install" );
writer.write( NEWLINE );
+ writer.write( " Copies the project artifacts into your local repository." );
+ writer.write( NEWLINE );
+ writer.write( " mvn deploy" );
+ writer.write( NEWLINE );
+ writer.write( " Copies the project artifacts into the remote repository." );
+ writer.write( NEWLINE );
+ writer.write( " mvn site" );
+ writer.write( NEWLINE );
+ writer.write( " Creates project documentation (e.g. reports or Javadoc)." );
writer.write( NEWLINE );
writer.write( NEWLINE );
-
addTips( CoreErrorTips.getNoGoalsTips(), writer );
+ writer.write( NEWLINE );
+ writer.write( NEWLINE );
+ writer.write( "Use \"mvn -?\" to show general usage information about Maven's command line." );
+ writer.write( NEWLINE );
+ writer.write( NEWLINE );
registerBuildError( error, writer.toString() );
}
@@ -116,7 +130,8 @@
{
writer.write( NEWLINE );
writer.write( NEWLINE );
- writer.write( "Some tips:" );
+ writer.write( "Please see:" );
+ writer.write( NEWLINE );
for ( Iterator it = tips.iterator(); it.hasNext(); )
{
String tip = (String) it.next();
@@ -125,6 +140,9 @@
writer.write( "\t- " );
writer.write( tip );
}
+ writer.write( NEWLINE );
+ writer.write( NEWLINE );
+ writer.write( "for more information." );
}
}
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed Jul 9 21:17:08 2008
@@ -125,7 +125,27 @@
if ( ( goals == null ) || goals.isEmpty() )
{
- throw new NoGoalsSpecifiedException( "\n\nYou must specify at least one goal. Try 'install' to build or mvn -? for other options.\n See http://maven.apache.org for more information.\n\n" );
+ StringBuffer buffer = new StringBuffer( 1024 );
+
+ buffer.append( "\n\n" );
+ buffer.append( "You must specify at least one goal or lifecycle phase to perform build steps.\n" );
+ buffer.append( "The following list illustrates some commonly used build commands:\n\n" );
+ buffer.append( " mvn clean\n" );
+ buffer.append( " Deletes any build output (e.g. class files or JARs).\n" );
+ buffer.append( " mvn test\n" );
+ buffer.append( " Runs the unit tests for the project.\n" );
+ buffer.append( " mvn install\n" );
+ buffer.append( " Copies the project artifacts into your local repository.\n" );
+ buffer.append( " mvn deploy\n" );
+ buffer.append( " Copies the project artifacts into the remote repository.\n" );
+ buffer.append( " mvn site\n" );
+ buffer.append( " Creates project documentation (e.g. reports or Javadoc).\n\n" );
+ buffer.append( "Please see\n" );
+ buffer.append( "http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html\n" );
+ buffer.append( "for a complete description of available lifecycle phases.\n\n" );
+ buffer.append( "Use \"mvn -?\" to show general usage information about Maven's command line.\n\n" );
+
+ throw new NoGoalsSpecifiedException( buffer.toString() );
}
List taskSegments = segmentTaskListByAggregationNeeds(
@@ -889,6 +909,7 @@
this.aggregate = aggregate;
}
+ @Override
public String toString()
{
StringBuffer message = new StringBuffer();
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java Wed Jul 9 21:17:08 2008
@@ -19,16 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.embedder.Configuration;
import org.apache.maven.embedder.DefaultConfiguration;
@@ -44,6 +34,16 @@
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.easymock.MockControl;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
public class ErrorReporterPointcutTest
extends TestCase
{
@@ -55,6 +55,7 @@
private String basedir;
+ @Override
public void setUp()
throws Exception
{
@@ -81,6 +82,7 @@
maven = new MavenEmbedder( configuration );
}
+ @Override
public void tearDown()
throws Exception
{
@@ -341,7 +343,7 @@
reporter.reportErrorInterpolatingModel( null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
- reporterCtl.setVoidCallable();
+ reporterCtl.setVoidCallable( MockControl.ONE_OR_MORE );
reporterCtl.replay();
@@ -1170,18 +1172,14 @@
buildTestAccessory( plugin );
- Settings settings = new Settings();
- settings.addPluginGroup( "org.apache.maven.errortest" );
-
reporter.reportInvalidPluginForDirectInvocation( null, null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
- MavenExecutionRequest request =
- createRequest( projectDir, reporter ).setSettings( settings ).setGoals(
- Arrays.asList( "missing-direct-invoke-mojo:test" ) );
+ MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "org.apache.maven.errortest:missing-direct-invoke-mojo-maven-plugin:1:test" ) )
+ .setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
MavenExecutionResult result = maven.execute( request );
@@ -1201,18 +1199,13 @@
buildTestAccessory( plugin );
- Settings settings = new Settings();
- settings.addPluginGroup( "org.apache.maven.errortest" );
-
reporter.reportDuplicateAttachmentException( null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
- MavenExecutionRequest request =
- createRequest( project, reporter ).setSettings( settings ).setGoals(
- Arrays.asList( "duplicated-attachments:test" ) );
+ MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "org.apache.maven.errortest:duplicated-attachments-maven-plugin:1:test" ) );
MavenExecutionResult result = maven.execute( request );
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Wed Jul 9 21:17:08 2008
@@ -587,7 +587,7 @@
Build clone = new Build();
- assembler.assembleBuildInheritance( clone, build );
+ assembler.assembleBuildInheritance( clone, build, false );
return clone;
}
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Wed Jul 9 21:17:08 2008
@@ -89,16 +89,59 @@
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = false;
/**
- * Retrieve the metadata for the project from the repository.
- * Uses the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
- * associated artifacts.
+ * Resolve all relocations in the POM for this artifact, and return the new artifact coordinate.
*/
- public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
+ public Artifact retrieveRelocatedArtifact( Artifact artifact,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ if ( artifact instanceof ActiveProjectArtifact )
+ {
+ return artifact;
+ }
+
+ ProjectRelocation res = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
+ MavenProject project = res.project;
+
+ if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) )
+ {
+ return artifact;
+ }
+
+ Artifact result = null;
+ if ( artifact.getClassifier() != null )
+ {
+ result = artifactFactory.createArtifactWithClassifier( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getType(), artifact.getClassifier() );
+ }
+ else
+ {
+ result = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getScope(), artifact.getType() );
+ }
+
+ result.setScope( artifact.getScope() );
+ result.setArtifactHandler( artifact.getArtifactHandler() );
+ result.setDependencyFilter( artifact.getDependencyFilter() );
+ result.setDependencyTrail( artifact.getDependencyTrail() );
+ result.setOptional( artifact.isOptional() );
+ result.setRelease( artifact.isRelease() );
+
+ return result;
+ }
+
+ private String getRelocationKey( Artifact artifact )
+ {
+ return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
+ }
+
+ private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
if ( remoteRepositories == null )
{
- remoteRepositories = Collections.EMPTY_LIST;
+ remoteRepositories = Collections.emptyList();
}
try
@@ -111,7 +154,6 @@
}
MavenProject project = null;
-
Artifact pomArtifact;
boolean done = false;
@@ -181,14 +223,17 @@
if ( relocation.getGroupId() != null )
{
artifact.setGroupId( relocation.getGroupId() );
+ project.setGroupId( relocation.getGroupId() );
}
if ( relocation.getArtifactId() != null )
{
artifact.setArtifactId( relocation.getArtifactId() );
+ project.setArtifactId( relocation.getArtifactId() );
}
if ( relocation.getVersion() != null )
{
artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) );
+ project.setVersion( relocation.getVersion() );
}
if ( ( artifact.getDependencyFilter() != null ) &&
@@ -239,6 +284,25 @@
}
while ( !done );
+ ProjectRelocation res = new ProjectRelocation();
+ res.project = project;
+ res.pomArtifact = pomArtifact;
+
+ return res;
+ }
+
+ /**
+ * Retrieve the metadata for the project from the repository.
+ * Uses the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
+ * associated artifacts.
+ */
+ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ ProjectRelocation res = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
+ MavenProject project = res.project;
+ Artifact pomArtifact = res.pomArtifact;
+
// last ditch effort to try to get this set...
if ( artifact.getDownloadUrl() == null )
{
@@ -511,4 +575,11 @@
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
+
+ private static final class ProjectRelocation
+ {
+ private MavenProject project;
+ private Artifact pomArtifact;
+ }
+
}
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java Wed Jul 9 21:17:08 2008
@@ -291,14 +291,15 @@
child.setBuild( childBuild );
}
- assembleBuildInheritance( childBuild, parentBuild );
+ assembleBuildInheritance( childBuild, parentBuild, true );
}
}
// TODO: Remove this!
@SuppressWarnings("unchecked")
public void assembleBuildInheritance( Build childBuild,
- Build parentBuild )
+ Build parentBuild,
+ boolean handleAsInheritance )
{
// The build has been set but we want to step in here and fill in
// values that have not been set by the child.
@@ -361,7 +362,7 @@
}
// Plugins are aggregated if Plugin.inherit != false
- ModelUtils.mergePluginLists( childBuild, parentBuild, true );
+ ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance );
// Plugin management :: aggregate
PluginManagement dominantPM = childBuild.getPluginManagement();
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java Wed Jul 9 21:17:08 2008
@@ -35,7 +35,8 @@
void assembleModelInheritance( Model child, Model parent );
void assembleBuildInheritance( Build childBuild,
- Build parentBuild );
+ Build parentBuild,
+ boolean handleAsInheriance );
void copyModel( Model dest, Model source );
}
Modified: maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java?rev=675436&r1=675435&r2=675436&view=diff
==============================================================================
--- maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java (original)
+++ maven/sandbox/branches/SI_MAVEN_2_1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java Wed Jul 9 21:17:08 2008
@@ -189,6 +189,14 @@
return projectArtifacts;
}
+
+ public Artifact retrieveRelocatedArtifact( Artifact artifact,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ return artifact;
+ }
}
public Source source()
@@ -199,12 +207,14 @@
/**
* @noinspection RefusedBequest
*/
+ @Override
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException
{
artifact.setFile( new File( "dummy" ) );
}
+ @Override
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter )
@@ -214,6 +224,7 @@
new Source( artifactFactory, repositoryFactory, container ), filter );
}
+ @Override
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
List remoteRepositories, ArtifactRepository localRepository,
ArtifactMetadataSource source )
@@ -226,7 +237,7 @@
public void contextualize( Context context )
throws ContextException
{
- this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}
\ No newline at end of file