You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/14 05:32:55 UTC

svn commit: r320986 - in /maven/components/trunk: maven-artifact/src/main/java/org/apache/maven/artifact/handler/ maven-artifact/src/main/resources/META-INF/plexus/ maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/ maven-p...

Author: brett
Date: Thu Oct 13 20:32:41 2005
New Revision: 320986

URL: http://svn.apache.org/viewcvs?rev=320986&view=rev
Log:
add new methods to type handler:
- isAddedToClassPath (default false)
- language (default "none")

Modified:
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java
    maven/components/trunk/maven-artifact/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java?rev=320986&r1=320985&r2=320986&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java Thu Oct 13 20:32:41 2005
@@ -33,4 +33,8 @@
     String getPackaging();
 
     boolean isIncludesDependencies();
+
+    String getLanguage();
+
+    boolean isAddedToClasspath();
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java?rev=320986&r1=320985&r2=320986&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java Thu Oct 13 20:32:41 2005
@@ -35,6 +35,10 @@
 
     private boolean includesDependencies;
 
+    private String language;
+
+    private boolean addedToClasspath;
+
     public DefaultArtifactHandler()
     {
     }
@@ -84,5 +88,20 @@
     public boolean isIncludesDependencies()
     {
         return includesDependencies;
+    }
+
+    public String getLanguage()
+    {
+        if ( language == null )
+        {
+            language = "none";
+        }
+
+        return language;
+    }
+
+    public boolean isAddedToClasspath()
+    {
+        return addedToClasspath;
     }
 }

Modified: maven/components/trunk/maven-artifact/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/resources/META-INF/plexus/components.xml?rev=320986&r1=320985&r2=320986&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-artifact/src/main/resources/META-INF/plexus/components.xml Thu Oct 13 20:32:41 2005
@@ -35,6 +35,8 @@
       <configuration>
         <type>ejb</type>
         <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 
@@ -44,6 +46,8 @@
       <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
       <configuration>
         <type>jar</type>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 
@@ -56,6 +60,8 @@
         <extension>jar</extension>
         <type>test-jar</type>
         <packaging>jar</packaging>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 
@@ -66,6 +72,8 @@
       <configuration>
         <type>maven-plugin</type>
         <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 
@@ -85,6 +93,20 @@
       <configuration>
         <type>java-source</type>
         <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>javadoc</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>javadoc</type>
+        <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 
@@ -95,6 +117,8 @@
       <configuration>
         <type>war</type>
         <includesDependencies>true</includesDependencies>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
       </configuration>
     </component>
 
@@ -105,6 +129,8 @@
       <configuration>
         <type>ear</type>
         <includesDependencies>true</includesDependencies>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
       </configuration>
     </component>
 
@@ -117,6 +143,8 @@
         <extension>jar</extension>
         <packaging>ejb</packaging>
         <classifier>client</classifier>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
       </configuration>
     </component>
 

Modified: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java?rev=320986&r1=320985&r2=320986&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java Thu Oct 13 20:32:41 2005
@@ -42,13 +42,13 @@
      * @deprecated ICK! This needs to be generalized OUTSIDE of this mojo!
      */
     private static final List BANNED_PACKAGINGS;
-    
+
     static
     {
         List banned = new ArrayList();
-        
+
         banned.add( "pom" );
-        
+
         BANNED_PACKAGINGS = banned;
     }
 
@@ -63,7 +63,7 @@
      * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}
      */
     private MavenProjectHelper projectHelper;
-    
+
     /**
      * @parameter expression="${project.packaging}"
      * @readonly
@@ -76,7 +76,7 @@
      * @required
      */
     private String finalName;
-    
+
     /**
      * @parameter expression="${attach}" default-value="true"
      */
@@ -93,23 +93,17 @@
      * @required
      */
     private File outputDirectory;
-    
+
     public void execute()
         throws MojoExecutionException
     {
-        if ( !attach )
-        {
-            getLog().info( "NOT adding java-sources to attached artifacts list." );
-            
-            return;
-        }
-        else if ( BANNED_PACKAGINGS.contains( packaging ) )
+        if ( BANNED_PACKAGINGS.contains( packaging ) )
         {
             getLog().info( "NOT adding java-sources to attached artifacts for packaging: \'" + packaging + "\'." );
-            
+
             return;
         }
-        
+
         // TODO: use a component lookup?
         JarArchiver archiver = new JarArchiver();
 
@@ -133,8 +127,16 @@
             throw new MojoExecutionException( "Error building source JAR", e );
         }
 
-        // TODO: these introduced dependencies on the project are going to become problematic - can we export it
-        //  through metadata instead?
-        projectHelper.attachArtifact( project, "java-source", "sources", outputFile );
+        if ( !attach )
+        {
+            getLog().info( "NOT adding java-sources to attached artifacts list." );
+
+        }
+        else
+        {
+            // TODO: these introduced dependencies on the project are going to become problematic - can we export it
+            //  through metadata instead?
+            projectHelper.attachArtifact( project, "java-source", "sources", outputFile );
+        }
     }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=320986&r1=320985&r2=320986&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Thu Oct 13 20:32:41 2005
@@ -348,7 +348,7 @@
         {
             Artifact a = (Artifact) i.next();
 
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
@@ -384,7 +384,7 @@
             Artifact a = (Artifact) i.next();
 
             // TODO: classpath check doesn't belong here - that's the other method
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
@@ -442,7 +442,7 @@
         {
             Artifact a = (Artifact) i.next();
 
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
@@ -471,7 +471,7 @@
             Artifact a = (Artifact) i.next();
 
             // TODO: classpath check doesn't belong here - that's the other method
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
@@ -536,7 +536,7 @@
         {
             Artifact a = (Artifact) i.next();
 
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
@@ -562,7 +562,7 @@
             Artifact a = (Artifact) i.next();
 
             // TODO: classpath check doesn't belong here - that's the other method
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
@@ -618,7 +618,7 @@
         {
             Artifact a = (Artifact) i.next();
 
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
@@ -653,7 +653,7 @@
             Artifact a = (Artifact) i.next();
 
             // TODO: classpath check doesn't belong here - that's the other method
-            if ( isAddedToClasspath( a ) )
+            if ( a.getArtifactHandler().isAddedToClasspath() )
             {
                 // TODO: let the scope handler deal with this
                 if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
@@ -696,14 +696,6 @@
             }
         }
         return list;
-    }
-
-    private static boolean isAddedToClasspath( Artifact artifact )
-    {
-        String type = artifact.getType();
-
-        // TODO: utilise type handler
-        return "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) || "test-jar".equals( type );
     }
 
     // ----------------------------------------------------------------------