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/11 20:55:50 UTC

svn commit: r537287 - 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...

Author: sisbell
Date: Fri May 11 13:55:49 2007
New Revision: 537287

URL: http://svn.apache.org/viewvc?view=rev&rev=537287
Log:
The initializing of artifacthandlers is now done by initializing the artifactContext. This means that standalone plugins are no longer responsible for programatically setting up the artifact handlers.

Modified:
    incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactContext.java
    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/resources/META-INF/plexus/components.xml
    incubator/nmaven/branches/SI_XPT/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactContext.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactContext.java?view=diff&rev=537287&r1=537286&r2=537287
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactContext.java (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactContext.java Fri May 11 13:55:49 2007
@@ -19,6 +19,7 @@
 package org.apache.maven.dotnet.artifact;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.project.MavenProject;
 
@@ -119,16 +120,18 @@
      *
      * @param repository the local repository directory. If value is null, the localRepository reference will default to
      *                   the specified localRepository passed to the init method of the context.
-     * @return  list of .NET artifacts that reside within the specified repository.
+     * @return list of .NET artifacts that reside within the specified repository.
      */
     List<Artifact> getAllNetArtifactsFromRepository( File repository );
 
+ //   ArtifactHandler createArtifactHandler( String packagingType, String extension );
+
     /**
      * Initializes this artifact context. Neither parameter value should be null.
      *
-     * @param mavenProject    the maven project
+     * @param mavenProject               the maven project
      * @param remoteArtifactRepositories
-     * @param localRepository the file location of the local maven repository
+     * @param localRepository            the file location of the local maven repository
      * @throws NullPointerException if localRepository parameter is null
      */
     void init( MavenProject mavenProject, List<ArtifactRepository> remoteArtifactRepositories, File localRepository );

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=537287&r1=537286&r2=537287
==============================================================================
--- 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 Fri May 11 13:55:49 2007
@@ -26,6 +26,8 @@
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -91,6 +93,10 @@
      */
     private Logger logger;
 
+    private List<ArtifactHandler> artifactHandlers;
+
+    private ArtifactHandlerManager artifactHandlerManager;
+
     /**
      * Constructor. This method is intended to by invoked by the plexus-container, not by the application developer.
      */
@@ -264,7 +270,7 @@
     }
 
     /**
-     * @see ArtifactContext#init(org.apache.maven.project.MavenProject,java.util.List
+     * @see ArtifactContext#init(org.apache.maven.project.MavenProject,java.util.List, File
      */
     public void init( MavenProject mavenProject, List<ArtifactRepository> remoteArtifactRepositories,
                       File localRepository )
@@ -272,6 +278,24 @@
         this.project = mavenProject;
         this.localRepository = localRepository.getAbsolutePath();
         artifactInstaller.init( this, mavenProject, remoteArtifactRepositories, localRepository );
+        Map<String, ArtifactHandler> map = new HashMap<String, ArtifactHandler>();
+        for ( ArtifactHandler artifactHandler : artifactHandlers )
+        {
+            //If I add a handler that already exists, the runtime breaks.
+            if ( isDotNetHandler( artifactHandler ) )
+            {
+                map.put( artifactHandler.getPackaging(), artifactHandler );
+            }
+        }
+
+        artifactHandlerManager.addHandlers( map );
+    }
+
+    private boolean isDotNetHandler( ArtifactHandler artifactHandler )
+    {
+        String extension = artifactHandler.getExtension();
+        return extension.equals( "dll" ) || extension.equals( "nar" ) || extension.equals( "exe" ) ||
+            extension.equals( "exe.config" );
     }
 
     /**
@@ -291,5 +315,83 @@
             }
         }
         return true;
+    }
+
+    private class Handler
+        implements ArtifactHandler
+    {
+        private String extension, directory, classifier, packaging, language;
+
+        private boolean includesDependencies, addedToClasspath;
+
+        public void setExtension( String extension )
+        {
+            this.extension = extension;
+        }
+
+        public String getExtension()
+        {
+            return extension;
+        }
+
+        public void setDirectory( String directory )
+        {
+            this.directory = directory;
+        }
+
+        public String getDirectory()
+        {
+            return directory;
+        }
+
+        public void setClassifier( String classifier )
+        {
+            this.classifier = classifier;
+        }
+
+        public String getClassifier()
+        {
+            return classifier;
+        }
+
+        public void setPackaging( String packaging )
+        {
+            this.packaging = packaging;
+        }
+
+        public String getPackaging()
+        {
+            return packaging;
+        }
+
+        public void setIncludesDependencies( boolean includesDependencies )
+        {
+            this.includesDependencies = includesDependencies;
+        }
+
+        public boolean isIncludesDependencies()
+        {
+            return includesDependencies;
+        }
+
+        public void setLanguage( String language )
+        {
+            this.language = language;
+        }
+
+        public String getLanguage()
+        {
+            return language;
+        }
+
+        public void setAddedToClasspath( boolean addedToClasspath )
+        {
+            this.addedToClasspath = addedToClasspath;
+        }
+
+        public boolean isAddedToClasspath()
+        {
+            return addedToClasspath;
+        }
     }
 }

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=537287&r1=537286&r2=537287
==============================================================================
--- 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 Fri May 11 13:55:49 2007
@@ -1,6 +1,104 @@
 <component-set>
   <components>
     <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>module</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>netmodule</extension>
+        <type>module</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>exe.config</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>exe.config</extension>
+        <type>exe.config</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>library</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>library</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>winexe</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>exe</extension>
+        <type>winexe</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>gac</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>gac</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>gac_generic</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>gac_generic</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>gac_msil</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>gac_msil</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>gac_32</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>gac_32</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>nar</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>nar</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>netplugin</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>netplugin</type>
+      </configuration>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>visual-studio-addin</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <extension>dll</extension>
+        <type>visual-studio-addin</type>
+      </configuration>
+    </component>
+    <component>
       <role>org.apache.maven.dotnet.artifact.ArtifactContext</role>
       <implementation>org.apache.maven.dotnet.artifact.impl.ArtifactContextImpl</implementation>
       <requirements>
@@ -23,6 +121,13 @@
           <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
           <role-hint>net</role-hint>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+          <field-name>artifactHandlers</field-name>
+        </requirement>
       </requirements>
     </component>
     <component>
@@ -43,7 +148,7 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.dotnet.artifact.AssemblyResolver</role>
-        </requirement> 
+        </requirement>
         <requirement>
           <role>org.apache.maven.dotnet.registry.RepositoryRegistry</role>
         </requirement>

Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java?view=diff&rev=537287&r1=537286&r2=537287
==============================================================================
--- incubator/nmaven/branches/SI_XPT/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java (original)
+++ incubator/nmaven/branches/SI_XPT/plugins/maven-vsinstaller-plugin/src/main/java/org/apache/maven/dotnet/plugin/vsinstaller/VsInstallerMojo.java Fri May 11 13:55:49 2007
@@ -69,11 +69,6 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        Map handlers = new HashMap();
-        handlers.put( "library", createArtifactHandler( "library", "dll" ) );
-        handlers.put( "netplugin", createArtifactHandler( "netplugin", "dll" ) );
-        handlers.put( "visual-studio-addin", createArtifactHandler( "visual-studio-addin", "dll" ) );
-        artifactHandlerManager.addHandlers( handlers );
         ArtifactRepository remoteArtifactRepository = new DefaultArtifactRepository( "nmaven",
                                                                                      "http://localhost:8080/repository",
                                                                                      new DefaultRepositoryLayout() );