Author: jdcasey
Date: Tue Jan 10 19:15:30 2006
New Revision: 367892
URL: http://svn.apache.org/viewcvs?rev=367892&view=rev
Log:
Adding goalsFile parameter to allow customization of the goals to be called on
a per-project basis.
Added:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml (with
props)
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/build.log
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
(with props)
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
(with props)
Modified:
maven/sandbox/plugins/maven-it-plugin/src/main/java/org/apache/maven/plugin/it/ForkMojo.java
Modified:
maven/sandbox/plugins/maven-it-plugin/src/main/java/org/apache/maven/plugin/it/ForkMojo.java
URL:
http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-it-plugin/src/main/java/org/apache/maven/plugin/it/ForkMojo.java?rev=367892&r1=367891&r2=367892&view=diff
==============================================================================
---
maven/sandbox/plugins/maven-it-plugin/src/main/java/org/apache/maven/plugin/it/ForkMojo.java
(original)
+++
maven/sandbox/plugins/maven-it-plugin/src/main/java/org/apache/maven/plugin/it/ForkMojo.java
Tue Jan 10 19:15:30 2006
@@ -30,7 +30,10 @@
import org.apache.maven.project.ProjectSorter;
import org.codehaus.plexus.util.dag.CycleDetectedException;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -61,7 +64,7 @@
/**
* Directory to search for integration tests.
- * @parameter default-value="${project.basedir}/src/it/"
expression="${it.testDir}"
+ * @parameter default-value="${basedir}/src/it/" expression="${it.testDir}"
*/
private File integrationTestsDirectory;
@@ -99,6 +102,13 @@
* @parameter expression="${it.goals}" default-value="package"
*/
private String goals;
+
+ /**
+ * The name of the project-specific file that contains the enumeration of
goals to execute for that test.
+ *
+ * @parameter
+ */
+ private String goalFile;
public void execute()
throws MojoExecutionException, MojoFailureException
@@ -164,6 +174,22 @@
List projectGoals = goalList;
+ if ( goalFile != null )
+ {
+ File projectGoalList = new File(
project.getFile().getParentFile(), goalFile );
+
+ if ( projectGoalList.exists() )
+ {
+ List goals = readFromFile( projectGoalList );
+
+ if ( goals != null && !goals.isEmpty() )
+ {
+ getLog().info( "Using goals specified in file: " +
projectGoalList );
+ projectGoals = goals;
+ }
+ }
+ }
+
String defaultGoal = project.getDefaultGoal();
if ( defaultGoal != null && defaultGoal.trim().length() > 0 )
@@ -172,6 +198,10 @@
projectGoals = Collections.singletonList( defaultGoal );
}
+ else
+ {
+ getLog().info( "Executing goals: " + projectGoals + " for
project: " + project.getId() );
+ }
getLog().info( "Running test: " + project.getId() + "..." );
@@ -241,6 +271,46 @@
{
throw new MojoFailureException( this, "There were test failures.",
failures.size() + " tests failed." );
}
+ }
+
+ private List readFromFile( File projectGoalList )
+ {
+ BufferedReader reader = null;
+
+ List result = null;
+
+ try
+ {
+ reader = new BufferedReader( new FileReader( projectGoalList ) );
+
+ result = new ArrayList();
+
+ String line = null;
+ while( ( line = reader.readLine() ) != null )
+ {
+ result.addAll( collectListFromCSV( line ) );
+ }
+ }
+ catch( IOException e )
+ {
+ getLog().warn( "Failed to load goal list from file: " +
projectGoalList + ". Using 'goal' parameter configured on this plugin instead."
);
+ getLog().debug( "Error reading goals file: " + projectGoalList, e
);
+ }
+ finally
+ {
+ if ( reader != null )
+ {
+ try
+ {
+ reader.close();
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+
+ return result;
}
private List collectListFromCSV( String csv )
Added: maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml?rev=367892&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml (added)
+++ maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml Tue Jan
10 19:15:30 2006
@@ -0,0 +1,31 @@
+<model
+ 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"
+>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>it-plugin-test</artifactId>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-it-plugin</artifactId>
+
+ <configuration>
+ <goalFile>goals.txt</goalFile>
+ </configuration>
+
+ <executions>
+ <execution>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</model>
Propchange: maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/build.log
URL:
http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/build.log?rev=367892&view=auto
==============================================================================
---
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/build.log
(added)
+++
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/build.log
Tue Jan 10 19:15:30 2006
@@ -0,0 +1 @@
+[info] [resources:resources][info] [compiler:compile][info]
[resources:testResources][info] [compiler:testCompile][info]
[surefire:test][info] [jar:jar][info] [resources:resources][info]
[compiler:compile]
\ No newline at end of file
Added:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
URL:
http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt?rev=367892&view=auto
==============================================================================
---
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
(added)
+++
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
Tue Jan 10 19:15:30 2006
@@ -0,0 +1 @@
+compile
Propchange:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml?rev=367892&view=auto
==============================================================================
---
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
(added)
+++
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
Tue Jan 10 19:15:30 2006
@@ -0,0 +1,6 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins.it.tests</groupId>
+ <artifactId>test1</artifactId>
+ <version>1.0</version>
+</project>
Propchange:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/plugins/maven-it-plugin/test-with-goals-file/src/it/test1/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"