incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r536766 - in /incubator/nmaven/branches/SI_XPT: components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ components/dotnet-artifact/src/main/r...
Date Thu, 10 May 2007 07:40:22 GMT
Author: sisbell
Date: Thu May 10 00:40:21 2007
New Revision: 536766

URL: http://svn.apache.org/viewvc?view=rev&rev=536766
Log:
Moved out some of the resolving and installing code from the Mojo into the components. I need
to reuse it for the visual studio install plugin.

Modified:
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml
    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/ArtifactInstaller.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java?view=diff&rev=536766&r1=536765&r2=536766
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java
Thu May 10 00:40:21 2007
@@ -20,6 +20,7 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.installer.ArtifactInstallationException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.model.Dependency;
@@ -101,12 +102,14 @@
      * netplugins.
      *
      * @param dependency the dependency to resolve
-     * @param pomFile
      * @throws ArtifactInstallationException
      * @throws ArtifactNotFoundException
      */
-    void resolveAndInstallLibraryDependenciesFor( Dependency dependency, File pomFile )
+    void resolveAndInstallLibraryDependenciesFor( Dependency dependency )
         throws ArtifactInstallationException , ArtifactNotFoundException;
+
+    void resolveAndInstallNetDependenciesForProfile( String profile, List<Dependency>
dependencies )
+        throws ArtifactResolutionException, ArtifactNotFoundException, ArtifactInstallationException;
   
 
     /**
      * Copies .netmodules, that the project is dependenct upon, from the local repo to the
project's target directory.

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java?view=diff&rev=536766&r1=536765&r2=536766
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
Thu May 10 00:40:21 2007
@@ -23,6 +23,11 @@
 import org.apache.maven.dotnet.artifact.AssemblyRepositoryLayout;
 import org.apache.maven.dotnet.artifact.ApplicationConfig;
 import org.apache.maven.dotnet.artifact.ArtifactType;
+import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy;
+import org.apache.maven.dotnet.artifact.NetDependenciesRepository;
+import org.apache.maven.dotnet.artifact.AssemblyResolver;
+import org.apache.maven.dotnet.registry.RepositoryRegistry;
+import org.apache.maven.dotnet.model.netdependency.NetDependency;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -118,6 +123,10 @@
      */
     private ArtifactFactory artifactFactory;
 
+    private AssemblyResolver assemblyResolver;
+
+    private RepositoryRegistry repositoryRegistry;
+
     /**
      * Constructor. This method is intended to by invoked by the plexus-container, not by
the application developer.
      */
@@ -132,6 +141,33 @@
     {
         this.logger = logger;
     }
