We define each reference in a single line of build.properties, then in build.xml do an amalgamation of the references into different patternsets which have different meanings.
That gives us the flexibility to use some references in the build time classpath, but not include them in the war/ear, and the flexibility to include references in the war/ear which are not part of the build time classpath. Sample script attached, hope it helps. -----Original Message----- From: KARR, DAVID (ATTSI) [mailto:dk0...@att.com] Sent: Wednesday, October 13, 2010 4:05 PM To: Ant Users List Subject: Proper way to translate list of jars from properties file into classpath I have a property defined in my properties file that specifies a list of jar files associated with a particular framework. I'll need to reference all of those jars any time I reference one of them, so I put them in a single property. It currently looks like this: cxf-patches = ${lib}/cxf-xjc-boolean-2.3.0.jar,\ ${lib}/cxf-xjc-bug671-2.3.0.jar,\ ${lib}/cxf-xjc-dv-2.3.0.jar,\ ${lib}/cxf-xjc-ts-2.3.0.jar Where I've defined "lib" in my build.xml before this file is referenced as "${basedir}/lib". At this point, I'm not certain of the elements that I need to get these jars properly referenced in a top-level path element so I can reference it as the classpath for javac. I imagine it involves using the "filelist" element. I tried this: <filelist id="cxfXjcPatch.jars.list" files="${cxf-patches}"/> Then: <path id="build.classpath"> ... <filelist refid="cxfXjcPatch.jars.list"/> ... </path> This doesn't produce anything really useful. It produces very odd results in the final classpath. I'm not going to bother listing it, because I'm sure I'm doing something basically wrong here. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="init" name="projectName"> <!-- read the user property file which will override any properies set in build.properties or branch.properties --> <property file="user.properties"/> <!-- read the branch property file which will override any properies set in build.properties --> <property file="branch.properties"/> <!-- read the base property file --> <property file="build.properties"/> <!-- JARs that are normally included with the container but required to compile --> <!-- A given reference should only be defined in ONE patternset --> <patternset id="container.libraries"> <include name="${foo.jar}"/> </patternset> <!-- Third party dependencies required to build and deploy the application --> <!-- A given reference should only be defined in ONE patternset --> <patternset id="dependent.libraries" > <include name="${foo2.jar}"/> <include name="${foo3.jar}"/> </patternset> <!-- Third party libraries NOT required by the application at buildtime but included the package --> <!-- A given reference should only be defined in ONE patternset --> <patternset id="other.libraries"> <include name="${foo4.jar}"/> <include name="${foo5.jar}"/> <include name="${foo6.jar}"/> </patternset> <!-- Class path used to compile source modules --> <path id="class.prod.path"> <fileset dir="${endorsed.dir}"> <patternset refid="container.libraries" /> </fileset> <fileset dir="${lib.dir}"> <patternset refid="dependent.libraries" /> </fileset> </path> <!-- ****************************************************************** --> <!-- Initialize properties and display debug information about build --> <!-- ****************************************************************** --> <target name="init"> <tstamp> <format property="TODAY_US" pattern="MM/dd/yyyy hh:mm:ss.SSS aa" unit="hour"/> </tstamp> <!-- check for java version and fail build if not the correct version --> <echo message="Java Version: ${java.version}"/> <echo message="Java home: ${java.home}"/> <fail message="Unsupported Java version: ${java.version}. Please make sure the version of the Java compiler is 1.5 (5.0) or greater."> <condition> <not> <or> <contains string="${java.version}" substring="1.5" casesensitive="false" /> <contains string="${java.version}" substring="1.6" casesensitive="false" /> </or> </not> </condition> </fail> </target> <!-- ****************************************************************** --> <!-- Delete any artifacts or directories that will be used by the build --> <!-- ****************************************************************** --> <target name="clean" depends="init"> <delete dir="${target.dir}" quiet="true"/> </target> <!-- ****************************************************************** --> <!-- Create any directories required by the build --> <!-- ****************************************************************** --> <target name="prepare" depends="init"> <mkdir dir="${classes.prod.dir}"/> <mkdir dir="${pub.dir}"/> <mkdir dir="${genSrc.dir}"/> </target> <!-- ****************************************************************** --> <!-- Compile the production material --> <!-- ****************************************************************** --> <target name="compile" depends="init, clean, prepare"> <pathconvert property="javac.class.prod.path" refid="class.prod.path" pathsep=";"/> <echo message="javac classpath is set to [${javac.class.prod.path}]"/> <javac srcdir="${src.dir}" destdir="${classes.prod.dir}" fork="yes" verbose="${javac.verbose}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" target="${javac.jvmTargetVersion}" source="${javac.jvmSourceVersion}" memoryInitialSize="${javac.memoryInitialSize}" memoryMaximumSize="${javac.memoryMaximumSize}" optimize="${javac.optimize}" deprecation="${javac.deprecation}" compiler="${javac.type}"> <classpath refid="class.prod.path"/> </javac> </target> <!-- ****************************************************************** --> <!-- Compile GWT App --> <!-- ****************************************************************** --> <target name="compile.gwt" depends="compile"> <java classname="com.google.gwt.dev.Compiler" fork="yes" failonerror="true" maxmemory="${javac.memoryMaximumSize}"> <classpath> <pathelement path="${src.dir}" /> <pathelement path="${websrc.dir}/WEB-INF/classes" /> <pathelement path="${endorsed.dir}/${foo.jar}" /> <pathelement path="${lib.dir}/${foo2.jar}" /> </classpath> <arg value="-style" /> <arg value="OBFUSCATED" /> <arg value="-logLevel" /> <arg value="INFO" /> <arg value="-war" /> <arg file="${genSrc.dir}" /> <arg value="com.company.gwt.base.BaseModule" /> </java> </target> <!-- ******************************************************************************************** --> <!-- WAR the application --> <!-- ******************************************************************************************** --> <target name="war" depends="compile.gwt"> <war compress="true" destfile="${pub.dir}/${WebAdmin.war}" webxml="${websrc.dir}/WEB-INF/web.xml" duplicate="fail"> <manifest> <attribute name="Created-By" value="${manifest.owner}, ${TODAY_US}"/> <attribute name="Implementation-Version" value="${targetVersion}"/> <attribute name="Implementation-Title" value="${manifest.title}"/> <attribute name="Implementation-Vendor" value="${manifest.vendor}"/> <attribute name="Compiled-Using-JDK-Version" value="${java.runtime.version}"/> <attribute name="Bamboo-Build-Information" value="${buildKey}.${buildNumber}"/> <attribute name="SVN-Repository-Number" value="${custom.svn.revision.number}"/> </manifest> <classes dir="${classes.prod.dir}"> <include name="**/*.class"/> </classes> <classes dir="${src.dir}"> <include name="**/*.properties"/> <include name="**/*.xml"/> <exclude name="gwt_hosted_mode_configuration.properties"/> </classes> <fileset dir="${websrc.dir}"> <exclude name="**/lib/*.jar" /> <exclude name="**/lib/*.dll" /> </fileset> <fileset dir="${genSrc.dir}"> <exclude name="**/lib/*.jar" /> <exclude name="**/lib/*.dll" /> </fileset> <lib dir="${lib.dir}"> <patternset refid="dependent.libraries"/> <patternset refid="other.libraries"/> </lib> </war> </target> <!-- ****************************************************************** --> <!-- Calls all targets in this build script --> <!-- ****************************************************************** --> <target name="all" depends="war"/> </project>
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org