I have the following build.xml code. Here i do modify the manifest file in a jar file. In manifest i wanted to add few attributes such as Asset-Name and Asset-Baseline.
Content of buildInfo.properties is as followed:
articlelib_componentname=ABC component.
articlelib_baselineName=Baseline_1.
buslib_componentname=XYZ component.
buslib_baselineName=Baseline_2.
build.xml: I want to pass the name i.e articlelib value dynamically, and retrieve the values from buildInfo.properties. I used macrodef outside manifest it's working file but when i use the same in manifest tag I'm unable to use it. Can I have a work around for this problem or alternative solution to pass dynamic values to manifest so that I can retrieve values from the builInfo.properties
<property name="name" value="articlelib" />
<property name="name_path" value="${name}_componentName" />
<property file="buildInfo.properties" prefix="buildInfo" />
<property file="buildInfo.properties"/>
<macrodef name="property-read">
<attribute name="name"/>
<attribute name="from"/>
<sequential>
<property name="@{name}" value="${@{from}_componentName}"/>
</sequential>
</macrodef>
<target name="test">
<echo>PRODUCT_NAME: ${name}</echo>
<property-read name="instance" from="${name}"/>
<echo>DYNAMIC PROPERTY VALUE: ${instance}</echo>
</target>
<target name="earchive" description="Generate the EAR file">
<jar destfile="${dir.dist}/${name}.jar">
<manifest>
<attribute name="Specification-Title" value="${name}" />
<property-read name="instance" from="${name}"/>
<attribute name="Asset-Component" value="${instance}" />
<echo>DYNAMIC PROPERTY VALUE: ${instance}</echo>
<attribute name="Asset-Baseline" value="${buildInfo.articleliblocal.baselineName}" />
</manifest>
</jar>
</target>
</project>
When i use the above property-read micro in manifest tag i get the following error:
BUILD FAILED
H:\Ant_Scripts_Testing\hello.xml:27: manifest doesn't support the nested "proper ty-read" element. at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.jav a:359) at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:5 69) at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.jav a:346) at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:198 ) at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.jav a:160) at org.apache.tools.ant.Task.perform(Task.java:347) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe cutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: class org.apache.tools.ant.taskdefs.Manifest doesn't support the nest ed "property-read" element. at org.apache.tools.ant.IntrospectionHelper.throwNotSupported(Introspect ionHelper.java:447) at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.jav a:349)