MXMLC ANT for building AIR application - ant

I'm used a script ANT, with MXMLC task to build my AIR application. The generation is oK (.swf is generated). But the xxx-app.xml is not generated too ?
<mxmlc
file="${src.dir}/${trinity.project}.mxml"
output="${release.dir}/${trinity-client}.swf"
locale="fr_FR"
static-rsls="true"
accessible="true"
configname="air"
debug="false"
failonerror="true"
fork="true"
optimize="true"
maxmemory="512m">
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${src.dir}"/>
<use-network>true</use-network>
<external-library-path file="${FLEX_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
<library-path dir="${ivy.cache.dir}" append="true">
<include name="${puremvc.lib}"/>
<include name="${kccalendar.lib}"/>
<include name="${as3commons.lib}"/>
</library-path>
</mxmlc>
Have you got a solution ?
Thank you very much,
Anthony

You need to call adt in the sdk folder, to make a .air package.
eg:
<target name="execute.air">
<condition property="adt.name" value="adt">
<os family="unix" />
</condition>
<condition property="adt.name" value="adt.bat">
<os family="windows" />
</condition>
<exec executable="${FLEX_HOME}/bin/${adt.name}" failonerror="true">
<arg line="-package" />
<arg line="-tsa none" />
<arg line="-storetype pkcs12" />
<arg line="-keystore ${basedir}/keys/${APP_NAME}.p12" />
<arg line="-storepass password" />
<arg line="${DEPLOY_DIR}/${APP_NAME}.air" />
<arg line="${SRC_DIR}/${APP_NAME}-app.xml" />
<arg line="-C ${DEPLOY_DIR} ${APP_NAME}.swf" />
</exec>
</target>

Related

jenkins build configuration- packaging EAR issue

