Author: brett
Date: Thu Aug 11 14:09:28 2011
New Revision: 1156622

URL: http://svn.apache.org/viewvc?rev=1156622&view=rev
Log:
[NPANDAY-459] Don't traverse project references when building with MSBuild, and 
ensure that the project's artifacts are in place where MSBuild would expect to 
find them

Modified:
    
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java
    
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/src/main/csharp/NPanday/Plugin/Msbuild/MsbuildMojo.cs

Modified: 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java?rev=1156622&r1=1156621&r2=1156622&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java
 (original)
+++ 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java
 Thu Aug 11 14:09:28 2011
@@ -21,12 +21,17 @@ package NPanday.Plugin.Msbuild;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import npanday.plugin.FieldAnnotation;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -55,6 +60,11 @@ public class MsbuildMojo
     private org.apache.maven.project.MavenProject project;
 
     /**
+     * @parameter expression = "${reactorProjects}"
+     */
+    private List<org.apache.maven.project.MavenProject> reactorProjects;
+
+    /**
      * @parameter expression = "${settings.localRepository}"
      */
     private String localRepository;
@@ -150,15 +160,36 @@ public class MsbuildMojo
     {
         if ( copyReferences )
         {
+            Map<String,MavenProject> projects = new 
HashMap<String,MavenProject>();
+            for ( MavenProject p : reactorProjects )
+            {
+                projects.put( ArtifactUtils.versionlessKey( p.getGroupId(), 
p.getArtifactId() ), p );
+            }
+            getLog().info( "projects = " + projects.keySet() );
+
             for ( Object artifact : project.getDependencyArtifacts() )
             {
                 Artifact a = (Artifact) artifact;
 
-                String path =
-                    a.getGroupId() + "/" + a.getArtifactId() + "-" + 
a.getBaseVersion() + "/" + a.getArtifactId() + "." +
-                        a.getArtifactHandler().getExtension();
-                File targetFile = new File( referencesDirectory, path );
-
+                File targetDir;
+                String vKey = ArtifactUtils.versionlessKey( a );
+                if ( !projects.containsKey( vKey ) )
+                {
+                    String path =
+                        a.getGroupId() + "/" + a.getArtifactId() + "-" + 
a.getBaseVersion();
+                    targetDir = new File( referencesDirectory, path );
+                }
+                else
+                {
+                    // Likely a project reference in MSBuild. 
+                    // If the other project was not built with MSBuild, make 
sure the artifact is present where it will look for it
+                    // Note: deliberately limited for now - will only work 
with reactor projects and doesn't test what are references and what are not
+                    // TODO: support other configurations, or more aligned 
MSBuild-based builds
+                    targetDir = new File( projects.get( vKey ).getBasedir(), 
"bin/Debug" );
+                }
+                File targetFile = new File( targetDir, a.getArtifactId() + "." 
+ a.getArtifactHandler().getExtension() );
+    
+                getLog().info( "Copying reference " + vKey + " to " + 
targetFile );
                 if ( !targetFile.exists() )
                 {
                     targetFile.getParentFile().mkdirs();

Modified: 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/src/main/csharp/NPanday/Plugin/Msbuild/MsbuildMojo.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/src/main/csharp/NPanday/Plugin/Msbuild/MsbuildMojo.cs?rev=1156622&r1=1156621&r2=1156622&view=diff
==============================================================================
--- 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/src/main/csharp/NPanday/Plugin/Msbuild/MsbuildMojo.cs
 (original)
+++ 
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/src/main/csharp/NPanday/Plugin/Msbuild/MsbuildMojo.cs
 Thu Aug 11 14:09:28 2011
@@ -75,8 +75,9 @@ namespace NPanday.Plugin.Msbuild
             }
             // must use /v:q here, as /v:m and above report the csc command, 
that includes '/errorprompt', which
             // erroneously triggers the NPANDAY-063-001 error
+            // BuildingInsideVisualStudio is required to avoid building 
project references on framework 2.0
             ProcessStartInfo processStartInfo =
-               new ProcessStartInfo("msbuild", "/v:q " + projectName);
+               new ProcessStartInfo("msbuild", "/v:q 
/p:BuildProjectReferences=false /p:BuildingInsideVisualStudio=true " + 
projectName);
             processStartInfo.UseShellExecute = false;
             Process p = System.Diagnostics.Process.Start(processStartInfo);
             p.WaitForExit();


Reply via email to