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
This commit is contained in:
Brett Leslie Porter 2005-05-10 15:04:06 +00:00
parent 91b4c4e604
commit 14b9e9f347
8 changed files with 37 additions and 79 deletions

View File

@ -22,6 +22,7 @@
import org.apache.maven.artifact.metadata.VersionArtifactMetadata; import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException; import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File; import java.io.File;
@ -107,7 +108,7 @@ else if ( snapshotPolicy.startsWith( ArtifactRepository.SNAPSHOT_POLICY_INTERVAL
getLogger().info( getLogger().info(
artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() ); artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() );
VersionArtifactMetadata remoteMetadata = retrieveFromRemoteRepository( artifact, remoteRepository ); VersionArtifactMetadata remoteMetadata = retrieveFromRemoteRepository( artifact, remoteRepository, localMetadata );
int difference = remoteMetadata.compareTo( localMetadata ); int difference = remoteMetadata.compareTo( localMetadata );
if ( difference > 0 ) if ( difference > 0 )
@ -171,7 +172,8 @@ else if ( difference == 0 )
} }
protected abstract VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, protected abstract VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
ArtifactRepository remoteRepository ) ArtifactRepository remoteRepository,
VersionArtifactMetadata localMetadata )
throws ArtifactMetadataRetrievalException; throws ArtifactMetadataRetrievalException;
protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact, protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact,

View File

@ -81,7 +81,8 @@ public void transformForDeployment( Artifact artifact, ArtifactRepository remote
} }
protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
ArtifactRepository remoteRepository ) ArtifactRepository remoteRepository,
VersionArtifactMetadata localMetadata )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact ); AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact );
@ -91,7 +92,11 @@ protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifac
} }
catch ( ResourceDoesNotExistException e ) 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; return metadata;
} }

View File

@ -25,7 +25,6 @@
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import java.io.IOException; import java.io.IOException;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -94,8 +93,8 @@ public void transformForDeployment( Artifact artifact, ArtifactRepository remote
} }
else if ( isSnapshot( artifact ) ) else if ( isSnapshot( artifact ) )
{ {
SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, SnapshotArtifactMetadata metadata = null;
remoteRepository ); metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null );
metadata.update(); metadata.update();
artifact.setVersion( metadata.constructVersion() ); artifact.setVersion( metadata.constructVersion() );
@ -110,7 +109,8 @@ private static boolean isSnapshot( Artifact artifact )
} }
protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact, protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
ArtifactRepository remoteRepository ) ArtifactRepository remoteRepository,
VersionArtifactMetadata localMetadata )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact ); SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );

View File

@ -23,6 +23,7 @@
import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginManagerException;
@ -188,11 +189,15 @@ private void injectHandlerPluginConfiguration( MavenProject project, String grou
plugin.setArtifactId( artifactId ); plugin.setArtifactId( artifactId );
plugin.setVersion( version ); plugin.setVersion( version );
Plugin def = (Plugin) project.getPluginManagement().getPluginsAsMap().get( key ); PluginManagement pluginManagement = project.getPluginManagement();
if ( pluginManagement != null )
{
Plugin def = (Plugin) pluginManagement.getPluginsAsMap().get( key );
if ( def != null ) if ( def != null )
{ {
modelDefaultsInjector.mergePluginWithDefaults( plugin, def ); modelDefaultsInjector.mergePluginWithDefaults( plugin, def );
} }
}
project.addPlugin( plugin ); project.addPlugin( plugin );
} }

View File

@ -636,8 +636,6 @@ private ModelReader buildProject( String basedir, String projectId, ClassLoader
installPom( basedir, localRepository, reader ); installPom( basedir, localRepository, reader );
String artifactId = reader.getArtifactId();
install( basedir, localRepository, reader, reader.getPackaging() ); install( basedir, localRepository, reader, reader.getPackaging() );
return reader; return reader;
@ -742,7 +740,6 @@ private void installPom( String basedir, Repository localRepository, ModelReader
throws Exception throws Exception
{ {
installPomFile( reader, localRepository, new File( basedir, "pom.xml" ) ); installPomFile( reader, localRepository, new File( basedir, "pom.xml" ) );
} }
private void installPomFile( ModelReader reader, Repository localRepository, File source ) private void installPomFile( ModelReader reader, Repository localRepository, File source )
@ -789,6 +786,8 @@ private void install( String basedir, Repository localRepository, ModelReader re
FileUtils.copyFile( new File( basedir, BUILD_DIR + "/" + finalName + ".jar" ), file ); 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, private void runTests( String basedir, String classes, String testClasses, ModelReader reader,
@ -807,7 +806,7 @@ private void runTests( String basedir, String classes, String testClasses, Model
excludes = new ArrayList(); excludes = new ArrayList();
excludes.add( "**/*Abstract*.java" ); excludes.add( "**/Abstract*Test.java" );
String reportsDir = new File( basedir, "target/surefire-reports" ).getAbsolutePath(); String reportsDir = new File( basedir, "target/surefire-reports" ).getAbsolutePath();

View File

@ -107,7 +107,11 @@ else if ( LAYOUT_DEFAULT.equals( layout ) )
repositoryPath = dependency.getGroupId().replace( '.', '/' ); repositoryPath = dependency.getGroupId().replace( '.', '/' );
// if ( !dependency.getType().equals( "pom" ) ) // 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; repositoryPath = repositoryPath + "/" + filename;
} }

View File

@ -25,6 +25,7 @@
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@ -83,12 +84,12 @@ public class SurefirePlugin
/** /**
* @parameter * @parameter
*/ */
private List includes; private List includes = new ArrayList( Collections.singletonList( "**/*Test.java" ) );
/** /**
* @parameter * @parameter
*/ */
private List excludes; private List excludes = new ArrayList( Collections.singletonList( "**/Abstract*Test.java" ) );
/** /**
* @parameter expression="${localRepository}" * @parameter expression="${localRepository}"

View File

@ -38,64 +38,6 @@
<directory>src/test/resources</directory> <directory>src/test/resources</directory>
</testResource> </testResource>
</testResources> </testResources>
<!-- Default plugins -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
<configuration>
<includes>
<include implementation="java.lang.String">**/*Test.java</include>
</includes>
<excludes>
<exclude implementation="java.lang.String">**/Abstract*Test.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pom-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>