+    
+    public void resolveAndInstallNetDependenciesForProfile( String profile, List<Dependency>
dependencies )
+        throws ArtifactResolutionException, ArtifactNotFoundException, ArtifactInstallationException
+    {
+        if ( dependencies == null )
+        {
+            dependencies = new ArrayList<Dependency>();
+        }
+
+        NetDependenciesRepository repository =
+            (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" );
+        List<NetDependencyMatchPolicy> matchPolicies = new ArrayList<NetDependencyMatchPolicy>();
+        matchPolicies.add( new ProfileMatchPolicy( profile ) );
+        dependencies.addAll( repository.getDependenciesFor( matchPolicies ) );
+
+        assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), dependencies,
project.getFile(),
+                                                 localRepository.getAbsolutePath(), false
);
+
+        //Do Library Installs for Net Dependencies
+        matchPolicies = new ArrayList<NetDependencyMatchPolicy>();
+        matchPolicies.add( new ProfileMatchPolicy( profile ) );
+        matchPolicies.add( new ExecutableAndNetPluginMatchPolicy() );
+        for ( Dependency dependency : repository.getDependenciesFor( matchPolicies ) )
+        {
+            resolveAndInstallLibraryDependenciesFor( dependency );
+        }
+    }
 
     /**
      * @see org.apache.maven.dotnet.artifact.ArtifactInstaller#installArtifact(org.apache.maven.artifact.Artifact,
java.io.File)
@@ -336,7 +372,7 @@
         }
     }
 
-    public void resolveAndInstallLibraryDependenciesFor( Dependency dependency, File pomFile
)
+    public void resolveAndInstallLibraryDependenciesFor( Dependency dependency )
         throws ArtifactInstallationException, ArtifactNotFoundException
     {
         Artifact sourceArtifact = artifactFactory.createBuildArtifact( dependency.getGroupId(),
@@ -592,5 +628,43 @@
         new MavenXpp3Writer().write( fileWriter, model );
         IOUtil.close( fileWriter );
         return new ArtifactMetadataImpl( artifact, tempFile );
+    }
+
+    private class ExecutableAndNetPluginMatchPolicy
+        implements NetDependencyMatchPolicy
+    {
+        public boolean match( NetDependency netDependency )
+        {
+            return netDependency.getType().equals( ArtifactType.EXE.getPackagingType() )
||
+                netDependency.getType().equals( ArtifactType.NETPLUGIN.getPackagingType()
);
+        }
+    }
+
+    private class ProfileMatchPolicy
+        implements NetDependencyMatchPolicy
+    {
+
+        private String profile;
+
+        public ProfileMatchPolicy( String profile )
+        {
+            this.profile = profile;
+        }
+
+        public boolean match( NetDependency netDependency )
+        {
+            //If no profile is specified in net-dependencies.xml, it matches
+            if ( netDependency.getProfile() == null || netDependency.getProfile().trim().equals(
"" ) )
+            {
+                return true;
+            }
+
+            if ( profile == null )
+            {
+                return false;
+            }
+
+            return profile.equals( netDependency.getProfile() );
+        }
     }
 }

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=536766&r1=536765&r2=536766
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml
Thu May 10 00:40:21 2007
@@ -40,7 +40,13 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
-        </requirement>        
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.dotnet.artifact.AssemblyResolver</role>
+        </requirement> 
+        <requirement>
+          <role>org.apache.maven.dotnet.registry.RepositoryRegistry</role>
+        </requirement>
       </requirements>
     </component>
     <component>

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=536766&r1=536765&r2=536766
==============================================================================
--- 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
Thu May 10 00:40:21 2007
@@ -153,58 +153,31 @@
             dependencies.add( dependency );
         }
 
-        NetDependenciesRepository repository =
-            (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" );
-        List<NetDependencyMatchPolicy> matchPolicies = new ArrayList<NetDependencyMatchPolicy>();
-        matchPolicies.add( new ProfileMatchPolicy( profile ) );
-        dependencies.addAll( repository.getDependenciesFor( matchPolicies ) );
-        getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + dependencies.size()
);
-
-        if ( localRepository == null )
-        {
-            localRepository = new File( System.getProperty( "user.home" ), ".m2/repository"
).getAbsolutePath();
-        }
-
+        artifactContext.init( project, new File( localRepository ) );
         try
         {
-            assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), dependencies,
pomFile,
-                                                     localRepository, false );
+            artifactContext.getArtifactInstaller().resolveAndInstallNetDependenciesForProfile(
profile,
+                                                                                        
      new ArrayList<Dependency>() );
         }
         catch ( ArtifactResolutionException e )
         {
-            throw new MojoExecutionException( "NMAVEN-1600-002: Unable to resolve assemblies",
e );
+            throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies",
e );
         }
         catch ( ArtifactNotFoundException e )
         {
             throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies",
e );
         }
-
-        //Do Library Installs for Net Dependencies
-        artifactContext.init( project, new File( localRepository ) );
-        matchPolicies = new ArrayList<NetDependencyMatchPolicy>();
-        matchPolicies.add( new ProfileMatchPolicy( profile ) );
-        matchPolicies.add( new ExecutableAndNetPluginMatchPolicy() );
-        for ( Dependency dependency : repository.getDependenciesFor( matchPolicies ) )
+        catch ( ArtifactInstallationException e )
         {
-            
-            try
-            {
-                artifactContext.getArtifactInstaller().resolveAndInstallLibraryDependenciesFor(
dependency, pomFile );
-
-            }
-            catch ( ArtifactNotFoundException e )
-            {
-               throw new MojoExecutionException( "", e );
-            }
-            catch ( ArtifactInstallationException e )
-            {
-                throw new MojoExecutionException( "", e );
-            }
+            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 ) );
+        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
);
@@ -265,44 +238,6 @@
         public boolean match( NetDependency netDependency )
         {
             return netDependency.isIsGacInstall() == isGacInstall;
-        }
-    }
-
-    private class ExecutableAndNetPluginMatchPolicy
-        implements NetDependencyMatchPolicy
-    {
-        public boolean match( NetDependency netDependency )
-        {
-            return netDependency.getType().equals( ArtifactType.EXE.getPackagingType() )
||
-                netDependency.getType().equals( ArtifactType.NETPLUGIN.getPackagingType()
);
-        }
-    }
-
-    private class ProfileMatchPolicy
-        implements NetDependencyMatchPolicy
-    {
-
-        private String profile;
-
-        public ProfileMatchPolicy( String profile )
-        {
-            this.profile = profile;
-        }
-
-        public boolean match( NetDependency netDependency )
-        {
-            //If no profile is specified in net-dependencies.xml, it matches
-            if ( netDependency.getProfile() == null || netDependency.getProfile().trim().equals(
"" ) )
-            {
-                return true;
-            }
-
-            if ( profile == null )
-            {
-                return false;
-            }
-
-            return profile.equals( netDependency.getProfile() );
         }
     }
 }



Mime
View raw message