You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nmaven-commits@incubator.apache.org by si...@apache.org on 2007/05/21 23:06:52 UTC

svn commit: r540347 - /incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java

Author: sisbell
Date: Mon May 21 16:06:52 2007
New Revision: 540347

URL: http://svn.apache.org/viewvc?view=rev&rev=540347
Log:
Fixed FxCop to handle multi-module builds. A little tricky. FxCop was executing from the parent pom so it did not recognize the correct relative path. Can't use absolute path because commandline adds quotes that confuses FxCop. Had to rely on a system var for this one.

Modified:
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java

Modified: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java?view=diff&rev=540347&r1=540346&r2=540347
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java (original)
+++ incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java Mon May 21 16:06:52 2007
@@ -76,10 +76,25 @@
      */
     private File targetDirectory;
 
+    private File rootDir;
+
 
     public void execute()
         throws MojoExecutionException
     {
+        //For multi-module
+        if ( project.getPackaging().equals( "pom" ) )
+        {
+
+            if ( System.getProperty( "NMAVEN.ROOT_DIR" ) == null )
+            {
+                System.setProperty( "NMAVEN.ROOT_DIR", project.getBasedir().getAbsolutePath() );
+            }
+            return;
+        }
+
+        rootDir = ( System.getProperty( "NMAVEN.ROOT_DIR" ) != null ) ? new File(
+            System.getProperty( "NMAVEN.ROOT_DIR" ) ) : null;
 
         ArtifactRepository localArtifactRepository =
             new DefaultArtifactRepository( "local", "file://" + localRepository, new AssemblyRepositoryLayout() );
@@ -139,9 +154,20 @@
         throws MojoExecutionException
     {
         List<String> commands = new ArrayList<String>();
-        commands.add( "/f:target" + File.separator + project.getArtifactId() + "." +
-            ArtifactType.getArtifactTypeForPackagingName( project.getPackaging() ).getExtension() );
-        commands.add( "/o:target" + File.separator + "Output.xml" );
+
+        String targetPath = "target" + File.separator + project.getArtifactId() + "." +
+            ArtifactType.getArtifactTypeForPackagingName( project.getPackaging() ).getExtension();
+        String outputPath = "target" + File.separator + "Output.xml";
+
+        String relativePathToTargetFile =
+            ( rootDir != null ) ? new File( project.getBasedir(), targetPath ).getAbsolutePath().substring(
+                rootDir.getAbsolutePath().length() + 1 ) : targetPath;
+        String relativePathToOutputFile =
+            ( rootDir != null ) ? new File( project.getBasedir(), outputPath ).getAbsolutePath().substring(
+                rootDir.getAbsolutePath().length() + 1 ) : outputPath;
+
+        commands.add( "/f:" + relativePathToTargetFile );
+        commands.add( "/o:" + relativePathToOutputFile );
         return commands;
     }
 }