Hi all,

Here is a quick & dirty suggestion for the WAR plugin for those of you who don't want to package WAR files with tons of stuff in the WEB-INF/classes directory. This little preGoal will allow you to package either just the *.class files into a JAR, or the whole content of the WEB-INF/classes directory.

First of all here are the properties :

# set to true if you want the contents of WEB-INF/classes to be packaged into a JAR in WEB-INF/lib
maven.war.jarclasses=true
# the name of the JAR in WEB-INF/lib
maven.war.jarclasses.name=${pom.artifactId}-${pom.currentVersion}.jar
# set to true if you only want the *.class files in the JAR, false will include the whole contents of WEB-INF/classes
maven.war.jarclasses.justclasses=true


Here is the preGoal :

<preGoal name="war:war">
<j:set var="mavenWarJarClasses" value="${maven.war.jarclasses}"/>
<j:set var="mavenWarJarClassesJustClasses" value="${maven.war.jarclasses.justclasses}"/>
<j:set var="mavenWarJarClassesName" value="${maven.war.jarclasses.name}"/>
<j:if test="${mavenWarJarClasses == 'true'}" trim="true">
<j:choose>


<j:when test="${mavenWarJarClassesJustClasses == 'true'}" trim="true">
<jar destfile="${maven.build.dir}/${pom.artifactId}/WEB-INF/lib/${mavenWarJarClassesName}"
basedir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes"
includes="**/*.class"
/>
<!-- we do all this mess because the delete includeEmptyDirs doesn't seem to work in Ant :( -->
<copy includeEmptyDirs="false" toDir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes_justresources">
<fileset dir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes">
<exclude name="**/*.class"/>
</fileset>
</copy>
<delete dir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes" />
<move todir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes">
<fileset dir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes_justresources"/>
</move>
</j:when>


<j:otherwise>
<jar destfile="${maven.build.dir}/${pom.artifactId}/WEB-INF/lib/${mavenWarJarClassesName}"
basedir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes"
includes="**/*"
/>
<delete dir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes" />
<mkdir dir="${maven.build.dir}/${pom.artifactId}/WEB-INF/classes" />
</j:otherwise>


      </j:choose>
    </j:if>
  </preGoal>

I hope this could be included into the WAR plugin as it is very useful to me and maybe to others. How should this happen, can someone take this up or should I try to modify the plugin myself. Please be informed my Jelly knowledge is *very* limited.

Regards,
  Serge Huber.


- -- --- -----=[ shuber2 at jahia dot com ]=---- --- -- -
www.jahia.org : A collaborative source CMS and Portal Server




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to