ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Berry" <Craig.Be...@portblue.com>
Subject RE: Extension to Manifest task?
Date Wed, 03 Mar 2004 19:29:51 GMT
> From: Stefan Bodewig [mailto:bodewig@apache.org]
> <pathconvert> should be able to take the <path> and turn it into a
> property stripping of the leading absolute path with nested <map>
> (or, CVS HEAD only, <mapper>) elements.
>
> I'd prefer an approach that works outside of <ear> and even outside of
> <manifest> as it may very well apply to a more general problem.  So
> please look into <pathconvert> to see whether it fits.

The fit turns out to be rather awkward.  I've reproduced the minimal
approach I've been able to make work below.  Note that this is just the
non-ejb-jar gathering and manifest-generation target; actually building
the EAR using the <ear> task happens in a different target.  Note that I
need two pathconverts, one to turn my relative lib path into an absolute
path, and one to drive the prefix-replacement mapping.

I am coming more and more to think that the right solution is an
addition to the manifest task to handle constructing a path-substituted
classpath attr based on a fileset of jars and an intendended
EAR-relative prefix.  Doing it in the <ear> task would be more direct,
but also a bit uglier as you'd need to reach into every ejb jar and mess
with its manifest, which seems wrong.

Anyway, here's my current solution.  Thoughts on how to make this easier
and cleaner, either through better use of existing tools or through
enhancements of the <ear>, <jar>, or <manifest> tasks, are very welcome.

    <target name="prepare.libs" depends="init">
		<!-- Gather the non-ejb EAR jars and build a fileset
containing them -->
		<copy todir="${portblue.build.ear-libs}"
		      flatten="true">
			<fileset refid="portblue.libs.ear"/>
		</copy>
		
		<fileset dir="${portblue.build.ear-libs}"
id="lib.include"/>

		<!-- Turn the rel path of these jars into an abs path
-->		
		<pathconvert property="lib.prefix" pathsep=" ">
			<path location="${portblue.build.ear-libs}"/>
		</pathconvert>

		<!-- Replace the abs path prefix of the jars with 'lib'
(which will
		     be the EAR-relative path) -->
     	      <pathconvert refid="lib.include"
     	             property="ear.classpath"
     	             dirsep="/"
     	             pathsep=" ">
     		    <map from="${lib.prefix}" to="lib"/>
     	      </pathconvert>

     	      <!-- Build the manifest file using the generated classpath
-->
     	      <manifest
file="${portblue.build.jar-meta-inf}/MANIFEST.MF">
     		      <attribute name="Class-Path"
value="${ear.classpath}"/>
     	      </manifest>
    </target>

-- 
Craig Berry
Principal Architect and Technical Manager
PortBlue
(310) 566-7546
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message