You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:27:21 UTC
[maven-antrun-plugin] 12/26: Added maven.plugin.classpath reference
PR: MNG-1702
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to annotated tag maven-antrun-plugin-1.1
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git
commit d43fa78eebb4c097084f3119bcd36a78edf87700
Author: Carlos Sanchez Gonzalez <ca...@apache.org>
AuthorDate: Wed Nov 30 02:29:20 2005 +0000
Added maven.plugin.classpath reference
PR: MNG-1702
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-antrun-plugin@349863 13f79535-47bb-0310-9956-ffa450edef68
---
.../maven/plugin/antrun/AbstractAntMojo.java | 36 ++++++++++++++++++++--
src/site/apt/usage.apt | 12 ++++++++
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java b/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
index cc5a29f..9efd3e9 100644
--- a/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
+++ b/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
@@ -16,6 +16,13 @@ package org.apache.maven.plugin.antrun;
* limitations under the License.
*/
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -26,14 +33,22 @@ import org.apache.tools.ant.Target;
import org.apache.tools.ant.types.Path;
import org.codehaus.plexus.util.StringUtils;
-import java.io.File;
-
/**
* @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
*/
public abstract class AbstractAntMojo
extends AbstractMojo
{
+
+ /**
+ * The plugin dependencies.
+ *
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
+ */
+ private List artifacts;
+
protected void executeTasks( Target antTasks, MavenProject mavenProject )
throws MojoExecutionException
{
@@ -66,6 +81,23 @@ public abstract class AbstractAntMojo
p.setPath( StringUtils.join( mavenProject.getTestClasspathElements().iterator(), File.pathSeparator ) );
antProject.addReference( "maven.test.classpath", p );
+ /* set maven.plugin.classpath with plugin dependencies */
+ List list = new ArrayList( artifacts.size() );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ File file = a.getFile();
+ if ( file == null )
+ {
+ throw new DependencyResolutionRequiredException( a );
+ }
+ list.add( file.getPath() );
+ }
+ p = new Path( antProject );
+ p.setPath( StringUtils.join( list.iterator(), File.pathSeparator ) );
+ antProject.addReference( "maven.plugin.classpath", p );
+
getLog().info( "Executing tasks" );
antTasks.execute();
diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt
index d505e03..502b725 100644
--- a/src/site/apt/usage.apt
+++ b/src/site/apt/usage.apt
@@ -52,7 +52,19 @@ Usage
lifecycle phase. You can add a script to each lifecycle phase,
by duplicating the <<<\<execution/\>>>> section and specifying
a new phase.
+
+
+ You can use these classpath references:
+ * <<<maven.dependency.classpath>>>
+
+ * <<<maven.compile.classpath>>>
+
+ * <<<maven.runtime.classpath>>>
+
+ * <<<maven.test.classpath>>>
+
+ * <<<maven.plugin.classpath>>>
Below you can see how to indicate that ant has generated some more java
source that needs to be included in the compilation phase. Note that the
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.