Our favorite Oracle Middleware author Andrejusb has explained how to setup ear verion for ADF Application in following blog.
http://andrejusb.blogspot.com/2011/12/how-to-set-ear-version-for-adf.html
Here he talks about providing Weblogic-Application-Version parameter in manifest File.
This example, i did the same except, the requirement was to get the version though application built using build.xml (ant script) and we can run through Jenkins
We create a template Manifest file here using which we create the manifest file.
In this example we would also perform operation to increment the build version for the application in ant script
Steps:
1. Create a MANIFEST.TEMPLATE.MF file in src\META-INF folder with following entries:
Manifest-Version: 1.0
Weblogic-Application-Version: @Weblogic-Application-Version@
Release-No: @Release-No@
Build-No: @Build-No@
Built-By: @Built-By@
Built-Date: @Built-Date@
2. Make the entry in build.xml as:
<target name="genEAR" description="Deploy JDeveloper profiles"
depends="prepareVersion">
<copy file="${manifest.file.directory}/MANIFEST.TEMPLATE.MF"
tofile="${manifest.file.directory}/MANIFEST.MF" overwrite="true">
<filterset>
<filter token="Weblogic-Application-Version"
value="${eonoms.build.major}.${eonoms.build.minor}.${eonoms.build.patch}"/>
<filter token="Release-No"
value="${eonoms.build.major}.${eonoms.build.minor}.${eonoms.build.patch}"/>
<filter token="Build-No" value="${eonoms.build.number}"/>
<filter token="Built-By" value="${eonoms.build.user}"/>
<filter token="Built-Date" value="${eonoms.build.date}"/>
</filterset>
</copy>
<taskdef name="ojdeploy"
classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask"
uri="oraclelib:OJDeployAntTask" classpathref="lib.path"
classpath="${oracle.jdeveloper.ant.library}"/>
<ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask"
executable="${oracle.jdeveloper.ojdeploy.path}"
ora:buildscript="${oracle.jdeveloper.deploy.dir}/ojdeploy-build.xml"
ora:statuslog="${oracle.jdeveloper.deploy.dir}/ojdeploy-statuslog.xml">
<ora:deploy>
<ora:parameter name="workspace"
value="${oracle.jdeveloper.workspace.path}"/>
<ora:parameter name="profile"
value="${oracle.jdeveloper.deploy.profile.name}"/>
<ora:parameter name="nocompile" value="false"/>
<ora:parameter name="outputfile"
value="${oracle.jdeveloper.deploy.outputfile}__${Current_Date}"/>
</ora:deploy>
</ora:ojdeploy>
</target>
<target name="prepareVersion">
<property name="header"
value="##Semi auto Generated file - Read comments before any manual modifications and consult with app owners"/>
<property environment="build_env"/>
<entry key="eonoms.build.number" type="int" default="0001" operation="+"
pattern="0000"/>
<entry key="eonoms.build.date" type="date" value="now"/>
<entry key="eonoms.build.user" type="string"
value="${user.name}"/>
</propertyfile>
</target>
Here, the target prepareVersion populates the build version info. It also increments the version number by 1 for next release.
The build info prepared is fed to the target genEAR where it copies the entry to template file to Manifest.MF with replacement for tokens available in template.
3. This build.xml can be run through jenkins to prepare ADF ear with version number information to be deployed in weblogic server
Please please your questions in comments. If required i can share the necessary files/application