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/04/24 18:17:57 UTC

svn commit: r532033 - in /incubator/nmaven/branches/SI_XPT: components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ components/dotnet-core/src/main/resources/META-INF/nmaven/ components/dotnet-executable/src/main/java/org/apache...

Author: sisbell
Date: Tue Apr 24 11:17:55 2007
New Revision: 532033

URL: http://svn.apache.org/viewvc?view=rev&rev=532033
Log:
Support for automatically installing net dependencies into the GAC. This is needed since NMaven uses a custom DomainAppManager that can only be run by a signed assembly within the cache.

Modified:
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
    incubator/nmaven/branches/SI_XPT/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/NetExecutableFactoryImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-model/netdependency/netdependency.mdo
    incubator/nmaven/branches/SI_XPT/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ComponentInitializerMojo.java
    incubator/nmaven/branches/SI_XPT/plugins/maven-install-plugin/src/main/java/org/apache/maven/dotnet/plugin/install/InstallerMojo.java
    incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependency.java
    incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java Tue Apr 24 11:17:55 2007
@@ -129,7 +129,13 @@
             return new ArrayList<Artifact>();
         }
         repository.init( artifactFactory );
-        return repository.getArtifactsFor( groupId, artifactId, version, type );
+        List<Artifact> artifacts = repository.getArtifactsFor( groupId, artifactId, version, type );
+        AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout();
+        for(Artifact artifact : artifacts)
+        {
+            artifact.setFile(new File( localRepository + File.separator + layout.pathOf( artifact ) ) );
+        }
+        return artifacts;
     }
 
     /**

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java Tue Apr 24 11:17:55 2007
@@ -146,6 +146,5 @@
             resolvedDependencies.addAll( gacDependencies );
             project.setDependencyArtifacts( resolvedDependencies );
         }
-
     }
 }

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java Tue Apr 24 11:17:55 2007
@@ -39,7 +39,6 @@
 import java.io.Reader;
 import java.io.InputStreamReader;
 
-
 /**
  * Provides methods for loading and reading the net dependency config file.
  *

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml Tue Apr 24 11:17:55 2007
@@ -32,6 +32,14 @@
     <artifactId>NMaven.Plugin</artifactId>
     <version>0.14</version>
     <type>library</type>
+    <isGacInstall>true</isGacInstall>
+  </netDependency>
+  <netDependency>
+    <groupId>NMaven.Model</groupId>
+    <artifactId>NMaven.Model.Pom</artifactId>
+    <version>0.14</version>
+    <type>library</type>
+    <isGacInstall>true</isGacInstall>
   </netDependency>
   <netDependency>
     <groupId>NMaven.Plugin</groupId>

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/NetExecutableFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/NetExecutableFactoryImpl.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/NetExecutableFactoryImpl.java (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/NetExecutableFactoryImpl.java Tue Apr 24 11:17:55 2007
@@ -191,12 +191,12 @@
                 "NMAVEN-066-021: Could not locate the plugin: GroupId = " + groupId + ", ArtifactId = " + artifactId );
         }
 
-        AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout();
-        File artifactPath = new File( localRepository + File.separator + layout.pathOf( artifact ) );
+      //  AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout();
+        //File artifactPath = new File( localRepository + File.separator + layout.pathOf( artifact ) );
         List<String> commands = new ArrayList<String>();
         //commands.add( "mojoName=NMaven.Plugin.Solution" );
         commands.add( "parameterFile=" + parameterFile.getAbsolutePath() );
-        commands.add( "assemblyFile=" + artifactPath.getAbsolutePath() );
+        commands.add( "assemblyFile=" + artifact.getFile().getAbsolutePath() );
         commands.add( "mojoName=" + artifactId + "." + mojoName );//ArtifactId = namespace
         return getNetExecutableFromRepository( "NMaven.Plugin", "NMaven.Plugin.Runner", vendorInfo, project,
                                                localRepository, commands );

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-model/netdependency/netdependency.mdo
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-model/netdependency/netdependency.mdo?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-model/netdependency/netdependency.mdo (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-model/netdependency/netdependency.mdo Tue Apr 24 11:17:55 2007
@@ -62,6 +62,12 @@
           <type>String</type>
           <description></description>
         </field>
+        <field>
+          <name>isGacInstall</name>
+          <version>1.0.0</version>
+          <type>boolean</type>
+          <description>True if the framework should install the net dependency in the GAC, otherwise false.</description>
+        </field>
       </fields>
     </class>
   </classes>

Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ComponentInitializerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ComponentInitializerMojo.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ComponentInitializerMojo.java (original)
+++ incubator/nmaven/branches/SI_XPT/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/ComponentInitializerMojo.java Tue Apr 24 11:17:55 2007
@@ -82,12 +82,9 @@
      */
     private AssemblerContext assemblerContext;
 
-    public static long sT;
-
     public void execute()
         throws MojoExecutionException
     {
-        sT = System.currentTimeMillis();
         long startTime = System.currentTimeMillis();
 
         if(localRepository == null)

Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-install-plugin/src/main/java/org/apache/maven/dotnet/plugin/install/InstallerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-install-plugin/src/main/java/org/apache/maven/dotnet/plugin/install/InstallerMojo.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/plugins/maven-install-plugin/src/main/java/org/apache/maven/dotnet/plugin/install/InstallerMojo.java (original)
+++ incubator/nmaven/branches/SI_XPT/plugins/maven-install-plugin/src/main/java/org/apache/maven/dotnet/plugin/install/InstallerMojo.java Tue Apr 24 11:17:55 2007
@@ -106,7 +106,6 @@
         }
         long endTime = System.currentTimeMillis();
         getLog().info( "Mojo Execution Time = " + ( endTime - startTime ) );
