maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/project MavenProject.java
Date Mon, 07 Mar 2005 09:41:55 GMT
brett       2005/03/07 01:41:55

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/resolver
                        DefaultArtifactResolver.java
               maven-artifact/src/main/java/org/apache/maven/artifact
                        Artifact.java DefaultArtifact.java
               maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin
                        CompilerMojo.java TestCompilerMojo.java
               maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
                        SurefirePlugin.java
               maven-core/src/main/java/org/apache/maven/artifact/factory
                        DefaultArtifactFactory.java
               maven-core/src/main/java/org/apache/maven/artifact
                        MavenMetadataSource.java
               maven-core/src/main/java/org/apache/maven/project
                        MavenProject.java
  Log:
  add basic test dependency handling
  
  Revision  Changes    Path
  1.13      +7 -6      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
  
  Index: DefaultArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultArtifactResolver.java	3 Mar 2005 15:37:25 -0000	1.12
  +++ DefaultArtifactResolver.java	7 Mar 2005 09:41:54 -0000	1.13
  @@ -2,13 +2,13 @@
   
   import org.apache.maven.artifact.AbstractArtifactComponent;
   import org.apache.maven.artifact.Artifact;
  -import org.apache.maven.artifact.resolver.transform.ArtifactRequestTransformation;
   import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
   import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
   import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
  +import org.apache.maven.artifact.resolver.transform.ArtifactRequestTransformation;
   import org.apache.maven.wagon.TransferFailedException;
   
   import java.util.HashMap;
  @@ -187,11 +187,11 @@
       //
       // ----------------------------------------------------------------------
   
  -    protected ArtifactResolutionResult collect( Set artifacts,
  -                                                ArtifactRepository localRepository,
  -                                                Set remoteRepositories,
  -                                                ArtifactMetadataSource source,
  -                                                ArtifactFilter filter )
  +    private ArtifactResolutionResult collect( Set artifacts,
  +                                              ArtifactRepository localRepository,
  +                                              Set remoteRepositories,
  +                                              ArtifactMetadataSource source,
  +                                              ArtifactFilter filter )
           throws TransitiveArtifactResolutionException
       {
           ArtifactResolutionResult result = new ArtifactResolutionResult();
  @@ -242,6 +242,7 @@
   
                       try
                       {
  +                        // TODO: need to convert scope compile -> runtime using scope
handler
                           referencedDependencies = source.retrieve( newArtifact, localRepository,
remoteRepositories );
                       }
                       catch ( ArtifactMetadataRetrievalException e )
  
  
  
  1.2       +2 -0      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java
  
  Index: Artifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Artifact.java	9 Aug 2004 18:37:32 -0000	1.1
  +++ Artifact.java	7 Mar 2005 09:41:54 -0000	1.2
  @@ -26,6 +26,8 @@
   
       String getVersion();
   
  +    String getScope();
  +
       String getType();
   
       String getExtension();
  
  
  
  1.4       +17 -6     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
  
  Index: DefaultArtifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultArtifact.java	13 Jan 2005 09:37:44 -0000	1.3
  +++ DefaultArtifact.java	7 Mar 2005 09:41:54 -0000	1.4
  @@ -37,28 +37,39 @@
   
       private String type;
   
  +    private String scope;
  +
       private String extension;
   
       private String path;
   
  -    public DefaultArtifact( String groupId, String artifactId, String version, String type,
String extension )
  +    public DefaultArtifact( String groupId, String artifactId, String version, String scope,
String type, 
  +                            String extension )
       {
           this.groupId = groupId;
  -
           this.artifactId = artifactId;
  -
           this.version = version;
  -
           this.type = type;
  -
  +        this.scope = scope;
           this.extension = extension;
       }
   
  +    /** @todo this should be replaced by type handler */
  +    public DefaultArtifact( String groupId, String artifactId, String version, String type,
String extension )
  +    {
  +        this( groupId, artifactId, version, null, type, extension );
  +    }
  +
       public DefaultArtifact( String groupId, String artifactId, String version, String type
)
       {
           this( groupId, artifactId, version, type, type );
       }
   
  +    public String getScope()
  +    {
  +        return scope;
  +    }
  +
       public String getGroupId()
       {
           return groupId;
  
  
  
  1.15      +9 -10     maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
  
  Index: CompilerMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CompilerMojo.java	4 Mar 2005 09:04:24 -0000	1.14
  +++ CompilerMojo.java	7 Mar 2005 09:41:55 -0000	1.15
  @@ -7,7 +7,6 @@
   
   import java.io.File;
   import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.Iterator;
   import java.util.List;
   
  @@ -36,10 +35,10 @@
    *
    * @parameter
    *  name="classpathElements"
  - *  type="String[]"
  + *  type="List"
    *  required="true"
    *  validator=""
  - *  expression="#project.classpathElements"
  + *  expression="#project.compileClasspathElements"
    *  description=""
    *
    * @parameter
  @@ -73,7 +72,7 @@
   
           String outputDirectory = (String) request.getParameter( "outputDirectory" );
   
  -        String[] classpathElements = (String[]) request.getParameter( "classpathElements"
);
  +        List classpathElements = (List) request.getParameter( "classpathElements" );
   
           // ----------------------------------------------------------------------
           //
  @@ -88,7 +87,7 @@
           CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
           
           compilerConfiguration.setOutputLocation(outputDirectory);
  -        compilerConfiguration.setClasspathEntries(Arrays.asList(classpathElements));
  +        compilerConfiguration.setClasspathEntries( classpathElements );
           compilerConfiguration.setSourceLocations( compileSourceRootsList );
           
           /* Compile with debugging info */
  @@ -106,11 +105,12 @@
   
           if ( debug )
           {
  -            for ( int i = 0; i < classpathElements.length; i++ )
  +            for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
               {
                   String message;
   
  -                if ( new File( classpathElements[i] ).exists() )
  +                String classpathElement = (String) i.next();
  +                if ( new File( classpathElement ).exists() )
                   {
                       message = "present in repository.";
                   }
  @@ -119,8 +119,7 @@
                       message = "Warning! not present in repository!";
                   }
   
  -//                System.out.println( "classpathElements[ "+ i +" ] = " + classpathElements[i]
+ ": " + message );
  -                request.getLog().debug( "classpathElements[ "+ i +" ] = " + classpathElements[i]
+ ": " + message );
  +                request.getLog().debug( "classpathElements[ "+ i +" ] = " + classpathElement
+ ": " + message );
               }
           }
   
  
  
  
  1.7       +5 -3      maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
  
  Index: TestCompilerMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestCompilerMojo.java	27 Feb 2005 22:23:27 -0000	1.6
  +++ TestCompilerMojo.java	7 Mar 2005 09:41:55 -0000	1.7
  @@ -7,6 +7,8 @@
    *
    * @description Compiles test sources
    *
  + * @requiresDependencyResolution
  + *
    * @parameter
    *  name="compileSourceRootsList"
    *  type="java.util.List"
  @@ -24,10 +26,10 @@
    *  description=""
    * @parameter
    *  name="classpathElements"
  - *  type="String[]"
  + *  type="List"
    *  required="true"
    *  validator=""
  - *  expression="#project.classpathElements"
  + *  expression="#project.testClasspathElements"
    *  description=""
    * @parameter
    *  name="debug"
  
  
  
  1.17      +8 -14     maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java
  
  Index: SurefirePlugin.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SurefirePlugin.java	3 Nov 2004 23:31:37 -0000	1.16
  +++ SurefirePlugin.java	7 Mar 2005 09:41:55 -0000	1.17
  @@ -1,18 +1,15 @@
   package org.apache.maven.test;
   
  -import org.codehaus.surefire.SurefireBooter;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.codehaus.surefire.SurefireBooter;
   
   import java.io.File;
  -import java.util.List;
   import java.util.ArrayList;
  -import java.util.Arrays;
  -import java.util.Collection;
  -import java.util.Collections;
  +import java.util.Iterator;
  +import java.util.List;
   import java.util.StringTokenizer;
  -import java.lang.reflect.Array;
   
   /**
    * @goal test
  @@ -71,7 +68,7 @@
    *  type="String[]"
    *  required="true"
    *  validator=""
  - *  expression="#project.classpathElements"
  + *  expression="#project.testClasspathElements"
    *  description=""
    * @parameter
    *  name="reportsDirectory"
  @@ -112,7 +109,7 @@
   
           String testClassesDirectory = (String) request.getParameter( "testClassesDirectory"
);
   
  -        String[] classpathElements = (String[]) request.getParameter( "classpathElements"
);
  +        List testClasspathElements = (List) request.getParameter( "classpathElements" );
   
           String reportsDirectory = (String) request.getParameter( "reportsDirectory" );
   
  @@ -171,12 +168,9 @@
   
           surefireBooter.addClassPathUrl( new File( testClassesDirectory ).getPath() );
   
  -        for ( int i = 0; i < classpathElements.length; i++ )
  +        for ( Iterator i = testClasspathElements.iterator(); i.hasNext(); )
           {
  -            if(classpathElements[i] != null)
  -            {
  -                surefireBooter.addClassPathUrl( classpathElements[i] );
  -            }
  +            surefireBooter.addClassPathUrl( (String) i.next() );
           }
   
           surefireBooter.addReport( "org.codehaus.surefire.report.ConsoleReporter" );
  
  
  
  1.6       +2 -0      maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
  
  Index: DefaultArtifactFactory.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultArtifactFactory.java	25 Dec 2004 16:26:24 -0000	1.5
  +++ DefaultArtifactFactory.java	7 Mar 2005 09:41:55 -0000	1.6
  @@ -51,6 +51,8 @@
           Artifact artifact = new DefaultArtifact( dependency.getGroupId(),
                                                    dependency.getArtifactId(),
                                                    dependency.getVersion(),
  +                                                 dependency.getScope(),
  +                                                 dependency.getType(),
                                                    dependency.getType() );
   
           return artifact;
  
  
  
  1.12      +3 -1      maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
  
  Index: MavenMetadataSource.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MavenMetadataSource.java	24 Feb 2005 05:33:18 -0000	1.11
  +++ MavenMetadataSource.java	7 Mar 2005 09:41:55 -0000	1.12
  @@ -117,6 +117,8 @@
           Artifact artifact = new DefaultArtifact( dependency.getGroupId(),
                                                    dependency.getArtifactId(),
                                                    dependency.getVersion(),
  +                                                 dependency.getScope(),
  +                                                 dependency.getType(),
                                                    dependency.getType() );
           return artifact;
       }
  
  
  
  1.20      +32 -16    maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
  
  Index: MavenProject.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- MavenProject.java	27 Feb 2005 21:51:52 -0000	1.19
  +++ MavenProject.java	7 Mar 2005 09:41:55 -0000	1.20
  @@ -209,35 +209,51 @@
           return list;
       }
   
  -    /* TODO: remove - should be using a type handler - is being used by introspection in
plugins. */
  -    public String[] getClasspathElements()
  +    public List getCompileClasspathElements()
       {
  -        int size = getArtifacts().size();
  +        List list = new ArrayList( getArtifacts().size() );
   
  -        String[] classpathElements = new String[size + 1];
  -
  -        int i = 0;
  -
  -        for ( Iterator it = getArtifacts().iterator(); it.hasNext(); )
  +        for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
           {
  -            Artifact artifact = (Artifact) it.next();
  +            Artifact a = (Artifact) i.next();
   
  -            if ( isAddedToClasspath( artifact ) )
  +            // TODO: let the scope handler deal with this
  +            if ( a.getScope() == null || "compile".equals( a.getScope() ) )
               {
  -                classpathElements[i++] = artifact.getPath();
  +                list.add( a.getPath() );
               }
           }
  +        return list;
  +    }
  +
  +    public List getTestClasspathElements()
  +    {
  +        List list = new ArrayList( getArtifacts().size() + 1 );
   
  -        classpathElements[i] = getBuild().getOutput();
  +        list.add( getBuild().getOutput() );
   
  -        return classpathElements;
  +        for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
  +        {
  +            Artifact a = (Artifact) i.next();
  +
  +            if ( isAddedToClasspath( a ) )
  +            {
  +                // TODO: let the scope handler deal with this
  +                if ( a.getScope() == null || "test".equals( a.getScope() ) || "compile".equals(
a.getScope() ) || "runtime".equals( a.getScope() ) )
  +                {
  +                    list.add( a.getPath() );
  +                }
  +            }
  +        }
  +        return list;
       }
   
  -    public boolean isAddedToClasspath( Artifact artifact )
  +    private static boolean isAddedToClasspath( Artifact artifact )
       {
  -        String type = artifact.getType().trim();
  +        String type = artifact.getType();
   
  -        if ( type.equals( "jar" ) || type.equals( "ejb" ) || type.equals( "test" ) )
  +        // TODO: utilise type handler
  +        if ( "jar".equals( type ) || "ejb".equals( type ) )
           {
               return true;
           }
  
  
  

Mime
View raw message