I have the build configuration set up for jenkins and while packaging EAR it is neglecting an xml file while it builds. I want to make sure that file gets updated via build configuration .
''''''EAR Packager file
<property name="librariesFolderPath" value="${basedir}/../libs" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${librariesFolderPath}/ant-contrib.jar" />
</classpath>
</taskdef>
<property environment="env" />
<condition property="partialWsPath" value="**/${TO_BUILD}/**" else="**">
<and>
<isset property="TO_BUILD" />
<not>
<equals arg1="${TO_BUILD}" arg2="" trim="true" />
</not>
</and>
</condition>
<condition property="lurch.properties.file" value="${project.properties.file}" else="lurchproject.properties">
<and>
<isset property="project.properties.file" />
<not>
<equals arg1="${project.properties.file}" arg2="" trim="true" />
</not>
</and>
</condition>
<pathconvert property="project.properties.path">
<fileset dir="${env.WORKSPACE}" includes="${partialWsPath}/${lurch.properties.file}" />
</pathconvert>
<property file="${project.properties.path}" />
<propertyregex property="studio.buildnumber" input="${studio.version}" regexp="(.*)[a-zA-Z]$" select="\1" defaultvalue="${studio.version}" />
<property file="${basedir}/../config/builderstructure.properties" />
<property file="${basedir}/barpackager.properties" />
<property file="${runtime.properties.file}" />
<property name="lurch.customized.folder.path" value="${basedir}/../../customized" />
<!-- Retriving deploy-project name -->
<propertyregex property="deploy.project.name" input="${deploy.project}" regexp="([^\\/]*)[\\/]?$" select="\1" />
<!-- Retriving the list of libraries that mustn't be in the ear -->
<propertyregex property="targetj2ee" input="${target.j2ee}" regexp=" " replace="_" global="true" />
<propertycopy property="libs2cutoff" from="libs2cutoff.${targetj2ee}" />
<!-- =================================
target: default
================================= -->
<target name="earsPackagingCompleted"
depends="init,evaluateConditions,createDeployJar,generateManifest,createEJB,createWAR,createEar,customizeEar"
description="Calls all the targets needd to generate the ear" />
<!-- =================================
target: init
================================= -->
<target name="init" description="Compute the build order">
<delete dir="${output.ears}" includeemptydirs="true" />
<mkdir dir="${output.ears.tmp.lib}" />
<mkdir dir="${output.ears.tmp.war}/META-INF" />
<mkdir dir="${output.ears.tmp.ejb}/META-INF" />
</target>
<!-- =================================
target: evaluateConditions
================================= -->
<target name="evaluateConditions" depends="" description="Evaluates conditions rekated to ear creation">
<condition property="appl.srv.project.folder"
value="${runtime.projects.to.build}/${deploy.project.name}/${deploy.appl.srv.folder}/${target.j2ee}">
<!-- else="${eclipse.plugins}/${appl.srv.studio.folder}/${target.j2ee}" -->
<and>
<isset property="deploy.appl.srv.folder" />
<not>
<equals arg1="${deploy.appl.srv.folder}" arg2="" trim="true" />
</not>
<isset property="target.j2ee" />
<not>
<equals arg1="${target.j2ee}" arg2="" trim="true" />
</not>
<available file="${runtime.projects.to.build}/${deploy.project.name}/${deploy.appl.srv.folder}" type="dir" />
<available file="${runtime.projects.to.build}/${deploy.project.name}/${deploy.appl.srv.folder}/${target.j2ee}" type="dir" />
<resourcecount when="greater" count="0">
<fileset dir="${runtime.projects.to.build}/${deploy.project.name}/${deploy.appl.srv.folder}/${target.j2ee}" />
</resourcecount>
</and>
</condition>
<echo message="appl.srv.project.folder: ${appl.srv.project.folder}" level="verbose" />
</target>
<!-- =================================
target: createDeployJar
================================= -->
<target name="createDeployJar">
<!-- Add the DeployInfo.xml file and replace the token with the actual J2EE target server -->
<copy file="${eclipse.plugins}/${appl.srv.studio.folder}/.misc/config/DeployInfo.xml"
todir="${runtime.projects.to.build}/${deploy.project.name}/bin/config"
overwrite="true" />
<replace file="${runtime.projects.to.build}/${deploy.project.name}/bin/config/DeployInfo.xml" token="%TargetJ2ee%" value="${target.j2ee}" />
<echo message="[DD] earpackager createDeployJar $${output.jars}/$${deploy.project.name}.jar: '${output.jars}/${deploy.project.name}.jar'."/>
<echo message="[DD] earpackager createDeployJar $${runtime.projects.to.build}/$${deploy.project.name}/bin: '${runtime.projects.to.build}/${deploy.project.name}/bin'."/>
<jar destfile="${output.jars}/${deploy.project.name}.jar" keepcompression="true">
<manifest>
<attribute name="Created-By" value="Finantix Studio ${studio.version}" />
<attribute name="Build-Jdk" value="${java.version} ${java.vendor}" />
<attribute name="Built-By" value="L.U.R.Ch - Fx automated build system - ${builder.full.version}" />
<attribute name="Implementation-Title" value="${deploy.project.name}" />
<attribute name="Implementation-Version" value="${project.full.version}" />
<attribute name="Implementation-Vendor" value="${implementation.vendor}" />
</manifest>
<fileset dir="${runtime.projects.to.build}/${deploy.project.name}/bin" />
</jar>
</target>
<!-- =================================
target: generateManifest
================================= -->
<target name="generateManifest" depends="cleanupJarsForEar" description="Generates the manifest files for the war and ejb files">
<propertyregex property="classpath.runtime.patches" input="${deploy.libraries}" regexp="," replace=" lib/" global="true" />
<propertyregex property="classpath.runtime.patches" input="${classpath.runtime.patches}" regexp="(.*)" select="lib/\1" override="true" />
<echo message="classpath.runtime.patches: ${classpath.runtime.patches}" level="verbose" />
<pathconvert property="classpath.other.runtime.patches" pathsep=" ">
<path>
<fileset dir="${project.libraries.folder.path}/${4Ear.patches}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.patches}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4Ear.lib3p}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.lib3p}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4Ear.libJavaPrj}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.libJavaPrj}"
includes="${selectable.required.libraries}"
excludes="${selectable.deploy.libraries}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.other.runtime.patches: ${classpath.other.runtime.patches}" level="verbose" />
<pathconvert property="classpath.generated.bars" pathsep=" ">
<path>
<fileset dir="${output.bars}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.generated.bars: ${classpath.generated.bars}" level="verbose" />
<pathconvert property="classpath.generated.jars" pathsep=" ">
<path>
<fileset dir="${output.jars}" includes="**/*.*" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.generated.jars: ${classpath.generated.jars}" level="verbose" />
<pathconvert property="classpath.not.generated.libs.and.bars" pathsep=" ">
<path>
<fileset dir="${input.ftp.bars}" includes="${required.bars}" excludes="${libs.and.bars.to.exclude}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.not.generated.libs.and.bars: ${classpath.not.generated.libs.and.bars}" level="verbose" />
<pathconvert property="classpath.studio.bars" pathsep=" ">
<path>
<fileset dir="${eclipse.plugins}" includes="${bars.from.fs.plugins}" excludes="${libs2cutoff}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.studio.bars: ${classpath.studio.bars}" level="verbose" />
<pathconvert property="classpath.fs.plugins.4.ear" pathsep=" ">
<path>
<fileset dir="${eclipse.plugins}" includes="${fs.plugins.4.ear}" excludes="${libs2cutoff},${selectable.required.libraries}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<globmapper from="*" to="lib/*" />
</chainedmapper>
</pathconvert>
<echo message="classpath.fs.plugins.4.ear: ${classpath.fs.plugins.4.ear}" level="verbose" />
<!--property name="EARClasspath" value="${classpath.runtime.patches} ${classpath.generated.jars} ${classpath.generated.bars} ${classpath.not.generated.libs.and.bars} ${classpath.other.runtime.patches} ${classpath.studio.bars} ${classpath.studio.plugins} ${classpath.3rd.parties.libs}" /-->
<property name="EARClasspath"
value="${classpath.runtime.patches} ${classpath.generated.jars} ${classpath.generated.bars} ${classpath.not.generated.libs.and.bars} ${classpath.other.runtime.patches} ${classpath.studio.bars} ${classpath.fs.plugins.4.ear}" />
<propertyregex property="EARClasspath" input="${EARClasspath}" regexp="\s+" replace=" " global="true" override="true" />
<echo message="EARClasspath: ${EARClasspath}" level="verbose" />
<manifest file="${output.ears.tmp.war}/META-INF/MANIFEST.MF">
<attribute name="Created-By" value="Finantix Studio ${studio.version}" />
<attribute name="Build-Jdk" value="${java.version} ${java.vendor}" />
<attribute name="Built-By" value="L.U.R.Ch - Fx automated build system - ${builder.full.version}" />
<attribute name="Implementation-Version" value="${project.full.version}" />
<attribute name="Implementation-Vendor" value="${implementation.vendor}" />
<attribute name="Class-Path" value="${EARClasspath}" />
</manifest>
<copy file="${output.ears.tmp.war}/META-INF/MANIFEST.MF" tofile="${output.ears.tmp.ejb}/META-INF/MANIFEST.MF" />
</target>
<!-- =================================
target: cleanupJarsForEar
================================= -->
<target name="cleanupJarsForEar" depends="cleanupBarsForEar" description="Remove java files from the archives to store in the ear.">
<fileset dir="${output.ears.tmp.lib}" id="jar.files.to.update.id">
<include name="*.jar" />
<exclude name="*_bar.jar" />
</fileset>
<echo level="info" message="********* Removing source code from jar files *******" />
<property name="jar.files.to.update" refid="jar.files.to.update.id" />
<for list="${jar.files.to.update}" delimiter=";" param="jar.file">
<sequential>
<echo message="=========================================" />
<echo message=" Updating ${jar.counter} out of ${number.of.jars.to.update} jar files ..." />
<exec executable="7za">
<arg value="d" />
<arg value="-tzip" />
<arg value="${output.ears.tmp.lib}/#{jar.file}" />
<arg value="*.java" />
<arg value="-r" />
</exec>
<math result="jar.counter" operation="+" operand1="${jar.counter}" operand2="1" datatype="int" />
</sequential>
</for>
</target>
<!-- =================================
target: cleanupBarsForEar
================================= -->
<target name="cleanupBarsForEar" depends="moveLibraries" description="Remove useless files from the archives to store in the ear.">
<resourcecount property="number.of.jars.to.update">
<fileset dir="${output.ears.tmp.lib}">
<include name="*.jar" />
</fileset>
</resourcecount>
<echo level="info" message="********* Removing source code, java and dat files from ${number.of.jars.to.update} bar files *******" />
<var name="jar.counter" value="1" />
<fileset dir="${output.ears.tmp.lib}" id="bar.files.to.update.id">
<include name="*_bar.jar" />
</fileset>
<property name="bar.files.to.update" refid="bar.files.to.update.id" />
<for list="${bar.files.to.update}" delimiter=";" param="bar.file">
<sequential>
<echo message="=========================================" />
<echo message=" Updating ${jar.counter} out of ${number.of.jars.to.update} bar files ..." />
<exec executable="7za">
<arg value="d" />
<arg value="-tzip" />
<arg value="${output.ears.tmp.lib}/#{bar.file}" />
<arg value="META-INF/*.dat" />
<arg value="META-INF/.bar" />
<arg value="src" />
<arg value="*.java" />
<arg value="-r" />
</exec>
<math result="jar.counter" operation="+" operand1="${jar.counter}" operand2="1" datatype="int" />
</sequential>
</for>
</target>
<!-- =================================
target: moveLibraries
================================= -->
<target name="moveLibraries" description="Moves files into the lib folder in the temporary ear folder">
<pathconvert property="libs.and.bars.to.exclude" pathsep=",">
<path>
<fileset dir="${output.bars}" />
<fileset dir="${output.jars}" />
</path>
<chainedmapper>
<mapper type="flatten" />
<regexpmapper from="(.*)" to="**/\1" />
</chainedmapper>
</pathconvert>
<propertyregex property="selectable.deploy.libraries" input="${deploy.libraries}" regexp="," replace=",**/" global="true" />
<propertyregex property="selectable.deploy.libraries" input="${selectable.deploy.libraries}" regexp="(.*)" select="**/\1" override="true" />
<propertyregex property="selectable.required.libraries" input="${required.libraries}" regexp="," replace=",**/" global="true" />
<propertyregex property="selectable.required.libraries"
input="${selectable.required.libraries}"
regexp="(.*)"
select="**/\1"
override="true" />
<copy todir="${output.ears.tmp.lib}" flatten="true" failonerror="true">
<fileset dir="${project.libraries.folder.path}/${4Ear.patches}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.patches}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4Ear.lib3p}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.lib3p}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4Ear.libJavaPrj}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${project.libraries.folder.path}/${4EarAndCompiling.libJavaPrj}"
includes="${selectable.deploy.libraries},${selectable.required.libraries}" />
<fileset dir="${output.bars}" />
<fileset dir="${output.jars}" />
<fileset dir="${input.ftp.bars}" includes="${required.bars}" excludes="${libs.and.bars.to.exclude}" />
<fileset dir="${eclipse.plugins}" includes="${bars.from.fs.plugins}" excludes="${libs2cutoff}" />
<fileset dir="${eclipse.plugins}" includes="${fs.plugins.4.ear}" excludes="${libs2cutoff},${selectable.required.libraries}" />
</copy>
</target>
<!-- =================================
target: createEJB
================================= -->
<target name="createEJB">
<copy todir="${output.ears.tmp.ejb}" overwrite="false">
<fileset dir="${eclipse.plugins}/${appl.srv.studio.folder}/${target.j2ee}/EJB" />
</copy>
<antcall target="updateWithCustomFiles">
<param name="destination.folder" value="${output.ears.tmp.ejb}" />
<param name="source.folder" value="${appl.srv.project.folder}/EJB" />
<param name="overwrite" value="true" />
</antcall>
<jar destfile="${output.ears.tmp}/${ejb.name}.jar" basedir="${output.ears.tmp.ejb}" manifest="${output.ears.tmp.ejb}/META-INF/MANIFEST.MF" />
<delete dir="${output.ears.tmp.ejb}" includeEmptyDirs="true" />
</target>
<!-- =================================
target: createWAR
================================= -->
<target name="createWAR">
<copy todir="${output.ears.tmp.war}" overwrite="true">
<fileset dir="${web.project.folder.path}">
<exclude name="work/" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${output.ears.tmp.war}" overwrite="false">
<fileset dir="${eclipse.plugins}/${appl.srv.studio.folder}/${target.j2ee}/WAR" />
</copy>
<antcall target="updateWithCustomFiles">
<param name="destination.folder" value="${output.ears.tmp.war}" />
<param name="source.folder" value="${appl.srv.project.folder}/WAR" />
<param name="overwrite" value="true" />
</antcall>
<for list="${web.project.version.files}" delimiter="," param="web.project.version.file">
<sequential>
<replace file="${output.ears.tmp.war}/#{web.project.version.file}"
token="${web.project.version.token}"
value="${project.full.version}" />
</sequential>
</for>
<antcall target="evaluateWebXmlConditions">
<param name="web.xml.path" value="${output.ears.tmp.war}/WEB-INF/web.xml" />
</antcall>
<war destfile="${output.ears.tmp}/${war.name}.war"
basedir="${output.ears.tmp.war}"
manifest="${output.ears.tmp.war}/META-INF/MANIFEST.MF"
webxml="${output.ears.tmp.war}/WEB-INF/web.xml" />
<delete dir="${output.ears.tmp.war}" includeEmptyDirs="true" />
</target>
<!-- =================================
target: evaluateWebXmlConditions
================================= -->
<target name="evaluateWebXmlConditions">
<loadfile property="web.content" srcFile="${web.xml.path}">
<filterchain>
<tokenfilter>
<filetokenizer />
<replaceregex pattern="<!--.*?-->" flags="gs" replace="" />
</tokenfilter>
</filterchain>
</loadfile>
<condition property="workManagerIsToAdd">
<not>
<contains string="${web.content}" substring="<res-ref-name>wm/WorkManager</res-ref-name>" />
</not>
</condition>
<condition property="ejbTimerIsToAdd">
<not>
<contains string="${web.content}" substring="<ejb-ref-name>ejb/EJBTimerServiceExecutorHome</ejb-ref-name>" />
</not>
</condition>
<antcall target="addWorkManager" />
<antcall target="addEjbTimer" />
</target>
<!-- =================================
target: addWorkManager
================================= -->
<target name="addWorkManager" if="workManagerIsToAdd">
<property name="tab" value=" " />
<replaceregexp file="${web.xml.path}"
match="</servlet-mapping>([^\w>]*)<resource-ref>"
replace="</servlet-mapping>${line.separator}${tab}<resource-ref>${line.separator}${tab}${tab}<!--WorkManager-->${line.separator}${tab}${tab}<description>Required for concurrency support</description>${line.separator}${tab}${tab}<res-ref-name>wm/WorkManager</res-ref-name>${line.separator}${tab}${tab}<res-type>commonj\.work\.WorkManager</res-type>${line.separator}${tab}${tab}<res-auth>Container</res-auth>${line.separator}${tab}${tab}<res-sharing-scope>Shareable</res-sharing-scope>${line.separator}${tab}</resource-ref>${line.separator}${tab}<resource-ref>"
flags="s" />
</target>
<!-- =================================
target: addEjbTimer
================================= -->
<target name="addEjbTimer" if="ejbTimerIsToAdd">
<property name="tab" value=" " />
<replaceregexp file="${web.xml.path}"
match="</web-app>"
replace="${tab}<!--EJB Timer reference -->${line.separator}${tab}<ejb-ref>${line.separator}${tab}${tab}<ejb-ref-name>ejb/EJBTimerServiceExecutorHome</ejb-ref-name>${line.separator}${tab}${tab}<ejb-ref-type>Session</ejb-ref-type>${line.separator}${tab}${tab}<home>com.finantix.foundation.integration.ejbtimer.EJBTimerServiceExecutorHome</home>${line.separator}${tab}${tab}<remote>com.finantix.foundation.integration.ejbtimer.EJBTimerServiceExecutor</remote>${line.separator}${tab}${tab}<ejb-link>EJBTimerServiceExecutor</ejb-link>${line.separator}${tab}</ejb-ref>${line.separator}</web-app>"
flags="s" />
</target>
<!-- =================================
target: createEar
================================= -->
<target name="createEar">
<copy todir="${output.ears.tmp}" overwrite="true">
<fileset dir="${eclipse.plugins}/${appl.srv.studio.folder}/${target.j2ee}/EAR" />
</copy>
<antcall target="updateWithCustomFiles">
<param name="destination.folder" value="${output.ears.tmp}" />
<param name="source.folder" value="${appl.srv.project.folder}/EAR" />
<param name="overwrite" value="true" />
</antcall>
<replace file="${output.ears.tmp}/META-INF/application.xml" token="%ContextRoot%" value="${context.root}" />
<replace file="${output.ears.tmp}/META-INF/application.xml" token="%WARName%" value="${war.name}" />
<replace file="${output.ears.tmp}/META-INF/application.xml" token="%EJBName%" value="${ejb.name}" />
<jar destfile="${output.ears}/${ear.name}.ear" basedir="${output.ears.tmp}">
<manifest>
<attribute name="Created-By" value="Finantix Studio ${studio.version}" />
<attribute name="Build-Jdk" value="${java.version} ${java.vendor}" />
<attribute name="Built-By" value="L.U.R.Ch - Fx automated build system - ${builder.full.version}" />
<attribute name="Implementation-Version" value="${project.full.version}" />
<attribute name="Implementation-Vendor" value="${implementation.vendor}" />
</manifest>
</jar>
<delete dir="${output.ears.tmp}" includeEmptyDirs="true" />
</target>
<!-- =================================
target: updateWithCustomFiles
================================= -->
<target name="updateWithCustomFiles" depends="evaluateCopyConditions" if="copy.is.executable">
<copy todir="${destination.folder}" overwrite="${overwrite}">
<fileset dir="${source.folder}" />
</copy>
</target>
<!-- =================================
target: evaluateCopyConditions
================================= -->
<target name="evaluateCopyConditions">
<condition property="copy.is.executable">
<and>
<isset property="appl.srv.project.folder" />
<available file="${source.folder}" type="dir" />
</and>
</condition>
</target>
<!-- =================================
target: customizeEar
================================= -->
<target name="customizeEar" if="custom.script.path" depends="checkForCustomScript">
<propertyregex property="workspaces.folder.path" input="${project.properties.path}" regexp="(.*?)/[^\\/]*$" select="\1" />
<ant antfile="${custom.script.path}" inheritAll="false">
<property name="ant-contrib.jar.path" value="${librariesFolderPath}/ant-contrib.jar" />
<property name="lurch.libraries.folder.path" value="${librariesFolderPath}" />
<property name="output.ears.folder.path" value="${output.ears}" />
<property name="ear.name" value="${ear.name}" />
<property name="deploy.project.name" value="${deploy.project.name}" />
<property name="studio.version" value="${studio.version}" />
<property name="java.version" value="${java.version}" />
<property name="java.vendor" value="${java.vendor}" />
<property name="builder.full.version" value="${builder.full.version}" />
<property name="project.full.version" value="${project.full.version}" />
<property name="workspaces.folder.path" value="${workspaces.folder.path}" />
<property name="output.bars.folder.path" value="${output.bars}" />
<property name="output.jars.folder.path" value="${output.jars}" />
<property name="output.ddls.folder.path" value="${output.ddls}" />
<property name="output.processes.folder.path" value="${output.processes}" />
<property name="output.translations.folder.path" value="${output.translations}" />
<property name="manifest.properties.file" value="${manifest.properties.file}" />
<propertyset>
<propertyref prefix="${custom.ear.properties.prefix}" />
</propertyset>
</ant>
</target>
<!-- =================================
target: checkForCustomScript
================================= -->
<target name="checkForCustomScript">
<condition property="custom.script.path" value="${lurch.customized.folder.path}/${project.phase.id}/${custom.ear.script}">
<and>
<isset property="project.phase.id" />
<not>
<equals arg1="project.phase.id" arg2="" trim="true" />
</not>
<available file="${lurch.customized.folder.path}/${project.phase.id}/${custom.ear.script}" type="file" />
</and>
</condition>
</target>
'''''''''''''''''''
The file name is FxCONF.xml which needs to be packaged in Deploy JAR.
Please advise how can i change the above code to make sure i include this file while pacaging.
Java is not my specialty, but I believe that to move and use the file (FxConf.xml) you need to add this copy action.
If I understand what you need I think the way is here:
How do I create an EAR file with an ant build including certain files?
Here can be another reference.
https://gist.github.com/mudzot/865511
Are you using ant?
I hope to be more helping than hinder. :)

