Author: sisbell
Date: Fri May 25 23:27:31 2007
New Revision: 541863

URL: http://svn.apache.org/viewvc?view=rev&rev=541863
Log:
The vsinstaller installs required assemblies into the GAC during resolution.

Removed:
    incubator/nmaven/trunk/assemblies/NMaven.Plugin/sample-public.snk
Modified:
    incubator/nmaven/trunk/assemblies/NMaven.Plugin/pom.xml
    
incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
    
incubator/nmaven/trunk/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
    
incubator/nmaven/trunk/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java
    
incubator/nmaven/trunk/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java

Modified: incubator/nmaven/trunk/assemblies/NMaven.Plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/trunk/assemblies/NMaven.Plugin/pom.xml?view=diff&rev=541863&r1=541862&r2=541863
==============================================================================
--- incubator/nmaven/trunk/assemblies/NMaven.Plugin/pom.xml (original)
+++ incubator/nmaven/trunk/assemblies/NMaven.Plugin/pom.xml Fri May 25 23:27:31 
2007
@@ -56,26 +56,4 @@
       </plugin>      
     </plugins>
   </build>
-  <profiles>
-    <profile>
-      <activation>
-        <property>
-          <name>version</name>
-          <value>1.1</value>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.dotnet.plugins</groupId>
-            <artifactId>maven-compile-plugin</artifactId>
-            <extensions>true</extensions>
-            <configuration>
-              <frameworkVersion>1.1.4322</frameworkVersion>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
 </project>

Modified: 
incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java?view=diff&rev=541863&r1=541862&r2=541863
==============================================================================
--- 
incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
 (original)
+++ 
incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
 Fri May 25 23:27:31 2007
@@ -455,7 +455,13 @@
         try
         {
             result = resolver.resolveTransitively( artifactDependencies, 
sourceArtifact, localArtifactRepository,
-                                                   remoteArtifactRepositories, 
metadata, new GacFilter() );
+                                                   remoteArtifactRepositories, 
metadata, new ArtifactFilter()
+            {
+                public boolean include( org.apache.maven.artifact.Artifact 
artifact )
+                {
+                    return !artifact.getType().startsWith( "gac" );
+                }
+            } );
         }
         catch ( ArtifactResolutionException e )
         {
@@ -675,15 +681,6 @@
             }
 
             return profile.equals( netDependency.getProfile() );
-        }
-    }
-
-    private static class GacFilter
-        implements ArtifactFilter
-    {
-        public boolean include( org.apache.maven.artifact.Artifact artifact )
-        {
-            return !artifact.getType().startsWith( "gac" );
         }
     }
 }

Modified: 
incubator/nmaven/trunk/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml?view=diff&rev=541863&r1=541862&r2=541863
==============================================================================
--- 
incubator/nmaven/trunk/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
 (original)
+++ 
incubator/nmaven/trunk/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
 Fri May 25 23:27:31 2007
@@ -53,12 +53,14 @@
     <artifactId>NMaven.Plugin</artifactId>
     <version>0.14-SNAPSHOT</version>
     <type>library</type>
+    <isGacInstall>true</isGacInstall>    
   </netDependency>
   <netDependency>
     <groupId>NMaven.Model</groupId>
     <artifactId>NMaven.Model.Pom</artifactId>
     <version>0.14-SNAPSHOT</version>
     <type>library</type>
+    <isGacInstall>true</isGacInstall>
   </netDependency>
   <netDependency>
     <groupId>NMaven.Plugin</groupId>

Modified: 
incubator/nmaven/trunk/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java?view=diff&rev=541863&r1=541862&r2=541863
==============================================================================
--- 
incubator/nmaven/trunk/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java
 (original)
+++ 
incubator/nmaven/trunk/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java
 Fri May 25 23:27:31 2007
@@ -89,6 +89,11 @@
     private String frameworkVersion;
 
     /**
+     * @parameter expression = "${installGacDependencies}" 
default-value="false"
+     */
+    private boolean isGacInstall;
+
+    /**
      * @component
      */
     private AssemblyResolver assemblyResolver;
@@ -178,39 +183,43 @@
 
         //Do GAC Install, if needed
         //TODO: Add in the dependencies from the MOJO config
