incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewor...@apache.org
Subject svn commit: r609088 - in /incubator/nmaven/trunk: components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/ plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/ plugins/maven-compiler-plugin/src/main/java/org/apache/...
Date Sat, 05 Jan 2008 03:57:59 GMT
Author: eworley
Date: Fri Jan  4 19:57:58 2008
New Revision: 609088

URL: http://svn.apache.org/viewvc?rev=609088&view=rev
Log:
* Adding test-assemblies to build directories
* Added check to DotnetTestMojo to not attempt to run if test assembly was not compiled (no
test source)
* Added step to TestCompilerMojo to generate the test-assemblies target directory and copy
over test scoped dependencies

Modified:
    incubator/nmaven/trunk/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/BuildDirectories.java
    incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
    incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
    incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java

Modified: incubator/nmaven/trunk/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/BuildDirectories.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/BuildDirectories.java?rev=609088&r1=609087&r2=609088&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/BuildDirectories.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/BuildDirectories.java
Fri Jan  4 19:57:58 2008
@@ -26,6 +26,7 @@
     BUILD_SOURCES("build-sources"),
     BUILD_SOURCES_MAIN("build-sources/main-sources"),
     BUILD_SOURCES_GENERATED("build-sources/generated-sources"),
+    TEST_ASSEMBLIES("test-assemblies"),
     TEST_SOURCES("test-sources"),
     TEST_SOURCES_MAIN("test-sources/main-sources"),
     TEST_SOURCES_GENERATED("test-sources/generated-sources"),

Modified: incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java?rev=609088&r1=609087&r2=609088&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/dotnet-test-plugin/src/main/java/org/apache/maven/dotnet/plugin/nunit/DotnetTestMojo.java
Fri Jan  4 19:57:58 2008
@@ -72,6 +72,13 @@
             return;
         }
         
+        // Verify that we have tests to run
+        File testAssembly = new File( project.getBuild().getDirectory(), getTestAssemblyName()
);
+        if ( !testAssembly.exists() )
+        {
+            return;
+        }
+        
         // The directory where the test artifact exists
         String outputDirectory = project.getBuild().getDirectory();
 
@@ -109,7 +116,6 @@
 
     private String getTestAssemblyName()
     {
-
         File file = project.getArtifact().getFile();
         String pieces = file.getName().substring( 0, file.getName().lastIndexOf( '.' ) );
         String testAssemblyName = pieces + "-test.dll";

Modified: incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java?rev=609088&r1=609087&r2=609088&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
Fri Jan  4 19:57:58 2008
@@ -73,7 +73,7 @@
     /**
      * @component
      */
-    private DotnetCompilerContext dotnetCompilerContext;
+    protected DotnetCompilerContext dotnetCompilerContext;
 
     /**
      * Performs compilation

Modified: incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java?rev=609088&r1=609087&r2=609088&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
Fri Jan  4 19:57:58 2008
@@ -18,10 +18,17 @@
  */
 package org.apache.maven.dotnet.plugin.compiler;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.dotnet.ArtifactScope;
 import org.apache.maven.dotnet.BuildDirectories;
 import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
 
 /**
  * Maven Mojo for compiling Class files to the .NET Intermediate Language.
@@ -48,7 +55,42 @@
         
         compilerConfig.setTestCompile( true );
         
-        compile( compilerConfig );
+        // Compile the test sources
+        File testAssembly = compile( compilerConfig );
+        
+        // Make sure we performed a compile
+        if ( testAssembly == null ) {
+            return;
+        }
+        
+        // Create and populate the test assemblies directory
+        File testAssemblies =
+            new File( project.getBuild().getDirectory(), BuildDirectories.TEST_ASSEMBLIES.getBuildDirectoryName()
);
+
+        if ( !testAssemblies.exists() && !testAssemblies.mkdirs() )
+        {
+            throw new MojoExecutionException( "Unable to create test assemblies directory:
" + testAssemblies );
+        }
+
+        Set<Artifact> testDependencies = dotnetCompilerContext.getLibraryDependenciesFor(
ArtifactScope.TEST );
+
+        // Copy the test dependencies to the test-assemblies directory
+        try
+        {
+            for ( Artifact testDependency : testDependencies )
+            {
+                File testDependencyFile = testDependency.getFile();
+                File testAssembliesFile = new File( testAssemblies, testDependencyFile.getName()
);
+                FileUtils.copyFile( testDependencyFile, testAssembliesFile );
+            }
+
+            File copiedTestAssembly = new File( testAssemblies, testAssembly.getName() );
+            FileUtils.copyFile( testAssembly, copiedTestAssembly );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Unable to copy all test assemblies to execution
directory" );
+        }
     }
 
     @Override



Mime
View raw message