Zend Server: Application name already exists

we have a problem on our Zend Server during the deployment of an application.
We've set up a virtual host on our Zend Server called "dev.application-7.de".
We are trying to deploy our Zend Framework 2 project over Jenkins to this virtual host. Usually this works well.
But we got the following error in 3 out of 170 builds:
deploy:
[exec] ======================================================================
[exec] The application has thrown an exception!
[exec] ======================================================================
[exec] ZendServerWebApi\Model\Exception\ApiException
[exec] Invalid userAppName parameter: Application name 'application-7' already exists
[exec] 2015-03-13T11:35:12+01:00 ERR (3): Invalid userAppName parameter: Application name 'application-7' already exists<zendServerAPIResponse xmlns="http://www.zend.com/server/api/1.9">
[exec] <requestData>
[exec] <apiKeyName><![CDATA[ZendStudio]]></apiKeyName>
[exec] <method>applicationDeploy</method>
[exec] </requestData>
[exec] <errorData>
[exec] <errorCode>applicationConflict</errorCode>
[exec] <errorMessage><![CDATA[Invalid userAppName parameter: Application name 'application-7' already exists]]></errorMessage>
[exec] </errorData></zendServerAPIResponse>
To fix this problem, we deleted the virtual host and recreated it with the same config mentioned below.
Is there another way to fix the problem?
Further Information
Zend Server Version:
Version 8.0.2, Developer Standard Edition, Development profile
OS Version:
Ubuntu 14.04.1 LTS
Jenkins Version:
1.599
Information about the Virtual-Host:
Type: Zend Server defined
Created at: 27/Feb/2015 8:18:23
Document Root: /usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/
Security: SSL enabled
Certificate File Path /etc/apache2/ssl/dev.application-7.de.crt
Key File Path /etc/apache2/ssl/dev.application-7.de.key
Chain File Path /etc/apache2/ssl/dev.application-7.de.csr
Virtual-Hosts Config:
<VirtualHost *:443>
SetEnv "APP_ENV" "dev"
DocumentRoot "/usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/"
<Directory "/usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/">
Options +Indexes +FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile "/etc/apache2/ssl/dev.application-7.de.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/dev.application-7.de.key"
SSLCertificateChainFile "/etc/apache2/ssl/dev.application-7.de.csr"
ServerName dev.application-7.de:443
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# include the folder containing the vhost aliases for zend server deployment
IncludeOptional "/usr/local/zend/etc/sites.d/https/dev.application-7.de/443/*.conf"
</VirtualHost>
Ant Build File:
<?xml version="1.0" encoding="UTF-8"?>
<project name="application-7-de-2" default="build">
<!-- By default, we assume all tools to be on the $PATH -->
<!-- <property name="toolsdir" value=""/> -->
<!-- Uncomment the following when the tools are in ${basedir}/vendor/bin -->
<!-- <property name="toolsdir" value="${basedir}/vendor/bin/"/> -->
<!-- Uncomment the following when the tools are in a custom path -->
<property name="baseuri" value="https://dev.application-7.de:443"/>
<property name="appname" value="application-7-de"/>
<property name="defaultserver" value="false"/>
<property name="toolsdir" value="/usr/local/zend/bin/"/>
<property name="params" value="APP_ENV=dev"/>
<property name="host" value="http://our-zend-server.de:10081"/>
<property name="key" value="ZendStudio"/>
<property name="secret" value="OUR_SECRET"/>
<target name="build" depends="prepare,composer,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,phpdox,zpk,deploy" description=""/>
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpdox" description=""/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd-ci"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc-ci"/>
</parallel>
</target>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
<delete dir="${basedir}/build/phpdox"/>
<property name="clean.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
<mkdir dir="${basedir}/build/phpdox"/>
<property name="prepare.done" value="true"/>
</target>
<target name="composer" depends="prepare" description="Update dependencies">
<exec executable="${toolsdir}composer" failonerror="true">
<arg value="update"/>
<arg value="--working-dir"/>
<arg path="${basedir}"/>
</exec>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/module">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${toolsdir}phploc">
<arg value="--count-tests" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="phploc-ci" depends="prepare" description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="${basedir}/build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="${basedir}/build/logs/phploc.xml" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="pdepend" depends="prepare" description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpmd" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpmd">
<arg path="${basedir}/module" />
<arg value="text" />
<arg path="${basedir}/build/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci" depends="prepare" description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpmd">
<arg path="${basedir}/module" />
<arg value="xml" />
<arg path="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
<arg path="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="phpcs-ci" depends="prepare" description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcpd">
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpcpd-ci" depends="prepare" description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcpd">
<arg value="--log-pmd" />
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpunit" depends="prepare" description="Run unit tests with PHPUnit">
<exec executable="${toolsdir}phpunit" failonerror="true">
<arg value="--log-junit"/>
<arg value="build/logs/junit.xml"/>
<arg value="--configuration"/>
<arg path="${basedir}/tests/phpunit.xml"/>
</exec>
</target>
<target name="phpdox" depends="phploc-ci,phpcs-ci,phpmd-ci" description="Generate project documentation using phpDox">
<exec executable="${toolsdir}phpdox" dir="${basedir}/build"/>
</target>
<target name="zpk" depends="phpdox">
<exec executable="${toolsdir}zs-client" failonerror="true">
<arg value="packZpk"/>
<arg value="--folder=${basedir}"/>
<arg value="--destination=${basedir}"/>
<arg value="--name=application.zpk"/>
</exec>
</target>
<target name="deploy" depends="zpk">
<exec executable="${toolsdir}zs-client" failonerror="true">
<arg value="installApp"/>
<arg value="--baseUri=${baseuri}"/>
<arg value="--userAppName=${appname}"/>
<arg value="--defaultServer=${defaultserver}"/>
<arg value="--userParams=${params}"/>
<arg value="--zpk=${basedir}/application.zpk"/>
<arg value="--zsurl=${host}"/>
<arg value="--zskey=${key}"/>
<arg value="--zssecret=${secret}"/>
</exec>
</target>
</project>

