From 5e7d4e0821835468e3bb3bcfea60433af7da9147 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 4 Sep 2010 20:17:55 +0000 Subject: [PATCH] o Extended IT plugin to allow distinction of multiple executions git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@992668 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/coreit/AbstractDependencyMojo.java | 21 +++++++++++++++++++ .../maven/plugin/coreit/CompileMojo.java | 4 +++- .../plugin/coreit/CompileRuntimeMojo.java | 3 ++- .../maven/plugin/coreit/RuntimeMojo.java | 4 +++- .../apache/maven/plugin/coreit/TestMojo.java | 4 +++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java index 36474f323b..e398b1b26d 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java @@ -333,6 +333,12 @@ public abstract class AbstractDependencyMojo if ( pathname != null ) { + if ( pathname.indexOf( "@idx@" ) >= 0 ) + { + // helps to distinguished forked executions of the same mojo + pathname = pathname.replaceAll( "@idx@", String.valueOf( nextCounter() ) ); + } + file = new File( pathname ); if ( !file.isAbsolute() ) @@ -344,4 +350,19 @@ public abstract class AbstractDependencyMojo return file; } + private int nextCounter() + { + int counter = 0; + + String key = getClass().getName(); + + synchronized ( System.class ) + { + counter = Integer.getInteger( key, 0 ).intValue(); + System.setProperty( key, Integer.toString( counter + 1 ) ); + } + + return counter; + } + } diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java index 114baab00b..76470accba 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java @@ -23,7 +23,9 @@ import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; /** - * Creates text files that list the dependencies with scope compile in the order returned from the Maven core. + * Creates text files that list the dependencies with scope compile in the order returned from the Maven core. The path + * parameters of this mojo support the token @idx@ to dynamically insert a running index in order + * to distinguish multiple executions of the same mojo. * * @goal compile * @requiresDependencyResolution compile diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileRuntimeMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileRuntimeMojo.java index c7c237d905..960c289f05 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileRuntimeMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/CompileRuntimeMojo.java @@ -24,7 +24,8 @@ import org.apache.maven.plugin.MojoExecutionException; /** * Creates text files that list the dependencies with scope compile and runtime in the order returned from the Maven - * core. + * core. The path parameters of this mojo support the token @idx@ to dynamically insert a running + * index in order to distinguish multiple executions of the same mojo. * * @goal compile-runtime * @requiresDependencyResolution compile+runtime diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java index 26f74b8593..a6c3cca954 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java @@ -23,7 +23,9 @@ import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; /** - * Creates text files that list the dependencies with scope runtime in the order returned from the Maven core. + * Creates text files that list the dependencies with scope runtime in the order returned from the Maven core. The path + * parameters of this mojo support the token @idx@ to dynamically insert a running index in order + * to distinguish multiple executions of the same mojo. * * @goal runtime * @requiresDependencyResolution runtime diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java index 34ffee653e..8f15a06393 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java @@ -23,7 +23,9 @@ import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; /** - * Creates text files that list the dependencies with scope test in the order returned from the Maven core. + * Creates text files that list the dependencies with scope test in the order returned from the Maven core. The path + * parameters of this mojo support the token @idx@ to dynamically insert a running index in order + * to distinguish multiple executions of the same mojo. * * @goal test * @requiresDependencyResolution test