-        NetDependenciesRepository repository =
-            (NetDependenciesRepository) repositoryRegistry.find( 
"net-dependencies" );
-        getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + 
dependencies.size() );
-
-        List<NetDependencyMatchPolicy> gacInstallPolicies = new 
ArrayList<NetDependencyMatchPolicy>();
-        gacInstallPolicies.add( new GacMatchPolicy( true ) );
-        List<Dependency> gacInstallDependencies = 
repository.getDependenciesFor( gacInstallPolicies );
-        for ( Dependency dependency : gacInstallDependencies )
-        {
-            List<Artifact> artifacts = artifactContext.getArtifactsFor( 
dependency.getGroupId(),
-                                                                        
dependency.getArtifactId(),
-                                                                        
dependency.getVersion(), dependency.getType() );
-            try
-            {
-                NetExecutable netExecutable = 
netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion,
-                                                                               
         "GACUTIL",
-                                                                               
         getGacInstallCommandsFor(
-                                                                               
             artifacts.get( 0 ) ),
-                                                                               
         null );
-                netExecutable.execute();
-                getLog().info( "NMAVEN-1600-004: Installed Assembly into GAC: 
Assembly = " +
-                    artifacts.get( 0 ).getFile().getAbsolutePath() + ",  
Vendor = " +
-                    netExecutable.getVendor().getVendorName() );
-            }
-            catch ( ExecutionException e )
-            {
-                throw new MojoExecutionException( "NMAVEN-1600-005: Unable to 
execute gacutil: Vendor " + vendor +
-                    ", frameworkVersion = " + frameworkVersion + ", Profile = 
" + profile, e );
-            }
-            catch ( PlatformUnsupportedException e )
+        if ( isGacInstall )
+        {
+            NetDependenciesRepository repository =
+                (NetDependenciesRepository) repositoryRegistry.find( 
"net-dependencies" );
+            getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = 
" + dependencies.size() );
+
+            List<NetDependencyMatchPolicy> gacInstallPolicies = new 
ArrayList<NetDependencyMatchPolicy>();
+            gacInstallPolicies.add( new GacMatchPolicy( true ) );
+            List<Dependency> gacInstallDependencies = 
repository.getDependenciesFor( gacInstallPolicies );
+            for ( Dependency dependency : gacInstallDependencies )
             {
-                throw new MojoExecutionException( "NMAVEN-1600-006: Platform 
Unsupported: Vendor " + vendor +
-                    ", frameworkVersion = " + frameworkVersion + ", Profile = 
" + profile, e );
+                List<Artifact> artifacts = artifactContext.getArtifactsFor( 
dependency.getGroupId(),
+                                                                            
dependency.getArtifactId(),
+                                                                            
dependency.getVersion(),
+                                                                            
dependency.getType() );
+                try
+                {
+                    NetExecutable netExecutable = 
netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion,
+                                                                               
             "GACUTIL",
+                                                                               
             getGacInstallCommandsFor(
+                                                                               
                 artifacts.get( 0 ) ),
+                                                                               
             null );
+                    netExecutable.execute();
+                    getLog().info( "NMAVEN-1600-004: Installed Assembly into 
GAC: Assembly = " +
+                        artifacts.get( 0 ).getFile().getAbsolutePath() + ",  
Vendor = " +
+                        netExecutable.getVendor().getVendorName() );
+                }
+                catch ( ExecutionException e )
+                {
+                    throw new MojoExecutionException( "NMAVEN-1600-005: Unable 
to execute gacutil: Vendor " + vendor +
+                        ", frameworkVersion = " + frameworkVersion + ", 
Profile = " + profile, e );
+                }
+                catch ( PlatformUnsupportedException e )
+                {
+                    throw new MojoExecutionException( "NMAVEN-1600-006: 
Platform Unsupported: Vendor " + vendor +
+                        ", frameworkVersion = " + frameworkVersion + ", 
Profile = " + profile, e );
+                }
             }
         }
 

Modified: 
incubator/nmaven/trunk/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java?view=diff&rev=541863&r1=541862&r2=541863
==============================================================================
--- 
incubator/nmaven/trunk/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java
 (original)
+++ 
incubator/nmaven/trunk/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java
 Fri May 25 23:27:31 2007
@@ -11,7 +11,16 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.dotnet.artifact.ArtifactContext;
+import org.apache.maven.dotnet.artifact.NetDependenciesRepository;
+import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy;
+import org.apache.maven.dotnet.executable.NetExecutable;
+import org.apache.maven.dotnet.executable.ExecutionException;
+import org.apache.maven.dotnet.PlatformUnsupportedException;
+import org.apache.maven.dotnet.registry.RepositoryRegistry;
+import org.apache.maven.dotnet.vendor.Vendor;
+import org.apache.maven.dotnet.model.netdependency.NetDependency;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.IOUtil;
 
@@ -55,9 +64,31 @@
      */
     private ArtifactHandlerManager artifactHandlerManager;
 
+    /**
+     * @component
+     */
+    private org.apache.maven.dotnet.NMavenRepositoryRegistry nmavenRegistry;
+
+    /**
+     * @component
+     */
+    private org.apache.maven.dotnet.executable.NetExecutableFactory 
netExecutableFactory;
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+
+        RepositoryRegistry repositoryRegistry;
+        try
+        {
+            repositoryRegistry = nmavenRegistry.createRepositoryRegistry();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException(
+                "NMAVEN-1600-000: Failed to create the repository registry for 
this plugin", e );
+        }
+
         ArtifactRepository remoteArtifactRepository = new 
DefaultArtifactRepository( "nmaven",
                                                                                
      "http://localhost:8080/repository";,
                                                                                
      new DefaultRepositoryLayout() );
@@ -83,11 +114,43 @@
             throw new MojoExecutionException( "NMAVEN-1600-005: Unable to 
resolve assemblies", e );
         }
 
+        //GAC Installs
+        NetDependenciesRepository repository =
+            (NetDependenciesRepository) repositoryRegistry.find( 
"net-dependencies" );
+
+        List<NetDependencyMatchPolicy> gacInstallPolicies = new 
ArrayList<NetDependencyMatchPolicy>();
+        gacInstallPolicies.add( new GacMatchPolicy( true ) );
+        List<Dependency> gacInstallDependencies = 
repository.getDependenciesFor( gacInstallPolicies );
+        for ( Dependency dependency : gacInstallDependencies )
+        {
+            List<Artifact> artifacts = artifactContext.getArtifactsFor( 
dependency.getGroupId(),
+                                                                        
dependency.getArtifactId(),
+                                                                        
dependency.getVersion(), dependency.getType() );
+            try
+            {
+                NetExecutable netExecutable = 
netExecutableFactory.getNetExecutableFor(
+                    Vendor.MICROSOFT.getVendorName(), "2.0.50727", "GACUTIL",
+                    getGacInstallCommandsFor( artifacts.get( 0 ) ), null );
+                netExecutable.execute();
+                getLog().info( "NMAVEN-1600-004: Installed Assembly into GAC: 
Assembly = " +
+                    artifacts.get( 0 ).getFile().getAbsolutePath() + ",  
Vendor = " +
+                    netExecutable.getVendor().getVendorName() );
+            }
+            catch ( ExecutionException e )
+            {
+                throw new MojoExecutionException( "NMAVEN-1600-005: Unable to 
execute gacutil:", e );
+            }
+            catch ( PlatformUnsupportedException e )
+            {
+                throw new MojoExecutionException( "NMAVEN-1600-006: Platform 
Unsupported:", e );
+            }
+        }
+
         OutputStreamWriter writer = null;
         try
         {
             String addin =
-                IOUtil.toString( VsInstallerMojo.class.getResourceAsStream( 
"/template/NMaven.VisualStudio.AddIn" ));
+                IOUtil.toString( VsInstallerMojo.class.getResourceAsStream( 
"/template/NMaven.VisualStudio.AddIn" ) );
             File outputFile = new File( System.getProperty( "user.home" ) +
                 "\\My Documents\\Visual Studio 
2005\\Addins\\NMaven.VisualStudio.AddIn" );
 
@@ -118,6 +181,32 @@
                 e.printStackTrace();
             }
         }
+    }
+
+    public List<String> getGacInstallCommandsFor( Artifact artifact )
+        throws MojoExecutionException
+    {
+        List<String> commands = new ArrayList<String>();
+        commands.add( "/nologo" );
+        commands.add( "/i" );
+        commands.add( artifact.getFile().getAbsolutePath() );
+        return commands;
+    }
 
+    private class GacMatchPolicy
+        implements NetDependencyMatchPolicy
+    {
+
+        private boolean isGacInstall;
+
+        public GacMatchPolicy( boolean isGacInstall )
+        {
+            this.isGacInstall = isGacInstall;
+        }
+
+        public boolean match( NetDependency netDependency )
+        {
+            return netDependency.isIsGacInstall() == isGacInstall;
+        }
     }
 }


Reply via email to