maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Venisse" <emman...@venisse.net>
Subject RE: cvs commit: maven-components/maven-plugins/maven-war-plugin/s rc/main/java/org/apache/maven/plugin/war WarMojo.java
Date Wed, 09 Mar 2005 10:09:25 GMT
Maczka Michal said:
>
>
>> -----Original Message-----
>> From: evenisse@apache.org [mailto:evenisse@apache.org]
>> Sent: Wednesday, March 09, 2005 7:46 AM
>> To: maven-components-cvs@apache.org
>> Subject: cvs commit:
>> maven-components/maven-plugins/maven-war-plugin/src/main/java/
>> org/apache
>> /maven/plugin/war WarMojo.java
>>
>>
>> evenisse    2005/03/08 22:45:33
>>
>>   Modified:    maven-core-it/it0016 pom.xml
>>
>> maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/
>> plugin/war
>>                         WarMojo.java
>>   Log:
>>   Add dependencies in war and add support of scope deps
>>
>>   Revision  Changes    Path
>>   1.2       +13 -0     maven-components/maven-core-it/it0016/pom.xml
>>
>>   Index: pom.xml
>>   ===================================================================
>> RCS file: /home/cvs/maven-components/maven-core-it/it0016/pom.xml,v
>> retrieving revision 1.1
>>   retrieving revision 1.2
>>   diff -u -r1.1 -r1.2
>>   --- pom.xml	3 Mar 2005 09:08:47 -0000	1.1
>>   +++ pom.xml	9 Mar 2005 06:45:33 -0000	1.2
>>   @@ -4,4 +4,17 @@
>>      <artifactId>maven-core-it0016</artifactId>
>>      <type>war</type>
>>      <version>1.0</version>
>>   +  <dependencies>
>>   +    <dependency>
>>   +      <groupId>commons-logging</groupId>
>>   +      <artifactId>commons-logging</artifactId>
>>   +      <version>1.0.3</version>
>>   +      <scope>runtime</scope>
>>   +    </dependency>
>>   +    <dependency>
>>   +      <groupId>servletapi</groupId>
>>   +      <artifactId>servletapi</artifactId>
>>   +      <version>2.3</version>
>>   +    </dependency>
>>   +  </dependencies>
>>    </project>
>>
>>
>>
>>   1.6       +7 -18
>> maven-components/maven-plugins/maven-war-plugin/src/main/java/
>> org/apache/maven/plugin/war/WarMojo.java
>>
>>   Index: WarMojo.java
>>   ===================================================================
>> RCS file:
>> /home/cvs/maven-components/maven-plugins/maven-war-plugin/src/
> main/java/org/apache/maven/plugin/war/WarMojo.jav> a,v
>>   retrieving revision 1.5
>>   retrieving revision 1.6
>>   diff -u -r1.5 -r1.6
>>   --- WarMojo.java	8 Mar 2005 06:39:50 -0000	1.5
>>   +++ WarMojo.java	9 Mar 2005 06:45:33 -0000	1.6
>>   @@ -23,7 +23,6 @@
>>
>>    import org.apache.maven.archiver.MavenArchiver;
>>    import org.apache.maven.artifact.Artifact;
>>   -import org.apache.maven.artifact.repository.ArtifactRepository;
>>    import org.apache.maven.plugin.AbstractPlugin;
>>    import org.apache.maven.plugin.PluginExecutionRequest;
>>    import org.apache.maven.plugin.PluginExecutionResponse;
>>   @@ -144,12 +143,6 @@
>>     *  validator=""
>>     *  expression="#project.build.directory"
>>     *  description=""
>>   - * @parameter name="localRepository"
>>   - *  type="org.apache.maven.artifact.repository.ArtifactRepository"
>> - *  required="true"
>>   - *  validator=""
>>   - *  expression="#localRepository"
>>   - *  description=""
>>     * @parameter
>>     *  name="project"
>>     *  type="org.apache.maven.project.MavenProject"
>>   @@ -172,8 +165,6 @@
>>
>>        private MavenProject project;
>>
>>   -    private ArtifactRepository localRepository;
>>   -
>>        private File classesDirectory;
>>
>>        private String outputDirectory;
>>   @@ -211,13 +202,12 @@
>>        }
>>
>>        /**
>>   -     * @todo properties 'war.bundle' and 'war.target.path'
>>   -     * @todo copy classes to classes webapp directory
>>   +     * @todo properties 'war.target.path'
>>         */
>>        public void buildWebapp( MavenProject project )
>>            throws IOException
>>        {
>>   -        request.getLog().info( "Assembling webapp " +
>> project.getArtifactId() );
>>   +        request.getLog().info( "Assembling webapp " +
>> project.getArtifactId() + " in " +
>> webappDirectory.getAbsolutePath() );
>>
>>            File libDirectory = new File( webappDirectory,
>> WEB_INF + "/lib" );
>>
>>   @@ -235,13 +225,14 @@
>>            for ( Iterator iter = artifacts.iterator();
>> iter.hasNext(); )
>>            {
>>                Artifact artifact = (Artifact) iter.next();
>>   -            if ( "jar".equals( artifact.getType() ) )
>>   +
>>   +            if ( "jar".equals( artifact.getType() ) &&
>> Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
>>                {
>>   -                FileUtils.copyFileToDirectory( new File(
>> localRepository.getBasedir(), artifact.toString() ) , libDirectory );
>>   +                FileUtils.copyFileToDirectory(
>> artifact.getFile() , libDirectory );
>>                }
>>                if ( "tld".equals( artifact.getType() ) )
>>                {
>>   -                FileUtils.copyFileToDirectory( new File(
>> localRepository.getBasedir(), artifact.toString() ) , tldDirectory );
>>   +                FileUtils.copyFileToDirectory(
>> artifact.getFile() , tldDirectory );
>>                }
>>            }
>>        }
>>   @@ -318,8 +309,6 @@
>>
>>            project = (MavenProject) request.getParameter( "project" );
>>
>>   -        localRepository = (ArtifactRepository)
>> request.getParameter( "localRepository" );
>>   -
>>            classesDirectory = new File( (String)
>> request.getParameter( "classesDirectory" ) );
>>
>>            outputDirectory = (String) request.getParameter(
>> "outputDirectory" );
>>
>>
>>
>
>
> Hmm. Don't you want to add to war everything except test only and
> compile-time only dependecies?
> So for example dependecies with no scope attribute given (if I
> understand they should be "globally" visible in all
> list of classpath elements) will be bundled as well.
>

A dependency with no scope is a dependency with compile scope.

>
> Shouldn't it be rather something like:
>
>
>   +  <dependencies>
>>   +    <dependency>
>>   +      <groupId>commons-logging</groupId>
>>   +      <artifactId>commons-logging</artifactId>
>>   +      <version>1.0.3</version>
>>   +    </dependency>
>>   +    <dependency>
>>   +      <groupId>servletapi</groupId>
>>   +      <artifactId>servletapi</artifactId>
>>   +      <version>2.3</version>
>>   +      <scope>compile</scope>
>>   +    </dependency>
>>   +  </dependencies>
>
> the problem is that servlet-api (runtime dependency) could be also a
> test dependency
> (for example there are some test frameworks which are emulating servlet
> containers),
> so probably it should be possible to limit the scope of a dependency to
> more then one of the existing scopes
> (e.g. to express that the scope of servletapi is: compile & test).

The test phase includes all dependencies with scope compile, test and
runtime.
See at
http://cvs.apache.org/viewcvs.cgi/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java?rev=1.24&view=markup

in method getTestClasspathElements()

Emmanuel



Mime
View raw message