Having directory reference trouble with Jenkins & Phing

I have set up my first CI environment with Jenkins and Phing and it is mostly running perfectly, though I have a few hiccups I can't resolve. I am constantly having trouble in determining how to reference directories within various parts of my build process, appreciate any thoughts on the below:
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="dev" basedir=".">
<property name="baseDir" value="." />
<property name="resourceDir" value="${baseDir}/resources" />
<property name="srcDir" value="${baseDir}/src" />
<property name="outputDir" value="${baseDir}/build" />
<property name="logDir" value="${baseDir}/build/logs" />
<property name="phpmdRulesets" value="${resourceDir}/phpmd/rulesets" />
<property name="devServer" value="C:\Apache24\htdocs\myProject.com" />
<target name="init">
<mkdir dir="${outputDir}" />
<mkdir dir="${logDir}" />
</target>
<target name="clean">
<delete dir="${devServer}" includeemptydirs="true" verbose="true" failonerror="true" />
<mkdir dir="${devServer}" />
</target>
<target name="test">
<echo msg="Running unit tests" />
<exec executable="phpunit" checkreturn="true">
<arg value="--log-junit=${logDir}/PHPUnit.xml" />
<arg value="--verbose" />
<arg value="--debug" />
<arg value="--coverage-clover=${logDir}/clover.xml" />
<arg path="${baseDir}" />
</exec>
</target>
<target name="build" depends="phpcs, phpmd, phpcpd, phpDox">
<echo msg="Running build" />
<echo msg="Copying files to build directory..." />
<copy todir="${outputDir}">
<fileset dir="${baseDir}">
<include name="**/src/**" />
<include name="**/resources/**" />
</fileset>
</copy>
</target>
<target name="phpcs">
<echo msg="Running phpcs" />
<exec executable="phpcs">
<arg value="--report=checkstyle" />
<arg value="--ignore=${srcDir}/php/Test/*,${srcDir}/php/lib/*" />
<arg value="--report-file=${logDir}/checkstyle.xml" />
<arg path="${srcDir}" />
</exec>
</target>
<target name="phpmd">
<echo msg="Running phpmd" />
<exec executable="phpmd">
<arg path="${srcDir}" />
<arg value="xml" />
<arg value="${phpmdRulesets}/codesize.xml,${phpmdRulesets}/unusedcode.xml,${phpmdRulesets}/naming.xml,${phpmdRulesets}/design.xml" />
<arg value="--reportfile ${logDir}/messdetector.xml" />
<arg value="--exclude ${srcDir}/php/Test/,${srcDir}/php/lib/" />
</exec>
</target>
<target name="phpcpd">
<echo msg="Running phpcpd" />
<exec executable="phpcpd">
<arg value="--log-pmd=${logDir}/phpcpd.xml" />
<arg value="-vvv" />
<arg value="--exclude=${srcDir}/php/Test/,${srcDir}/php/lib/" />
<arg path="${srcDir}" />
</exec>
</target>
<target name="phpDox">
<echo msg="Running phpDox" />
<exec executable="phpdox">
<arg value="${resourceDir}" />
</exec>
</target>
<target name="dev" depends="init, clean, test, build">
<echo msg="Running dev target" />
<copy file="${outputDir}/src/php/index.php" tofile="${devServer}/index.php" />
<copy todir="${devServer}/php">
<fileset dir="${outputDir}/src/php">
<include name="**" />
<exclude name="**/index.php" />
</fileset>
</copy>
<copy todir="${devServer}/api">
<fileset dir="${outputDir}/api/html">
<include name="**" />
</fileset>
</copy>
<copy file="${outputDir}/src/php/lib/phpLogin/index.php" tofile="${devServer}/php/lib/phpLogin/index.php" />
</target>
</project>
Issue 1: phpmd won't output the reportfile yet there are no errors reported in the Jenkins log. Instead it is logging the entire xml to the stdout and reporting it in the Jenkins logs.
myProject > phpmd:
[echo] Running phpmd
Property ${srcDir} => ./src
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${logDir} => ./build/logs
Property ${srcDir} => ./src
Property ${srcDir} => ./src
[exec] Executing command: phpmd ./src xml ./resources/phpmd/rulesets/codesize.xml,./resources/phpmd/rulesets/unusedcode.xml,./resources/phpmd/rulesets/naming.xml,./resources/phpmd/rulesets/design.xml "--reportfile ./build/logs/messdetector.xml" "--exclude ./src/php/Test/,./src/php/lib/" 2>&1
[exec] <?xml version="1.0" encoding="UTF-8" ?>
...
Issue 2: I am unable to get phpDox to exclude certain directories within my source code. Below is my phpdox.xml.
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://phpdox.de/config">
<project name="myProject.com" source="src/php" workdir="build/api/xml">
<collector backend="parser" publiconly="false">
<include mask="*.php" />
<exclude mask="/lib/**" />
</collector>
<generator output="build/api">
<build engine="html" output="html"/>
</generator>
</project>
</phpdox>
Does anyone know the correct exclude mask I can use please? My file structure is:
myProject.com
/build.xml
/phpdox.xml
/src
/php
/lib
Both issues resolved.
Issue 1: Changed the phpmd task to only use arg values and not arg path. Fixed below:
<target name="phpmd">
<echo msg="Running phpmd" />
<exec executable="phpmd">
<arg value="${dir.src}" />
<arg value="xml" />
<arg value="${dir.phpmdRulesets}/codesize.xml,${dir.phpmdRulesets}/unusedcode.xml,${dir.phpmdRulesets}/naming.xml,${dir.phpmdRulesets}/design.xml" />
<arg value="--reportfile" />
<arg value="${dir.logs}/messdetector.xml" />
<arg value="--exclude"/>
<arg value="test,lib" />
</exec>
</target>
Issue 2: Finally got the exclude masks to work. Fixed xml below:
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://phpdox.de/config">
<project name="myProject.com" source="src/app" workdir="build/api/xml">
<collector backend="parser" publiconly="false">
<include mask="*.php" />
<exclude mask="**/*lib*" />
<exclude mask="**/*test*" />
</collector>
<generator output="build/api">
<build engine="html" output="html"/>
</generator>
</project>
</phpdox>

