maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r462641 - in /maven/plugins/trunk/maven-antrun-plugin: ./ src/it/test6/ src/main/java/org/apache/maven/plugin/antrun/ src/main/java/org/apache/maven/plugin/antrun/components/ src/main/resources/ src/test/java/org/apache/maven/plugin/antrun/
Date Tue, 10 Oct 2006 23:56:45 GMT
Author: jvanzyl
Date: Tue Oct 10 16:56:44 2006
New Revision: 462641

URL: http://svn.apache.org/viewvc?view=rev&rev=462641
Log:
o turning off the tests inside the antrun plugins and turning on the ITs using the maven-invoker-plugin


Removed:
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/components/
    maven/plugins/trunk/maven-antrun-plugin/src/main/resources/
Modified:
    maven/plugins/trunk/maven-antrun-plugin/pom.xml
    maven/plugins/trunk/maven-antrun-plugin/src/it/test6/build.xml
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
    maven/plugins/trunk/maven-antrun-plugin/src/test/java/org/apache/maven/plugin/antrun/AntRunMojoTest.java

Modified: maven/plugins/trunk/maven-antrun-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/pom.xml?view=diff&rev=462641&r1=462640&r2=462641
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-antrun-plugin/pom.xml Tue Oct 10 16:56:44 2006
@@ -17,8 +17,8 @@
 -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
@@ -39,6 +39,11 @@
   </issueManagement>
   <dependencies>
     <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-ant</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0.1</version>
@@ -66,4 +71,28 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <configuration>
+          <debug>true</debug>
+          <projectsDirectory>src/it</projectsDirectory>
+          <pomIncludes>
+            <pomInclude>**/pom.xml</pomInclude>
+          </pomIncludes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
+

Modified: maven/plugins/trunk/maven-antrun-plugin/src/it/test6/build.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/it/test6/build.xml?view=diff&rev=462641&r1=462640&r2=462641
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/it/test6/build.xml (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/it/test6/build.xml Tue Oct 10 16:56:44 2006
@@ -2,9 +2,9 @@
 <project name="test6">
 
     <target name="test">
-
+        <mkdir dir="${basedir}/target"/>
         <!-- <taskdef name="antlr" classname="org.apache.tools.ant.taskdefs.optional.ANTLR"/>
-->
-
+        
         <antlr target="calc.g" outputdirectory="target">
             <classpath refid="maven.plugin.classpath"/>
         </antlr>

Modified: maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java?view=diff&rev=462641&r1=462640&r2=462641
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
(original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
Tue Oct 10 16:56:44 2006
@@ -16,26 +16,13 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-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.plugin.antrun.components.AntTargetConverter;
 import org.apache.maven.project.MavenProject;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DefaultLogger;
+import org.apache.maven.shared.ant.AntProjectPopulator;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.PropertyHelper;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.types.Path;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.util.StringUtils;
+
+import java.util.List;
 
 /**
  * Abstract class for the Antrun plugin
@@ -56,113 +43,11 @@
      */
     private List artifacts;
 
-    /**
-     * @param antTasks
-     * @param mavenProject
-     * @throws MojoExecutionException
-     */
-    protected void executeTasks( Target antTasks, MavenProject mavenProject )
+    protected void populateAntProjectWithMavenInformation( MavenProject mavenProject, Project
antProject )
         throws MojoExecutionException
     {
-        if ( antTasks == null )
-        {
-            getLog().info( "No ant tasks defined - SKIPPED" );
-            return;
-        }
-
-        try
-        {
-            //TODO refactor - place the manipulation of the expressionEvaluator into a separated
class.
-            ExpressionEvaluator exprEvaluator = (ExpressionEvaluator) antTasks.getProject()
-                .getReference( AntTargetConverter.MAVEN_EXPRESSION_EVALUATOR_ID );
-
-            Project antProject = antTasks.getProject();
-
-            PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper( antProject
);
-            propertyHelper.setNext( new AntPropertyHelper( exprEvaluator, mavenProject.getArtifacts(),
getLog() ) );
-
-            DefaultLogger antLogger = new DefaultLogger();
-            antLogger.setOutputPrintStream( System.out );
-            antLogger.setErrorPrintStream( System.err );
-            antLogger.setMessageOutputLevel( getLog().isDebugEnabled() ? Project.MSG_DEBUG
: Project.MSG_INFO );
-
-            antProject.addBuildListener( antLogger );
-            antProject.setBaseDir( mavenProject.getBasedir() );
-
-            Path p = new Path( antProject );
-            p.setPath( StringUtils.join( mavenProject.getCompileClasspathElements().iterator(),
File.pathSeparator ) );
-
-            /* maven.dependency.classpath it's deprecated as it's equal to maven.compile.classpath
*/
-            antProject.addReference( "maven.dependency.classpath", p );
-            antProject.addReference( "maven.compile.classpath", p );
-
-            p = new Path( antProject );
-            p.setPath( StringUtils.join( mavenProject.getRuntimeClasspathElements().iterator(),
File.pathSeparator ) );
-            antProject.addReference( "maven.runtime.classpath", p );
+        AntProjectPopulator app = new AntProjectPopulator();
 
-            p = new Path( antProject );
-            p.setPath( StringUtils.join( mavenProject.getTestClasspathElements().iterator(),
File.pathSeparator ) );
-            antProject.addReference( "maven.test.classpath", p );
-
-            /* set maven.plugin.classpath with plugin dependencies */
-            antProject.addReference( "maven.plugin.classpath", getPathFromArtifacts( artifacts,
antProject ) );
-
-            if ( getLog().isInfoEnabled() )
-            {
-                getLog().info( "Executing tasks" );
-            }
-
-            antTasks.execute();
-
-            if ( getLog().isInfoEnabled() )
-            {
-                getLog().info( "Executed tasks" );
-            }
-        }
-        catch ( DependencyResolutionRequiredException e )
-        {
-            throw new MojoExecutionException( "DependencyResolutionRequiredException: " +
e.getMessage(), e );
-        }
-        catch ( BuildException e )
-        {
-            throw new MojoExecutionException( "An Ant BuildException has occured: " + e.getMessage(),
e );
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "Error executing ant tasks: " + e.getMessage(),
e );
-        }
+        app.populateAntProjectWithMavenInformation( mavenProject, antProject, artifacts,
getLog() );
     }
-
-    /**
-     * @param artifacts
-     * @param antProject
-     * @return a path
-     * @throws DependencyResolutionRequiredException
-     */
-    public Path getPathFromArtifacts( Collection artifacts, Project antProject )
-        throws DependencyResolutionRequiredException
-    {
-        if ( artifacts == null )
-        {
-            return new Path( antProject );
-        }
-
-        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() );
-        }
-
-        Path p = new Path( antProject );
-        p.setPath( StringUtils.join( list.iterator(), File.pathSeparator ) );
-
-        return p;
-    }
-
 }

