You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2008/07/16 21:35:14 UTC

svn commit: r677395 - in /maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths: plugin/src/main/java/plugin/Mojo3563.java project/pom.xml

Author: jdcasey
Date: Wed Jul 16 12:35:14 2008
New Revision: 677395

URL: http://svn.apache.org/viewvc?rev=677395&view=rev
Log:
[MNG-3536] Modifying test plugin and test project to check paths injected into plugin configuration as well.

Modified:
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/plugin/src/main/java/plugin/Mojo3563.java
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/project/pom.xml

Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/plugin/src/main/java/plugin/Mojo3563.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/plugin/src/main/java/plugin/Mojo3563.java?rev=677395&r1=677394&r2=677395&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/plugin/src/main/java/plugin/Mojo3563.java (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/plugin/src/main/java/plugin/Mojo3563.java Wed Jul 16 12:35:14 2008
@@ -5,21 +5,34 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.model.Model;
+import org.codehaus.plexus.util.IOUtil;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
 
 /**
- *
  * @goal validate
  * @phase validate
  */
-public class Mojo3563 extends AbstractMojo {
+public class Mojo3563
+    extends AbstractMojo
+{
 
     /**
-     * @parameter expression="${project}"
+     * @parameter default-value="${project}"
      */
     private MavenProject project;
 
+    /**
+     * @parameter
+     * @required
+     */
+    private File foo;
+
     public void execute() throws MojoExecutionException, MojoFailureException {
         Model model = project.getModel();
         String property = model.getProperties().getProperty("test");
@@ -32,6 +45,46 @@
             throw new MojoExecutionException("Test file does not exist: File = " + testFile.getAbsolutePath() + "Property = " + property);
         }
         getLog().info("Property = " + property);
-
+        
+        File f = new File( project.getBuild().getOutputDirectory(), "foo.txt" );
+        getLog().info( "Creating test file using project.getBuild().getDirectory(): " + f );
+        
+        String testValue = "" + System.currentTimeMillis();
+        
+        FileWriter w = null;
+        try
+        {
+            f.getParentFile().mkdirs();
+            w = new FileWriter( f );
+            
+            w.write( testValue );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Failed to write test file.", e );
+        }
+        finally
+        {
+            IOUtil.close( w );
+        }
+        
+        getLog().info( "Attempting to read test file using path from plugin parameter: " + foo );
+        BufferedReader r = null;
+        try
+        {
+            r = new BufferedReader( new FileReader( foo ) );
+            if ( !testValue.equals( r.readLine() ) )
+            {
+                throw new MojoExecutionException( "Test file: " + foo + " has wrong contents." );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Failed to read test file.", e );
+        }
+        finally
+        {
+            IOUtil.close( r );
+        }
     }
 }

Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/project/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/project/pom.xml?rev=677395&r1=677394&r2=677395&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/project/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3536-appendedAbsolutePaths/project/pom.xml Wed Jul 16 12:35:14 2008
@@ -38,6 +38,9 @@
                         <goals>
                             <goal>validate</goal>
                         </goals>
+                        <configuration>
+                          <foo>${project.build.outputDirectory}/foo.txt</foo>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>