ANT script : how to exclude several files with ASDOC engine

I want to exclude several files (*_include.as) in my source project, to generate ASDOC :
<target name="build-asdoc" depends="manifest">
<delete dir="${asdoc.dir}" />
<mkdir dir="${asdoc.dir}" />
<exec executable="${FLEX_HOME}/bin/asdoc.exe" failonerror="false">
<arg line="-doc-sources '${src.dir}'" />
<arg line="-doc-sources '${lib.dir}'" />
<arg line="-external-library-path '${ivy.cache.dir}/org.puremvc.as3/singlecore/swcs'" />
<arg line="-external-library-path '${ivy.cache.dir}/com.keepcore.calendar/KCCalendar/swcs'" />
<arg line="-external-library-path '${ivy.cache.dir}/org.as3commons/as3commons-lang/swcs'" />
<arg line="-main-title '${asdoc.mainTitle}'" />
<arg line="-window-title '${asdoc.windowTitle}'" />
<arg line="-output '${asdoc.dir}'" />
<arg line="-footer '${asdoc.footer}'" />
<arg line="-exclude-sources ?????" />
</exec>
</target>
Thank you very much,
Regards,
Anthony
Use a fileset and a path convert :
<fileset dir="${src.dir}" id="src.files">
<include name="**/*.cpp"/>
</fileset>
<pathconvert pathsep="," property="excluded.src.files" refid="src.files"/>
Now property ${excluded.src.files} will have your files separated by a space, you can add your own separator etc. according to your program input argument. Then you just pass this with your -exlucde-sources arg to your program and that's it.