Modified: maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java?view=diff&rev=462641&r1=462640&r2=462641
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
(original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
Tue Oct 10 16:56:44 2006
@@ -16,12 +16,12 @@
  * limitations under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.tools.ant.Target;
 
+import java.io.File;
+
 /**
  * Maven AntRun Mojo.
  *
@@ -82,7 +82,9 @@
     public void execute()
         throws MojoExecutionException
     {
-        executeTasks( tasks, project );
+        populateAntProjectWithMavenInformation( project, tasks.getProject() );
+
+        tasks.execute();
 
         if ( sourceRoot != null )
         {

Modified: maven/plugins/trunk/maven-antrun-plugin/src/test/java/org/apache/maven/plugin/antrun/AntRunMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/test/java/org/apache/maven/plugin/antrun/AntRunMojoTest.java?view=diff&rev=462641&r1=462640&r2=462641
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/test/java/org/apache/maven/plugin/antrun/AntRunMojoTest.java
(original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/test/java/org/apache/maven/plugin/antrun/AntRunMojoTest.java
Tue Oct 10 16:56:44 2006
@@ -68,8 +68,10 @@
     public void testDefaultProject()
         throws Exception
     {
+        /*
         String result = invokeMaven( "antrun-default-test", new Properties() );
         assertTrue( result.indexOf( "[echo] Hello World!" ) != -1 );
+        */
     }
 
     /**
@@ -80,6 +82,7 @@
     public void testTasksAttributesProject()
         throws Exception
     {
+        /*
         Properties properties = new Properties();
 
         String result = invokeMaven( "tasksattributes-test", properties );
@@ -88,6 +91,7 @@
         properties.put( "maven.test.skip", "true" );
         result = invokeMaven( "tasksattributes-test", properties );
         assertTrue( result.indexOf( "[echo] To skip me" ) == -1 );
+        */
     }
 
     /**



Mime
View raw message