polx 2004/02/03 14:44:17 Modified: jelly maven.xml Log: Adding a goal named pack-fat-jar so that one can pack a binary of jelly and all its dependent in one double-clickable jar. Use as follows: maven pack-fat-jar -DtagLibs=xml,util java -jar target/jellypack.jar myFile.jelly Not much tested, thanks to comment! paul Revision Changes Path 1.66 +68 -0 jakarta-commons/jelly/maven.xml Index: maven.xml =================================================================== RCS file: /home/cvs/jakarta-commons/jelly/maven.xml,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- maven.xml 25 Dec 2003 22:09:58 -0000 1.65 +++ maven.xml 3 Feb 2004 22:44:17 -0000 1.66 @@ -313,4 +313,72 @@ <path refid="maven.dependency.classpath"/> </path> </goal> + + + + <goal name="pack-fat-jar" prereqs="jar" + description="Creates a jar with all the dependencies of jelly and the taglibs indicated in ${tagLibs}."> + <!-- this goal isn't really much tested yet but could be the key + to get a better packaging --> + + <j:new var="jellyTaglibNames" className="java.util.HashSet"/> + <j:set var="taglibs_projects" value=""/> + <util:tokenize delim="," var="tagLibnames">${tagLibs}</util:tokenize> + <j:forEach var="tlName" items="${tagLibnames}"> + <echo>Considering taglib tlName "${tlName}".</echo> + <j:if test="${'core' ne tlName}"> + <j:if test="${taglibs_projects.length() > 0}"><j:set var="taglibs_projects" trim="false">${taglibs_projects},</j:set></j:if> + <j:set var="taglibs_projects">${taglibs_projects}jelly-tags/${tlName}/project.xml</j:set> + ${jellyTaglibNames.add(tlName)} + </j:if> + </j:forEach> + + <!-- collect all dependencies in a set --> + <j:new var="deps" className="java.util.HashSet"/> + + <maven:reactor + basedir="." goal="jar:install-snapshot" + postProcessing="true" + includes="${taglibs_projects}" + ignoreFailures="false"> + </maven:reactor> + <j:forEach var="reactorProject" items="${reactorProjects}"> + <j:forEach var="dep" items="${reactorProject.dependencies}">${deps.add(dep)}</j:forEach> + </j:forEach> + <j:forEach var="tl" items="${jellyTaglibNames}"> + <j:new var="tlD" className="org.apache.maven.project.Dependency"/> + ${tlD.setGroupId("commons-jelly")} + <j:set var="artId" value="commons-jelly-tags-${tl}"/> + ${tlD.setArtifactId(artId)} + ${tlD.setType("jar")} + ${tlD.setVersion("SNAPSHOT")} + ${deps.add(tlD)} + </j:forEach> + + <maven:reactor + basedir="." + postProcessing="true" + includes="project.xml" + ignoreFailures="false"> + </maven:reactor> + <j:forEach var="reactorProject" items="${reactorProjects}"> + <j:forEach var="dep" items="${reactorProject.dependencies}">${deps.add(dep)}</j:forEach> + </j:forEach> + + + <j:file name="${maven.build.dir}/deps.txt">${deps}</j:file> + + <!-- we could process project's dependencies if we were a plugin --> + + <!-- merging it all --> + <jar destfile="${maven.build.dir}/jellypack.jar"> + <manifest> + <attribute name="Main-Class" value="org.apache.commons.jelly.Jelly"/></manifest> + <j:forEach var="dep" items="${deps}"> + <zipfileset src="${maven.repo.local}/${dep.groupId}/${dep.type}s/${dep.artifact}" /> + <echo>Adding jar ${maven.repo.local}/${dep.groupId}/${dep.type}s/${dep.artifact}.</echo> + </j:forEach> + </jar> + + </goal> </project>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]