Invoking FindBugs from Ant: passing a space-separated list of files to java

I'm trying to invoke FindBugs from inside Ant. In order to control the amount of memory available to FindBugs, I've chosen not to use the ant-task. The problem I have now is that I want to pass a number of jars on the command-line to FindBugs:
java -jar .../findbugs.jar foo.jar bar.jar fie.jar
However, since these jars actually are Eclipse plugins, I don't know the exact name of the jars so I need a way to use a wildcard to obtain the list. This is what I've come up with:
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg pathref="findbugs.input" />
</java>
</target>
However, the findbugs.input pathref is a comma-separated list of jars, and not space-separated as FindBugs wants it. How do I get the list of jars as a space-separated list?
(Is this perhaps easier to do with the FindBugs ant-task. I can't really tell from the documentation.)
Use pathconvert, like this:
<pathconvert pathsep="," property="findbugs.input.csv" refid="findbugs.input"/>
Implementing in the target that you provided, I changed the reference from <arg pathref="findbugs.input" />
to <arg value="${findbugs.input.csv}" />
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<pathconvert pathsep="," property="findbugs.input.csv"
refid="findbugs.input"/>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<echo message="${findbugs.input.csv}" />
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg value="${findbugs.input.csv}" />
</java>
</target>
Use <pathconvert> to convert the path into the proper format, storing it into a property then use <arg value...> instead of <arg pathref...>
You can control the memory from the ant task:
<findbugs jvmargs="-Xms512m -Xmx512m" ...>
...
</findbugs>

Resources