From dd0a1b6d40b90620ccc0e95d97216e8763dfb03d Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 27 Aug 2009 15:03:00 +0000 Subject: [PATCH] o Extended plugin to track execution of forking mojo git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@808445 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/coreit/ForkLifecycleMojo.java | 9 +++++++++ .../org/apache/maven/plugin/coreit/TouchMojo.java | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java index 6a8e5c37a5..cb5d616bc5 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java @@ -23,6 +23,8 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.io.File; + /** * @goal fork * @@ -41,9 +43,16 @@ public class ForkLifecycleMojo */ private MavenProject executedProject; + /** + * @parameter default-value="${project.build.directory}" + */ + private File touchDirectory; + public void execute() throws MojoExecutionException { + TouchMojo.touch( touchDirectory, "fork-lifecycle.txt", true ); + if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) ) { throw new MojoExecutionException( "Unexpected result, final name of executed project is " diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java index bdc63d28c7..f05550396f 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java @@ -25,7 +25,8 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; import java.io.IOException; import java.util.Map; @@ -133,7 +134,13 @@ public class TouchMojo project.getBuild().setFinalName( FINAL_NAME ); } - private static void touch( File dir, String file ) + static void touch( File dir, String file ) + throws MojoExecutionException + { + touch( dir, file, false ); + } + + static void touch( File dir, String file, boolean append ) throws MojoExecutionException { try @@ -145,9 +152,10 @@ public class TouchMojo File touch = new File( dir, file ); - FileWriter w = new FileWriter( touch ); + OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( touch, append ), "UTF-8" ); w.write( file ); + w.write( "\n" ); w.close(); }