From 14b9e9f3473bfe23d60c2351701262ba41397d0c Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 10 May 2005 15:04:06 +0000 Subject: [PATCH] remove default plugin versions from super POM, rely on discovery of releases. Write out the current version during bootstrap to force its usage (unfortunately enforcing it on other installs, however...) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@169484 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractVersionTransformation.java | 6 +- .../ReleaseArtifactTransformation.java | 9 ++- .../transform/SnapshotTransformation.java | 8 +-- .../lifecycle/DefaultLifecycleExecutor.java | 11 +++- maven-mboot2/src/main/java/MBoot.java | 7 +-- .../src/main/java/model/Repository.java | 6 +- .../org/apache/maven/test/SurefirePlugin.java | 11 ++-- .../org/apache/maven/project/pom-4.0.0.xml | 58 ------------------- 8 files changed, 37 insertions(+), 79 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java index b41daf2386..333f69476c 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java @@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.VersionArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException; +import org.apache.maven.wagon.ResourceDoesNotExistException; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.File; @@ -107,7 +108,7 @@ public abstract class AbstractVersionTransformation getLogger().info( artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() ); - VersionArtifactMetadata remoteMetadata = retrieveFromRemoteRepository( artifact, remoteRepository ); + VersionArtifactMetadata remoteMetadata = retrieveFromRemoteRepository( artifact, remoteRepository, localMetadata ); int difference = remoteMetadata.compareTo( localMetadata ); if ( difference > 0 ) @@ -171,7 +172,8 @@ public abstract class AbstractVersionTransformation } protected abstract VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, - ArtifactRepository remoteRepository ) + ArtifactRepository remoteRepository, + VersionArtifactMetadata localMetadata ) throws ArtifactMetadataRetrievalException; protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact, diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java index 51123bc17f..4074859a63 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java @@ -81,7 +81,8 @@ public class ReleaseArtifactTransformation } protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, - ArtifactRepository remoteRepository ) + ArtifactRepository remoteRepository, + VersionArtifactMetadata localMetadata ) throws ArtifactMetadataRetrievalException { AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact ); @@ -91,7 +92,11 @@ public class ReleaseArtifactTransformation } catch ( ResourceDoesNotExistException e ) { - throw new ArtifactMetadataRetrievalException( "No releases could be detected for the artifact", e ); + if ( localMetadata.constructVersion() == null ) + { + throw new ArtifactMetadataRetrievalException( "Unable to find release for artifact " + artifact, e ); + } + // otherwise, ignore - use the local one } return metadata; } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java index 83727b4879..4b911bad24 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java @@ -25,7 +25,6 @@ import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException; import org.apache.maven.wagon.ResourceDoesNotExistException; import java.io.IOException; -import java.io.File; import java.util.List; import java.util.regex.Matcher; @@ -94,8 +93,8 @@ public class SnapshotTransformation } else if ( isSnapshot( artifact ) ) { - SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, - remoteRepository ); + SnapshotArtifactMetadata metadata = null; + metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null ); metadata.update(); artifact.setVersion( metadata.constructVersion() ); @@ -110,7 +109,8 @@ public class SnapshotTransformation } protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, - ArtifactRepository remoteRepository ) + ArtifactRepository remoteRepository, + VersionArtifactMetadata localMetadata ) throws ArtifactMetadataRetrievalException { SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 6ce92b838a..f095cae518 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -23,6 +23,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.PluginManagerException; @@ -188,10 +189,14 @@ public class DefaultLifecycleExecutor plugin.setArtifactId( artifactId ); plugin.setVersion( version ); - Plugin def = (Plugin) project.getPluginManagement().getPluginsAsMap().get( key ); - if ( def != null ) + PluginManagement pluginManagement = project.getPluginManagement(); + if ( pluginManagement != null ) { - modelDefaultsInjector.mergePluginWithDefaults( plugin, def ); + Plugin def = (Plugin) pluginManagement.getPluginsAsMap().get( key ); + if ( def != null ) + { + modelDefaultsInjector.mergePluginWithDefaults( plugin, def ); + } } project.addPlugin( plugin ); diff --git a/maven-mboot2/src/main/java/MBoot.java b/maven-mboot2/src/main/java/MBoot.java index 46e39e5031..392c71835c 100644 --- a/maven-mboot2/src/main/java/MBoot.java +++ b/maven-mboot2/src/main/java/MBoot.java @@ -636,8 +636,6 @@ public class MBoot installPom( basedir, localRepository, reader ); - String artifactId = reader.getArtifactId(); - install( basedir, localRepository, reader, reader.getPackaging() ); return reader; @@ -742,7 +740,6 @@ public class MBoot throws Exception { installPomFile( reader, localRepository, new File( basedir, "pom.xml" ) ); - } private void installPomFile( ModelReader reader, Repository localRepository, File source ) @@ -789,6 +786,8 @@ public class MBoot FileUtils.copyFile( new File( basedir, BUILD_DIR + "/" + finalName + ".jar" ), file ); + file = localRepository.getMetadataFile( groupId, artifactId, null, type, artifactId + "-RELEASE.version.txt" ); + IOUtil.copy( new StringReader( version ), new FileWriter( file ) ); } private void runTests( String basedir, String classes, String testClasses, ModelReader reader, @@ -807,7 +806,7 @@ public class MBoot excludes = new ArrayList(); - excludes.add( "**/*Abstract*.java" ); + excludes.add( "**/Abstract*Test.java" ); String reportsDir = new File( basedir, "target/surefire-reports" ).getAbsolutePath(); diff --git a/maven-mboot2/src/main/java/model/Repository.java b/maven-mboot2/src/main/java/model/Repository.java index 8068ef9ed8..8959ea6846 100644 --- a/maven-mboot2/src/main/java/model/Repository.java +++ b/maven-mboot2/src/main/java/model/Repository.java @@ -107,7 +107,11 @@ public class Repository repositoryPath = dependency.getGroupId().replace( '.', '/' ); // if ( !dependency.getType().equals( "pom" ) ) // { - repositoryPath = repositoryPath + "/" + dependency.getArtifactId() + "/" + dependency.getVersion(); + repositoryPath = repositoryPath + "/" + dependency.getArtifactId(); + if ( version != null ) + { + repositoryPath = repositoryPath + "/" + dependency.getVersion(); + } // } repositoryPath = repositoryPath + "/" + filename; } diff --git a/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java b/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java index 1c80809155..905365a75a 100644 --- a/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java +++ b/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java @@ -25,6 +25,7 @@ import org.codehaus.surefire.SurefireBooter; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -40,7 +41,7 @@ import java.util.StringTokenizer; public class SurefirePlugin extends AbstractMojo { - + /** * @parameter expression="${basedir}" * @required @@ -68,14 +69,14 @@ public class SurefirePlugin /** * Base directory where all reports are written to. - * + * * @parameter expression="${project.build.directory}/surefire-reports" */ private String reportsDirectory; /** * Specify this parameter if you want to use the test regex notation to select tests to run. - * + * * @parameter */ private String test; @@ -83,12 +84,12 @@ public class SurefirePlugin /** * @parameter */ - private List includes; + private List includes = new ArrayList( Collections.singletonList( "**/*Test.java" ) ); /** * @parameter */ - private List excludes; + private List excludes = new ArrayList( Collections.singletonList( "**/Abstract*Test.java" ) ); /** * @parameter expression="${localRepository}" 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 22bd30f73c..0078cf6b43 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 @@ -38,64 +38,6 @@ src/test/resources - - - - - org.apache.maven.plugins - maven-compiler-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-resources-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-jar-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-surefire-plugin - 1.0-alpha-2-SNAPSHOT - - - **/*Test.java - - - **/Abstract*Test.java - - - - - org.apache.maven.plugins - maven-clean-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-deploy-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-install-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-pom-plugin - 1.0-alpha-2-SNAPSHOT - - - org.apache.maven.plugins - maven-plugin-plugin - 1.0-alpha-2-SNAPSHOT - - -