[ http://jira.codehaus.org/browse/MWAR-73?page=comments#action_76984 ] 
            
mark struberg commented on MWAR-73:
-----------------------------------

It seems that i found a second way to fit my needs:

I patched the archiveClasses feature to create an attached artifact and switch 
this feature on in war1. 
>     public void createJarArchive( File libDirectory )
>  ...
>            archiver.getArchiver().addDirectory( classesDirectory, 
> getIncludes(), getExcludes() );
>            archiver.createArchive( project, archive );
>            projectHelper.attachArtifact( project, "jar", "webclasses", 
> jarFile );


In the pom of war2, i simply add a manual dependency to this webclasses 
artifact.
    <dependency><!-- the dependant war file-->
      <groupId>msx.test</groupId>
      <artifactId>war1</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>war</type>
    </dependency>
    <dependency> <!-- the classes of the dependant war file-->
      <groupId>msx.test</groupId>
      <artifactId>war1</artifactId>
      <version>1.0-SNAPSHOT</version>
      <classifier>webclasses</classifier>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>

This method has a few pros and also cons
pro: 
1.) it is faster (compared to war overlaying in preparecp step), because the 
unpacking step isn't needed anymore
2.) the hack with the resource path led to unintended side effects when using 
the eclipse and idea plugins (The classes got added as source directories in 
the IDE). The dependency resolution now also works with e.g.  m2eclipse

contra:
1.) the first war needs to have 'archiveClasses=true'
2.) in the 2nd war, there have to be 2 dependency settings, one for the war 
itself and another one with the webclasses classifier. The version numbers 
always have to be exactly the same.

The 2nd con may be avoided if it is possible to automatically check if there is 
an attached 'webclasses'  artifact, and automatically add this artifact to the 
dependency list. But i didn't succeed to get this work. Anyone have an idea how 
i may manage this?

> war overlay mechanism does not work for classes
> -----------------------------------------------
>
>                 Key: MWAR-73
>                 URL: http://jira.codehaus.org/browse/MWAR-73
>             Project: Maven 2.x War Plugin
>          Issue Type: Improvement
>    Affects Versions: 2.0, 2.1, 2.0.1, 2.0.2
>         Environment: all OS, all JDK, currently using jdk1.4.2_10 and 
> jdk1.5.0_06 under linux fedora core 5/x86_64 and sunOS5.10/Sparc64
>            Reporter: mark struberg
>         Attachments: maven-war-plugin-patch.tar.gz
>
>
> PROBLEM DESCRIPTION:
> When building a WAR (e.g. war2.war) which depends on another WAR (e.g. 
> war1.war), the web-resources from the dependant war are beeing used as base 
> for overlaying. 
> This mechanism doesn't currently work for the classes within the dependant 
> war, altough it is specified by the plugin documentation 
> See the SampleActionDependency.class in 
> http://maven.apache.org/plugins/maven-war-plugin/examples/war-overlay.html 
> APPLIED PATCH:
> I have written two simple war examples war1 and war2 and extended the 
> maven-war-plugin by an own WarClasspathMojo which is bound to the phase 
> generate-resources to fix this issue.
> Since i found no way to add non-artifact parts to the classpath, i simply 
> unpack all dependant war files (reusing the functions already there in 
> AbstractWarMojo) and add a resource-path to the 
> $explodedWarDir/WEB-INF/classes for each of them. The 
> The implementation fits all my needs, but if you provide me with a hint how 
> it may be improved, then let me know.
> KNOWN ISSUES:
> This mechanism currently doesn't work if you have specified to generate an 
> archive for the dependant war's classes.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to