-        getLog().info( "Total Time = " + ( endTime - ComponentInitializerMojo.sT ) );
         //For the IDE: If we see a dll with same name as netmodule, copy dll to the local repo.
         /*
         File linkedFile =

Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependency.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependency.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependency.java (original)
+++ incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependency.java Tue Apr 24 11:17:55 2007
@@ -18,6 +18,11 @@
  */
 package org.apache.maven.dotnet.plugin.resolver;
 
+/**
+ * Provides access to net dependency information.
+ *
+ * @author Shane Isbell
+ */
 public class NetDependency
 {
 
@@ -28,6 +33,18 @@
     private String groupId;
 
     private String type;
+
+    private  boolean isGacInstall;
+
+    public boolean isGacInstall()
+    {
+        return isGacInstall;
+    }
+
+    public void setGacInstall( boolean gacInstall )
+    {
+        isGacInstall = gacInstall;
+    }
 
     public String getVersion()
     {

Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java?view=diff&rev=532033&r1=532032&r2=532033
==============================================================================
--- incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java (original)
+++ incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java Tue Apr 24 11:17:55 2007
@@ -23,6 +23,7 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -32,11 +33,16 @@
 import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import org.apache.maven.dotnet.artifact.AssemblyResolver;
 import org.apache.maven.dotnet.artifact.NetDependenciesRepository;
 import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy;
+import org.apache.maven.dotnet.artifact.ArtifactContext;
 import org.apache.maven.dotnet.model.netdependency.NetDependency;
+import org.apache.maven.dotnet.executable.NetExecutable;
+import org.apache.maven.dotnet.executable.ExecutionException;
+import org.apache.maven.dotnet.PlatformUnsupportedException;
 
 /**
  * @author Shane Isbell
@@ -72,6 +78,18 @@
     private NetDependency[] netDependencies;
 
     /**
+     * The Vendor for the executable.
+     *
+     * @parameter expression="${vendor}"
+     */
+    private String vendor;
+
+    /**
+     * @parameter expression = "${frameworkVersion}"
+     */
+    private String frameworkVersion;
+
+    /**
      * @component
      */
     private AssemblyResolver assemblyResolver;
@@ -86,11 +104,21 @@
      */
     private org.apache.maven.dotnet.NMavenRepositoryRegistry nmavenRegistry;
 
+    /**
+     * @component
+     */
+    private org.apache.maven.dotnet.executable.NetExecutableFactory netExecutableFactory;
+
+    /**
+     * @component
+     */
+    private ArtifactContext artifactContext;
+
     public void execute()
         throws MojoExecutionException
     {
         long startTime = System.currentTimeMillis();
-        
+
         if ( System.getProperty( "bootstrap" ) != null )
         {
             return;
@@ -132,11 +160,11 @@
         dependencies.addAll( repository.getDependenciesFor( matchPolicies ) );
         getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + dependencies.size() );
 
-        if(localRepository == null)
+        if ( localRepository == null )
         {
-            localRepository = new File(System.getProperty("user.home"), ".m2/repository").getAbsolutePath();
+            localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" ).getAbsolutePath();
         }
-        
+
         try
         {
             assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), dependencies, pomFile,
@@ -150,8 +178,70 @@
         {
             throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies", e );
         }
+
+        //Do GAC Install, if needed
+        //TODO: Add in the dependencies from the MOJO config
+        artifactContext.init( project, new File( localRepository ) );
+        List<NetDependencyMatchPolicy> gacInstallPolicies = new ArrayList<NetDependencyMatchPolicy>();
+        gacInstallPolicies.add( new GacMatchPolicy( true ) );
+        List<Dependency> gacInstallDependencies = repository.getDependenciesFor( gacInstallPolicies );
+        for ( Dependency dependency : gacInstallDependencies )
+        {
+            System.out.println( dependency.getArtifactId() );
+            List<Artifact> artifacts = artifactContext.getArtifactsFor( dependency.getGroupId(),
+                                                                        dependency.getArtifactId(),
+                                                                        dependency.getVersion(), dependency.getType() );
+            try
+            {
+                NetExecutable netExecutable = netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion,
+                                                                                        "GACUTIL", project,
+                                                                                        getGacInstallCommandsFor(
+                                                                                            artifacts.get( 0) ), null );
+                netExecutable.execute();
+                getLog().info( "NMAVEN-1600-004: Installed Assembly into GAC: Assembly = " +
+                    project.getArtifact().getFile() + ",  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 );
+            }
+        }
+
         long endTime = System.currentTimeMillis();
-        getLog().info( "Mojo Execution Time = " + (endTime - startTime));
+        getLog().info( "Mojo Execution Time = " + ( endTime - startTime ) );
+    }
+
+    public List<String> getGacInstallCommandsFor( Artifact artifact )
+        throws MojoExecutionException
+    {
+        List<String> commands = new ArrayList<String>();
+        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;
+        }
     }
 
     private class ProfileMatchPolicy