mirror of https://github.com/apache/maven.git
PR: MNG-956
allow the addition of <dependencies> inside a <plugin> element to introduce plugin specific extensions. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293557 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cfa8ba1eff
commit
51489cd0fd
|
@ -220,6 +220,8 @@ it0079: Test that source attachments have the same build number as the main
|
|||
it0080: Test that depending on a WAR doesn't also get its dependencies
|
||||
transitively.
|
||||
|
||||
it0081: Test per-plugin dependencies.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
it0081
|
||||
it0080
|
||||
it0079
|
||||
it0078
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
test-component-c/target/org.apache.maven.wagon.providers.ftp.FtpWagon
|
|
@ -0,0 +1 @@
|
|||
install
|
|
@ -0,0 +1,13 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-components</artifactId>
|
||||
<version>0.1</version>
|
||||
<name>Test Components</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>test-component-c</module>
|
||||
<module>test-plugin</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -0,0 +1,37 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>test-components</artifactId>
|
||||
<groupId>test</groupId>
|
||||
<version>0.1</version>
|
||||
</parent>
|
||||
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-component-c</artifactId>
|
||||
<version>0.1</version>
|
||||
<name>Test Component C</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-plugin</artifactId>
|
||||
<version>0.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<version>1.0-alpha-4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>test-components</artifactId>
|
||||
<groupId>test</groupId>
|
||||
<version>0.1</version>
|
||||
</parent>
|
||||
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>0.1</version>
|
||||
<name>Test Plugin</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0-beta-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,75 @@
|
|||
package org.apache.maven.plugin.coreit;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* test goal.
|
||||
*
|
||||
* @goal test
|
||||
* @phase test
|
||||
*/
|
||||
public class CoreItMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* @parameter expression="${project.build.directory}"
|
||||
* @required
|
||||
*/
|
||||
private String outputDirectory;
|
||||
|
||||
/**
|
||||
* @component role="org.apache.maven.wagon.Wagon" roleHint="ftp"
|
||||
*/
|
||||
private Object wagon;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
touch( new File( outputDirectory ), wagon.getClass().getName() );
|
||||
}
|
||||
|
||||
private static void touch( File dir, String file )
|
||||
throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !dir.exists() )
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File touch = new File( dir, file );
|
||||
|
||||
FileWriter w = new FileWriter( touch );
|
||||
|
||||
w.write( file );
|
||||
|
||||
w.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error touching file", e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.settings.Settings;
|
||||
|
@ -66,7 +67,6 @@ import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
|||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.logging.LoggerManager;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
@ -85,7 +85,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DefaultPluginManager
|
||||
extends AbstractLogEnabled
|
||||
|
@ -304,6 +303,17 @@ public class DefaultPluginManager
|
|||
// later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
|
||||
// transitively resolve its dependencies, and add them to the plugin container...
|
||||
addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
|
||||
|
||||
try
|
||||
{
|
||||
Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null,
|
||||
project.getProjectReferences() );
|
||||
addedPlugin.setIntroducedDependencyArtifacts( artifacts );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new PluginManagerException( "Unable to get one of the plugins additional dependencies", e );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -506,10 +516,7 @@ public class DefaultPluginManager
|
|||
return pluginContainer;
|
||||
}
|
||||
|
||||
private Mojo getConfiguredMojo( MavenSession session,
|
||||
Xpp3Dom dom,
|
||||
MavenProject project,
|
||||
boolean report,
|
||||
private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
|
||||
MojoExecution mojoExecution )
|
||||
throws ComponentLookupException, PluginConfigurationException, PluginManagerException
|
||||
{
|
||||
|
@ -592,7 +599,9 @@ public class DefaultPluginManager
|
|||
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository,
|
||||
project.getPluginArtifactRepositories() );
|
||||
|
||||
Set dependencies = resolutionGroup.getArtifacts();
|
||||
Set dependencies = new HashSet( resolutionGroup.getArtifacts() );
|
||||
|
||||
dependencies.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() );
|
||||
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
|
||||
localRepository,
|
||||
|
@ -1041,13 +1050,14 @@ public class DefaultPluginManager
|
|||
}
|
||||
catch ( ComponentConfigurationException e )
|
||||
{
|
||||
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to parse the created DOM for plugin configuration", e );
|
||||
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
|
||||
"Unable to parse the created DOM for plugin configuration", e );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new PluginConfigurationException(mojoDescriptor.getPluginDescriptor(),
|
||||
"Unable to retrieve component configurator for plugin configuration",
|
||||
e );
|
||||
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
|
||||
"Unable to retrieve component configurator for plugin configuration",
|
||||
e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -2387,6 +2387,15 @@
|
|||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>dependencies</name>
|
||||
<description>Additional dependencies that this project needs to introduce to the plugin</description>
|
||||
<version>4.0.0</version>
|
||||
<association>
|
||||
<type>Dependency</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>goals</name>
|
||||
<version>4.0.0</version>
|
||||
|
@ -2543,7 +2552,7 @@
|
|||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
java.util.Map reportPluginMap;
|
||||
|
||||
|
||||
public void flushReportPluginMap()
|
||||
{
|
||||
this.reportPluginMap = null;
|
||||
|
@ -2575,7 +2584,7 @@
|
|||
<superClass>ModelBase</superClass>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
Modifications to the build process which is keyed on some
|
||||
Modifications to the build process which is keyed on some
|
||||
sort of environmental parameter.
|
||||
]]></description>
|
||||
<fields>
|
||||
|
@ -2613,17 +2622,17 @@
|
|||
// We don't want this to be parseable...it's sort of 'hidden'
|
||||
// default source for this profile is in the pom itself.
|
||||
private String source = "pom";
|
||||
|
||||
|
||||
public void setSource( String source )
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
public String getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Profile {id: " + getId() + ", source: " + getSource() + "}";
|
||||
|
@ -2636,7 +2645,7 @@
|
|||
<name>Activation</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
The conditions within the build runtime environment which will trigger
|
||||
The conditions within the build runtime environment which will trigger
|
||||
the automatic inclusion of the parent build profile.
|
||||
]]></description>
|
||||
<fields>
|
||||
|
@ -2690,7 +2699,7 @@
|
|||
<name>ActivationProperty</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is the property specification used to activate a profile. If the value field is empty,
|
||||
This is the property specification used to activate a profile. If the value field is empty,
|
||||
then the existence of the named property will activate the profile, otherwise it does a case-sensitive
|
||||
match against the property value as well.
|
||||
]]></description>
|
||||
|
|
|
@ -33,6 +33,9 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
|
@ -64,6 +67,8 @@ public class PluginDescriptor
|
|||
// calculated on-demand.
|
||||
private Map artifactMap;
|
||||
|
||||
private Set introducedDependencyArtifacts;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -214,18 +219,18 @@ public class PluginDescriptor
|
|||
public void setArtifacts( List artifacts )
|
||||
{
|
||||
this.artifacts = artifacts;
|
||||
|
||||
|
||||
// clear the calculated artifactMap
|
||||
artifactMap = null;
|
||||
}
|
||||
|
||||
|
||||
public Map getArtifactMap()
|
||||
{
|
||||
if ( artifactMap == null )
|
||||
{
|
||||
artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() );
|
||||
}
|
||||
|
||||
|
||||
return artifactMap;
|
||||
}
|
||||
|
||||
|
@ -308,4 +313,13 @@ public class PluginDescriptor
|
|||
return classRealm;
|
||||
}
|
||||
|
||||
public void setIntroducedDependencyArtifacts( Set introducedDependencyArtifacts )
|
||||
{
|
||||
this.introducedDependencyArtifacts = introducedDependencyArtifacts;
|
||||
}
|
||||
|
||||
public Set getIntroducedDependencyArtifacts()
|
||||
{
|
||||
return introducedDependencyArtifacts != null ? introducedDependencyArtifacts : Collections.EMPTY_SET;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue