You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/10/04 06:19:57 UTC
svn commit: r293520 - in /maven/components/trunk: maven-core-it/it0013/
maven-core-it/it0020/
maven-core/src/main/java/org/apache/maven/plugin/version/
maven-core/src/main/resources/META-INF/plexus/
maven-plugin-parameter-documenter/ maven-plugins/mave...
Author: jdcasey
Date: Mon Oct 3 21:19:40 2005
New Revision: 293520
URL: http://svn.apache.org/viewcvs?rev=293520&view=rev
Log:
Resolving: MNG-449, MNG-832
o If the metadata version is still in the plugin artifact after it's resolved, then simply return null and allow the plugin version resolution process to fail.
o Added a new mojo to update the plugin registry (if it's enabled) with newly installed versions of plugins.
o Added comments to maven-settings and maven-plugin-parameter-documenter poms marking the packageWithVersion config as deprecated pending modello alpha-5
o Cleaned up it0013 and it0020 to work with the new resolution (point one above).
Added:
maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java (with props)
Removed:
maven/components/trunk/maven-core-it/it0013/cli-options.txt
maven/components/trunk/maven-core-it/it0013/system.properties
maven/components/trunk/maven-core-it/it0020/cli-options.txt
maven/components/trunk/maven-core-it/it0020/system.properties
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-plugin-parameter-documenter/pom.xml
maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml
maven/components/trunk/maven-settings/pom.xml
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=293520&r1=293519&r2=293520&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Mon Oct 3 21:19:40 2005
@@ -566,7 +566,6 @@
}
private void writeUserRegistry( String groupId, String artifactId, PluginRegistry pluginRegistry )
- throws PluginVersionResolutionException
{
File pluginRegistryFile = pluginRegistry.getRuntimeInfo().getFile();
@@ -584,14 +583,12 @@
PluginRegistryXpp3Writer writer = new PluginRegistryXpp3Writer();
- writer.write( fWriter, PluginRegistryUtils.extractUserPluginRegistry( pluginRegistry ) );
+ writer.write( fWriter, extractedUserRegistry );
}
catch ( IOException e )
{
- // TODO: should we soften this to a warning??
- throw new PluginVersionResolutionException( groupId, artifactId,
- "Cannot rewrite user-level plugin-registry.xml with new plugin version.",
- e );
+ getLogger().warn( "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'"
+ + groupId + ":" + artifactId + "\'.", e );
}
finally
{
@@ -666,9 +663,11 @@
}
}
- if ( pluginValid )
+ String artifactVersion = artifact.getVersion();
+
+ if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
{
- version = artifact.getVersion();
+ version = artifactVersion;
}
}
}
Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=293520&r1=293519&r2=293520&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Mon Oct 3 21:19:40 2005
@@ -270,8 +270,13 @@
org.apache.maven.plugins:maven-jar-plugin:jar,
org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata
</package>
- <install>org.apache.maven.plugins:maven-install-plugin:install</install>
- <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ <install>
+ org.apache.maven.plugins:maven-install-plugin:install,
+ org.apache.maven.plugins:maven-plugin-plugin:updateRegistry
+ </install>
+ <deploy>
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
+ </deploy>
</phases>
<!-- END SNIPPET: maven-plugin-lifecycle -->
</configuration>
Modified: maven/components/trunk/maven-plugin-parameter-documenter/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-parameter-documenter/pom.xml?rev=293520&r1=293519&r2=293520&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-parameter-documenter/pom.xml (original)
+++ maven/components/trunk/maven-plugin-parameter-documenter/pom.xml Mon Oct 3 21:19:40 2005
@@ -18,6 +18,8 @@
<configuration>
<version>1.0.0</version>
<model>src/main/mdo/paramdoc.mdo</model>
+
+ <!-- The following config can be removed with modello -alpha-5 -->
<packageWithVersion>false</packageWithVersion>
</configuration>
Modified: maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml?rev=293520&r1=293519&r2=293520&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml Mon Oct 3 21:19:40 2005
@@ -24,6 +24,11 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-registry</artifactId>
+ <version>2.0-beta-3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-3-SNAPSHOT</version>
</dependency>
Added: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java?rev=293520&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java (added)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java Mon Oct 3 21:19:40 2005
@@ -0,0 +1,176 @@
+package org.apache.maven.plugin.plugin;
+
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.registry.MavenPluginRegistryBuilder;
+import org.apache.maven.plugin.registry.Plugin;
+import org.apache.maven.plugin.registry.PluginRegistry;
+import org.apache.maven.plugin.registry.PluginRegistryUtils;
+import org.apache.maven.plugin.registry.io.xpp3.PluginRegistryXpp3Writer;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Update the user plugin registry (if it's in use) to reflect the version we're installing.
+ *
+ * @goal updateRegistry
+ * @phase install
+ */
+public class UpdatePluginRegistryMojo
+ extends AbstractMojo
+{
+
+ /**
+ * @parameter default-value="${settings.usePluginRegistry}"
+ * @required
+ * @readonly
+ */
+ private boolean usePluginRegistry;
+
+ /**
+ * @parameter default-value="${project.groupId}"
+ * @required
+ * @readonly
+ */
+ private String groupId;
+
+ /**
+ * @parameter default-value="${project.artifactId}"
+ * @required
+ * @readonly
+ */
+ private String artifactId;
+
+ /**
+ * @parameter default-value="${project.artifact.version}"
+ * @required
+ * @readonly
+ */
+ private String version;
+
+ /**
+ * @component role="org.apache.maven.plugin.registry.MavenPluginRegistryBuilder"
+ */
+ private MavenPluginRegistryBuilder pluginRegistryBuilder;
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ if ( usePluginRegistry )
+ {
+ updatePluginVersionInRegistry( groupId, artifactId, version );
+ }
+ }
+
+ private void updatePluginVersionInRegistry( String groupId, String artifactId, String version ) throws MojoExecutionException
+ {
+ PluginRegistry pluginRegistry;
+ try
+ {
+ pluginRegistry = getPluginRegistry( groupId, artifactId );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Failed to read plugin registry.", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new MojoExecutionException( "Failed to parse plugin registry.", e );
+ }
+
+ String pluginKey = ArtifactUtils.versionlessKey( groupId, artifactId );
+ Plugin plugin = (Plugin) pluginRegistry.getPluginsByKey().get( pluginKey );
+
+ // if we can find the plugin, but we've gotten here, the useVersion must be missing; fill it in.
+ if ( plugin != null )
+ {
+ if ( PluginRegistry.GLOBAL_LEVEL.equals( plugin.getSourceLevel() ) )
+ {
+ // do nothing. We don't rewrite the globals, under any circumstances.
+ getLog().warn(
+ "Cannot update registered version for plugin {" + groupId + ":" + artifactId
+ + "}; it is specified in the global registry." );
+ }
+ else
+ {
+ plugin.setUseVersion( version );
+
+ SimpleDateFormat format = new SimpleDateFormat(
+ org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT );
+
+ plugin.setLastChecked( format.format( new Date() ) );
+ }
+ }
+ else
+ {
+ plugin = new org.apache.maven.plugin.registry.Plugin();
+
+ plugin.setGroupId( groupId );
+ plugin.setArtifactId( artifactId );
+ plugin.setUseVersion( version );
+
+ pluginRegistry.addPlugin( plugin );
+
+ pluginRegistry.flushPluginsByKey();
+ }
+
+ writeUserRegistry( groupId, artifactId, pluginRegistry );
+ }
+
+ private void writeUserRegistry( String groupId, String artifactId, PluginRegistry pluginRegistry )
+ {
+ File pluginRegistryFile = pluginRegistry.getRuntimeInfo().getFile();
+
+ PluginRegistry extractedUserRegistry = PluginRegistryUtils.extractUserPluginRegistry( pluginRegistry );
+
+ // only rewrite the user-level registry if one existed before, or if we've created user-level data here.
+ if ( extractedUserRegistry != null )
+ {
+ FileWriter fWriter = null;
+
+ try
+ {
+ pluginRegistryFile.getParentFile().mkdirs();
+ fWriter = new FileWriter( pluginRegistryFile );
+
+ PluginRegistryXpp3Writer writer = new PluginRegistryXpp3Writer();
+
+ writer.write( fWriter, extractedUserRegistry );
+ }
+ catch ( IOException e )
+ {
+ getLog().warn(
+ "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'"
+ + groupId + ":" + artifactId + "\'.", e );
+ }
+ finally
+ {
+ IOUtil.close( fWriter );
+ }
+ }
+ }
+
+ private PluginRegistry getPluginRegistry( String groupId, String artifactId )
+ throws IOException, XmlPullParserException
+ {
+ PluginRegistry pluginRegistry = null;
+
+ pluginRegistry = pluginRegistryBuilder.buildPluginRegistry();
+
+ if ( pluginRegistry == null )
+ {
+ pluginRegistry = pluginRegistryBuilder.createUserPluginRegistry();
+ }
+
+ return pluginRegistry;
+ }
+
+}
Propchange: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/UpdatePluginRegistryMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-settings/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-settings/pom.xml?rev=293520&r1=293519&r2=293520&view=diff
==============================================================================
--- maven/components/trunk/maven-settings/pom.xml (original)
+++ maven/components/trunk/maven-settings/pom.xml Mon Oct 3 21:19:40 2005
@@ -14,9 +14,12 @@
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
+
+ <!-- The following configuration can be removed with modello -alpha-5 -->
<configuration>
<packageWithVersion>false</packageWithVersion>
</configuration>
+
<executions>
<execution>
<goals>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org