| <!--/******************************************************************************* |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 |
| * which accompanies this distribution. |
| * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| * and the Eclipse Distribution License is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * Ant naming conventions: |
| * - regardless of the actual OS platform,'/' is the directory separator |
| * (Ant will convert as appropriate). |
| * - multi-word properties use periods '.' |
| * - properties ending in .jar define jarfile names only (no path) |
| * - properties ending in .lib are fully qualified jars (path and filename) |
| * - properties ending in .dir are directory paths |
| * - properties ending in .path are path refid names (classpath fragments) |
| * - multi-word targets use hyphens '-' |
| * - targets beginning with test- are reserved for high level test targets, |
| * and are used in test results parsing |
| * - targets typically use the form <action>-<object>-<type> (ie. package-bundle-zip) |
| * - multi-word macros use underscores '_' |
| * - multi-word macro attributes are concatenated |
| * e.g. 'runpathref' |
| * - multi-word tasks (taskdef) names are concatenated |
| * e.g. 'validateconnection' |
| * - OS environment variables are in ALLCAPS and have 'env' as a prefix |
| * e.g. ${env.XXX}. |
| * - Ant properties are lower case. |
| * |
| * Contributors: |
| * eric.gwin - initial API and implementation |
| #******************************************************************************/--> |
| |
| <!--/******************************************************************************* |
| This buildfile looks for a eclipselink.jar file in the current directory, and |
| generates an appropriate ear file for use as a WLS shared library. If the jar |
| does not exist, an attempt to generate one will be attempted (it is assumed |
| that the this file resides at the same location as the primary buildfile for |
| EclipseLink - not necessary, but assumed). |
| #******************************************************************************/--> |
| <project name="wls-shared-lib" default="create-shared-lib-install" basedir="."> |
| <scriptdef name="genImpVersion" language="javascript" manager="javax"> |
| <attribute name="input"/> |
| <attribute name="property"/> |
| <attribute name="newline"/> |
| <![CDATA[ |
| // getting the value |
| input = attributes.get("input"); |
| property = attributes.get("property"); |
| newline = attributes.get("newline"); |
| if (input == null || property == null || newline == null) { |
| self.fail("'input', 'property', and 'newline' attributes must be set."); |
| } |
| if (input.startsWith("${") || input == "" ) { |
| // Set the result of an undefined (unexpanded) or "empty string" variable to 'NA' |
| project.setProperty(attributes.get("property"), "NA"); |
| } |
| else { |
| // Verstion String is displayed just before Qualifier in |
| // "java -jar eclipselink.jar" output |
| // Convert newlines to ',' |
| trimmedInput = input.replace(newline, ','); |
| // Get "endString" Index based on search for last instance of "Build Qualifier" |
| endLastRev = trimmedInput.lastIndexOf(", Build Qualifier"); |
| // Get "beginString" index based upon the last space in the line above the endString index |
| beginLastRev = trimmedInput.lastIndexOf(" ", endLastRev); |
| // Trim the string to not include the leading space, or the end-of-line |
| trimmedInput = trimmedInput.substring(beginLastRev+1, endLastRev); |
| project.setProperty(attributes.get("property"), trimmedInput); |
| } |
| ]]> |
| </scriptdef> |
| |
| <scriptdef name="genSpecVersion" language="javascript" manager="javax"> |
| <attribute name="input"/> |
| <attribute name="property"/> |
| <![CDATA[ |
| // getting the value |
| input = attributes.get("input"); |
| property = attributes.get("property"); |
| if (input == null || property == null) { |
| self.fail("both 'input' and 'property' attributes must be set."); |
| } |
| if (input.startsWith("${") || input == "" ) { |
| // Set the result of an undefined (unexpanded) or "empty string" variable to 'NA' |
| project.setProperty(attributes.get("property"), "NA"); |
| } |
| else { |
| // Trim the string to not include the bugfix or qualifier tokens |
| endLastRev = input.lastIndexOf("."); |
| trimmedInput = input.substring(0, endLastRev); |
| endLastRev = trimmedInput.lastIndexOf("."); |
| trimmedInput = input.substring(0, endLastRev); |
| project.setProperty(attributes.get("property"), trimmedInput); |
| } |
| ]]> |
| </scriptdef> |
| |
| <scriptdef name="genEarnameVersion" language="javascript" manager="javax"> |
| <attribute name="input"/> |
| <attribute name="property"/> |
| <![CDATA[ |
| // getting the value |
| input = attributes.get("input"); |
| property = attributes.get("property"); |
| if (input == null || property == null) { |
| self.fail("both 'input' and 'property' attributes must be set."); |
| } |
| if (input.startsWith("${") || input == "" ) { |
| // Set the result of an undefined (unexpanded) or "empty string" variable to 'NA' |
| project.setProperty(attributes.get("property"), "NA"); |
| } |
| else { |
| // replace "." in version string with "_" |
| project.setProperty(attributes.get("property"), input.replace('.', '_')); |
| } |
| ]]> |
| </scriptdef> |
| |
| <!-- ================================================================================= --> |
| |
| <target name="verify-eclipselink-exist"> |
| <property name="eclipselink.jar" value="eclipselink.jar"/> |
| <condition property="eclipselink.exist"> |
| <available file="${eclipselink.jar}"/> |
| </condition> |
| </target> |
| |
| <target name="generate-eclipselink" unless="eclipselink.exist" depends="verify-eclipselink-exist"> |
| <echo message="EclipseLink jar not found! Building..."/> |
| <condition property="eclipselink.build.file" value="build.xml" |
| else="antbuild.xml"> |
| <available file="build.xml"/> |
| </condition> |
| <ant antfile="${eclipselink.build.file}" dir="." target="build-eclipselink-jar"/> |
| </target> |
| |
| <target name="identify-eclipselink" depends="generate-eclipselink"> |
| <!-- unzip src="${eclipselink.jar}" dest="."> |
| <patternset> |
| <include name="META-INF/MANIFEST.MF"/> |
| </patternset> |
| </unzip --> |
| <java jar="${eclipselink.jar}" outputproperty="implimentation.version" fork="true"/> |
| <!-- echo message="${implimentation.version}"/ --> |
| <genImpVersion input="${implimentation.version}" property="implimentation.version" newline="${line.separator}"/> |
| <genSpecVersion input="${implimentation.version}" property="specification.version"/> |
| <genEarnameVersion input="${implimentation.version}" property="earname.version"/> |
| <echo message="SpecV: '${specification.version}'"/> |
| <echo message="ImpV: '${implimentation.version}'"/> |
| <echo message="EarV: '${earname.version}'"/> |
| </target> |
| |
| <target name="package-wls-shared-lib" depends="prepare-wls-metadata"> |
| <!-- generate Ear file --> |
| <!-- if eclipselink.jar exists, generate ear with "o.e.p:spec version:imp version" --> |
| <jar destfile="${shared-lib.dir}/${wls-shared-lib.name}.ear"> |
| <metainf dir="${metadata.dir}" includes="*.xml"/> |
| <manifest> |
| <attribute name="Extension-Name" value="${wls-shared-lib.base.name}"/> |
| <attribute name="Specification-Version" value="${specification.version}"/> |
| <attribute name="Implementation-Version" value="${implimentation.version}"/> |
| </manifest> |
| <zipfileset dir="." includes="${eclipselink.jar}" prefix="lib"/> |
| </jar> |
| </target> |
| |
| <target name="create-shared-lib-install" depends="package-wls-shared-lib"> |
| <delete file="eclipselink${earname.version}-shared-lib.zip"/> |
| <!-- generate Ear file --> |
| <!-- if eclipselink.jar exists, generate ear with "o.e.p:spec version:imp version" --> |
| <zip destfile="eclipselink${earname.version}-shared-lib.zip"> |
| <zipfileset dir="${shared-lib.dir}" includes="${wls-shared-lib.name}.ear" prefix="shared-lib"/> |
| <zipfileset dir="${shared-lib.dir}" includes="weblogic-application.xml" prefix="application"/> |
| <zipfileset dir="${shared-lib.dir}" includes="README"/> |
| </zip> |
| </target> |
| |
| <!-- ======================================================================================================================================= --> |
| <!-- METADATA GENERATION --> |
| <!-- Ugly so moved to bottom of file --> |
| |
| <target name="prepare-wls-metadata" depends="identify-eclipselink"> |
| <!-- artifact definitions --> |
| <property name="wls-shared-lib.base.name" value="org.eclipse.persistence"/> |
| <property name="wls-shared-lib.name" value="${wls-shared-lib.base.name}${earname.version}-shared-lib"/> |
| |
| <!-- location to generate metadata artifacts --> |
| <property name="shared-lib.dir" value="build/shared-lib"/> |
| <property name="metadata.dir" value="${shared-lib.dir}/etc"/> |
| <delete dir="${shared-lib.dir}"/> |
| <mkdir dir="${metadata.dir}"/> |
| |
| <!-- Create Library Metadata --> |
| <echo file="${metadata.dir}/weblogic-application.xml" append="false"><weblogic-application> |
| <prefer-application-packages> |
| <package-name>org.eclipse.persistence.*</package-name> |
| <package-name>commonj.sdo.*</package-name> |
| </prefer-application-packages> |
| </weblogic-application> |
| </echo> |
| |
| <echo file="${metadata.dir}/application.xml" append="false"><application> |
| <display-name>${wls-shared-lib.name}</display-name> |
| <module> |
| <java></java> |
| </module> |
| </application> |
| </echo> |
| |
| <!-- Create "Application" Metadata --> |
| <echo file="${shared-lib.dir}/weblogic-application.xml" append="false"><?xml version="1.0" encoding="UTF-8"?> |
| <wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.2/weblogic-application.xsd"> |
| <wls:application-param> |
| <wls:param-name>webapp.encoding.default</wls:param-name> |
| <wls:param-value>UTF-8</wls:param-value> |
| </wls:application-param> |
| <wls:library-ref> |
| <wls:library-name>${wls-shared-lib.base.name}</wls:library-name> |
| <wls:specification-version>${specification.version}</wls:specification-version> |
| <wls:implementation-version>${implimentation.version}</wls:implementation-version> |
| <wls:exact-match>true</wls:exact-match> |
| </wls:library-ref> |
| </wls:weblogic-application> |
| </echo> |
| |
| <!-- Create Sharedlib "Install" readme --> |
| <echo file="${shared-lib.dir}/README" append="false"> |
| How to use a different version of EclipseLink than ships with Weblogic in your application |
| ------------------------------------------------------------------------------------------ |
| |
| Put the shared library (the ear in the 'shared-lib' dir) in the ... |
| Package the 'weblogoc-application.xml found in the 'app' dir with your application, and... |
| </echo> |
| </target> |
| |
| </project> |