blob: 772e129449e41e9ec7aecb429784cb332e2b0ee5 [file] [log] [blame]
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="XMLBeans" default="process-resources" basedir="."
xmlns:mvn="antlib:org.apache.maven.artifact.ant"
xmlns:if="ant:if" xmlns:unless="ant:unless">
<property name="build.compiler" value="javac1.8"/>
<property name="jdk.version.source" value="1.8" description="JDK version of source code"/>
<property name="jdk.version.class" value="1.8" description="JDK version of generated class files"/>
<property name="version.base" value="4.0.0"/>
<property name="version.rc" value=""/>
<property name="cases.location" location="src/test/resources"/>
<property name="repository.m2" value="https://repo1.maven.org/maven2"/>
<property environment="ENV"/>
<condition property="isJava8">
<equals arg1="${ant.java.version}" arg2="1.8"/>
</condition>
<scriptdef name="dependency" language="javascript" description="define properties for library dependency">
<attribute name="prefix"/>
<attribute name="artifact"/>
<attribute name="usage"/>
<attribute name="packaging"/>
<attribute name="repo"/>
<attribute name="snapshot"/>
<attribute name="query"/>
<attribute name="target"/>
<![CDATA[
var parts = attributes.get("artifact").split(/:/);
var packaging = attributes.get("packaging") || "jar";
var version = attributes.get("snapshot") || parts[2];
var repo = attributes.get("repo");
if (repo == null) {
repo = project.getProperty("repository.m2");
}
var query = attributes.get("query") || "";
var usageDir = attributes.get("usage");
usageDir = project.getProperty("basedir")+(usageDir.charAt(0) == '/' ? "" : "/lib/")+usageDir;
var jarLoc = usageDir+"/"+(attributes.get("target")||(parts[1]+"-"+parts[2]+"."+packaging));
var urlLoc = repo+"/"+parts[0].replace(/\./g,"/")+"/"+parts[1]+"/"+parts[2]+"/"+
parts[1]+"-"+(attributes.get("snapshot") || parts[2])+"."+packaging+query;
project.setProperty(attributes.get("prefix")+"."+packaging, jarLoc);
project.setProperty(attributes.get("prefix")+".url", urlLoc);
]]>
<!-- TODO: add library to a queue for downloading ... -->
</scriptdef>
<!-- dependencies -->
<!-- <dependency prefix="xml-apis" artifact="xml-apis:xml-apis:1.4.01" usage="main"/>-->
<dependency prefix="saxon" artifact="net.sf.saxon:Saxon-HE:10.1" usage="main"/>
<dependency prefix="ant" artifact="org.apache.ant:ant:1.10.8" usage="main"/>
<dependency prefix="javaparser.core" artifact="com.github.javaparser:javaparser-core:3.15.21" usage="main"/>
<!-- previous xmlbeans version is used to bootstrap necessary schema bindings -->
<dependency prefix="old.xmlbeans" artifact="org.apache.xmlbeans:xmlbeans:3.1.0" usage="previous"/>
<!-- Apache RAT license check properties -->
<property name="rat.reportdir" value="build/rat"/>
<property name="rat.report" value="${rat.reportdir}/report.txt"/>
<dependency prefix="rat" artifact="org.apache.rat:apache-rat:0.12" usage="util"/>
<!-- api checks -->
<dependency prefix="forbidden" artifact="de.thetaphi:forbiddenapis:2.6" usage="util"/>
<!-- test dependencies -->
<dependency prefix="junit" artifact="junit:junit:4.13" usage="tests"/>
<dependency prefix="ant-junit" artifact="org.apache.ant:ant-junit:1.10.8" usage="tests"/>
<dependency prefix="ant-junit4" artifact="org.apache.ant:ant-junit4:1.10.8" usage="tests"/>
<dependency prefix="hamcrest" artifact="org.hamcrest:hamcrest:2.2" usage="tests"/>
<dependency prefix="xerces" artifact="xerces:xercesImpl:2.12.0" usage="tests"/>
<path id="xmlbeans-test">
<pathelement location="build/classes"/>
<pathelement location="build/generated-resources"/>
<dirset dir="src/main/resources" includes="*" excludes="maven"/>
<pathelement location="${ant.jar}"/>
<pathelement location="${ant-junit.jar}"/>
<pathelement location="${ant-junit4.jar}"/>
<pathelement location="${saxon.jar}"/>
<pathelement location="test/lib/w3c_domts.jar"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
<pathelement location="${xerces.jar}"/>
<!-- <pathelement location="${xml-apis.jar}"/>-->
<pathelement location="${javaparser.core.jar}"/>
</path>
<path id="sources">
<pathelement location="src/main/java"/>
<!-- the next sources depend on the oldxbean.jar -->
<pathelement location="build/generated-sources"/>
</path>
<target name="usage" description="Shows the projecthelp">
<java classname="org.apache.tools.ant.Main">
<arg value="-projecthelp" />
</java>
</target>
<target name="clean" description="Cleans out the xbeans directories">
<delete dir="build"/>
</target>
<target name="-check-jars" description="Removes old dependencies and verifies downloaded ones">
<!-- remove previous versions of third-party jars to prevent them from lingering around,
we often had hard-to-find build/CI-problems because of these! -->
<delete dir="compile-lib"/>
<condition property="jars.present">
<or>
<and>
<available file="${old.xmlbeans.jar}"/>
<available file="${javaparser.core.jar}"/>
<available file="${saxon.jar}"/>
<available file="${junit.jar}"/>
<available file="${hamcrest.jar}"/>
<available file="${xerces.jar}"/>
<!-- <available file="${xml-apis.jar}"/>-->
<available file="${ant.jar}"/>
<available file="${ant-junit.jar}"/>
<available file="${ant-junit4.jar}"/>
</and>
<isset property="disconnected"/>
</or>
</condition>
</target>
<macrodef name="downloadfile">
<attribute name="src"/>
<attribute name="dest"/>
<sequential>
<local name="destdir"/>
<dirname property="destdir" file="@{dest}"/>
<mkdir dir="${destdir}"/>
<get src="@{src}" dest="@{dest}" skipexisting="true"/>
</sequential>
</macrodef>
<target name="-fetch-jars" depends="-check-jars" unless="jars.present"
description="Fetches needed JAR files from the Internet">
<downloadfile dest="${old.xmlbeans.jar}" src="${old.xmlbeans.url}"/>
<downloadfile dest="${javaparser.core.jar}" src="${javaparser.core.url}"/>
<downloadfile dest="${saxon.jar}" src="${saxon.url}"/>
<downloadfile dest="${junit.jar}" src="${junit.url}"/>
<downloadfile dest="${hamcrest.jar}" src="${hamcrest.url}"/>
<downloadfile dest="${xerces.jar}" src="${xerces.url}"/>
<!-- <downloadfile dest="${xml-apis.jar}" src="${xml-apis.url}"/>-->
<downloadfile dest="${ant.jar}" src="${ant.url}"/>
<downloadfile dest="${ant-junit.jar}" src="${ant-junit.url}"/>
<downloadfile dest="${ant-junit4.jar}" src="${ant-junit4.url}"/>
</target>
<macrodef name="schemaComp">
<attribute name="schemaName"/>
<attribute name="src"/>
<attribute name="dest"/>
<attribute name="classpathref"/>
<sequential>
<local name="srcDir"/>
<local name="rscDir"/>
<local name="up2date"/>
<property name="srcDir" location="@{dest}/generated-sources"/>
<property name="rscDir" location="@{dest}/generated-resources"/>
<mkdir dir="${srcDir}"/>
<mkdir dir="${rscDir}"/>
<uptodate property="up2date" targetfile="${rscDir}/org/apache/xmlbeans/system/@{schemaName}/TypeSystemHolder.class">
<srcresources>
<filelist dir="${basedir}" files="@{src}"/>
</srcresources>
</uptodate>
<java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler" fork="true" failonerror="true" classpathref="@{classpathref}" unless:true="${up2date}">
<jvmarg value="-ea"/>
<arg line="-name @{schemaName} -srconly -noann -d ${rscDir} -src ${srcDir} @{src}"/>
</java>
</sequential>
</macrodef>
<macrodef name="replaceHolder">
<attribute name="srcDir"/>
<attribute name="rscDir"/>
<attribute name="schemaName"/>
<sequential>
<!-- if replaceHolder: copy TypeSystemHolder and replace package name, then compile -->
<mkdir dir="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}"/>
<copy file="src/main/java/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java" todir="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}">
<filterchain>
<replacestring from="package org.apache.xmlbeans.impl.schema" to="package org.apache.xmlbeans.metadata.system.@{schemaName}"/>
</filterchain>
</copy>
<javac destdir="@{rscDir}"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<src path="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}"/>
<classpath>
<pathelement location="${old.xmlbeans.jar}"/>
</classpath>
</javac>
</sequential>
</macrodef>
<macrodef name="schemaCompProd">
<attribute name="classpathref"/>
<attribute name="dest"/>
<sequential>
<schemaComp schemaName="sXMLLANG" src="src/main/schema/xml" dest="@{dest}" classpathref="@{classpathref}"/>
<schemaComp schemaName="sXMLSCHEMA" src="src/main/schema/xsd" dest="@{dest}" classpathref="@{classpathref}"/>
<schemaComp schemaName="sXMLCONFIG" src="src/main/schema/config" dest="@{dest}" classpathref="@{classpathref}"/>
<schemaComp schemaName="sXMLTOOLS" src="src/main/schema/tools" dest="@{dest}" classpathref="@{classpathref}"/>
</sequential>
</macrodef>
<target name="process-resources" depends="-fetch-jars" description="Generate sources and resources based on schema files">
<!-- Note that this is tricky because it bootstraps xmlbeans on itself. -->
<!-- The basic strategy is to rely on the oldxbeans.jar checked into lib -->
<path id="oldxbean">
<pathelement location="${old.xmlbeans.jar}"/>
</path>
<schemaCompProd classpathref="oldxbean" dest="build/bootstrap"/>
<move file="build/bootstrap/generated-resources/schemaorg_apache_xmlbeans" tofile="build/bootstrap/generated-resources/org/apache/xmlbeans/metadata"/>
<replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources" schemaName="sXMLLANG"/>
<replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources" schemaName="sXMLSCHEMA"/>
<replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources" schemaName="sXMLCONFIG"/>
<replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources" schemaName="sXMLTOOLS"/>
<replace dir="build/bootstrap/generated-sources" token="schemaorg_apache_xmlbeans" value="org.apache.xmlbeans.metadata" includes="**/*.java"/>
<mkdir dir="build/classes"/>
<mkdir dir="build/generated-sources"/>
<javac destdir="build/classes"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<src refid="sources"/>
<src path="build/bootstrap/generated-sources"/>
<classpath>
<path refid="oldxbean"/>
<pathelement location="${ant.jar}"/>
<pathelement location="${ant-junit.jar}"/>
<pathelement location="${ant-junit4.jar}"/>
<pathelement location="${saxon.jar}"/>
<pathelement location="${javaparser.core.jar}"/>
</classpath>
</javac>
<mkdir dir="build/generated-resources/org/apache/xmlbeans/impl/schema"/>
<!-- need to provide the template also in classes - generated-resources will be ignored on bootstrapping -->
<move file="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.class"
tofile="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"/>
<copy file="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"
todir="build/generated-resources/org/apache/xmlbeans/impl/schema"/>
<!-- now generate new xmlbeans re-/sources and remove the traces of the oldxbean generated re-/sources -->
<path id="oldschemas">
<pathelement location="${ant.jar}"/>
<pathelement location="${ant-junit.jar}"/>
<pathelement location="${ant-junit4.jar}"/>
<pathelement location="build/classes"/>
<pathelement location="build/bootstrap/generated-resources"/>
<dirset dir="src/main/resources" includes="*" excludes="maven"/>
</path>
<schemaCompProd classpathref="oldschemas" dest="build"/>
<!-- delete old schema classes -->
<delete dir="build/classes/org/apache/xmlbeans/impl/xb"/>
</target>
<target name="compile" depends="process-resources" description="Compile sources and resources">
<!-- delete old schema classes -->
<delete dir="build/classes/org/apache/xmlbeans/impl/xb"/>
<javac destdir="build/classes"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<src refid="sources"/>
<classpath path="${saxon.jar}"/>
</javac>
<mkdir dir="build/classes/META-INF/versions/9"/>
<javac release="9"
srcdir="${basedir}/src/main/multimodule/java9"
destdir="build/classes/META-INF/versions/9"
includeantruntime="false"
fork="true"
modulepath="lib/main"
unless:true="${isJava8}">
<compilerarg line="--patch-module org.apache.xmlbeans=build/classes"/>
</javac>
</target>
<!-- Run this target before you open the project in an IDE. -->
<target name="process-test-resources" depends="compile"
description="Generate test sources and resources based on schema files.">
<mkdir dir="build/tmp"/>
<mkdir dir="build/test-classes"/>
<mkdir dir="build/test-results"/>
<!-- extensions currently deactivated - it generates duplicated methods -->
<!--
<pathconvert property="extensions-dir" pathsep=" ">
<path>
<dirset dir="test/src/xmlobject/extensions/" includes="interfaceFeature/*,prePostFeature/readOnlyBean"/>
<dirset dir="${cases.location}/xbean/extensions/" includes="interfaceFeature/*,prePostFeature/readOnlyBean"/>
</path>
</pathconvert>
<schemaComp schemaName="sEXTENSIONS" src="${extensions-dir}" dest="build/test-extensions" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sEXTENSIONS2" src="${cases.location}/xbean/extensions/prePostFeature/ValueRestriction test/src/xmlobject/extensions/prePostFeature/ValueRestriction" dest="build/test-extensions" classpathref="xmlbeans-test"/>
-->
<untar src="${cases.location}/xbean/tranxml.tar.bz2" dest="build/test-tranxml/schemas" compression="bzip2" overwrite="false">
<patternset>
<include name="tranxml/Version4.0/schemas/StandAlone/CarLocationMessage_40_LX.xsd"/>
</patternset>
<mapper type="flatten"/>
</untar>
<schemaComp schemaName="sTRAN" src="build/test-tranxml/schemas" dest="build/test-tranxml" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sTOOLS" src="test/tools/lib/xsl" dest="build/test-tools" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sXMLCURSOR" src="${cases.location}/xbean/xmlcursor" dest="build/test-xmlcursor" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sDOM" src="${cases.location}/xbean/dom" dest="build/test-dom" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sSCOMP" src="${cases.location}/xbean/scomp" dest="build/test-scomp" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sSIMPLE" src="${cases.location}/xbean/simple" dest="build/test-simple" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sVALIDATE" src="${cases.location}/xbean/ValidatingStream" dest="build/test-validate" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sUSERTYPE" src="${cases.location}/xbean/usertype" dest="build/test-usertype" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sLAX" src="${cases.location}/xbean/compile/scomp/detailed" dest="build/test-lax" classpathref="xmlbeans-test"/>
<pathconvert property="xmlobjects" pathsep=" ">
<path>
<fileset dir="${cases.location}/xbean/xmlobject">
<include name="CR192525.xsd"/>
<include name="defaults.xsd"/>
<include name="easypo.xsd*"/>
<include name="enumtest.xsd*"/>
<include name="inttest.xsd"/>
<include name="listandunion.xsd"/>
<include name="nameworld.xsd"/>
<include name="numerals.xsd"/>
<include name="redefine2.xsd"/>
<include name="SelectAttribute.xsd"/>
<include name="SelectChildren.xsd"/>
<include name="selectChldAttTest.xsd"/>
<include name="soap-envelope.xsd"/>
<include name="soapfaults.xsd"/>
<include name="substgroup.xsd"/>
<include name="substgroup2.xsd"/>
<include name="Test.xsd"/>
<include name="Test36510.xsd"/>
<include name="Test40907.xsd"/>
<include name="version3.xsd"/>
</fileset>
</path>
</pathconvert>
<schemaComp schemaName="sXMLOBJECT" src="${xmlobjects}" dest="build/test-xmlobject" classpathref="xmlbeans-test"/>
<pathconvert property="miscs" pathsep=" ">
<path>
<fileset dir="${cases.location}/xbean/misc/jira">
<include name="xmlbeans_33b.xsd"/>
<include name="xmlbeans_46.xsd"/>
<include name="xmlbeans_48.xsd"/>
<include name="xmlbeans_64.xsd"/>
<include name="xmlbeans_68.xsd"/>
<include name="xmlbeans_71.xsd"/>
<include name="xmlbeans_98.xsd"/>
<include name="xmlbeans_99*.xsd"/>
<include name="xmlbeans_105.xsd"/>
<include name="xmlbeans_175.xsd"/>
<include name="xmlbeans_177*.xsd"/>
<include name="xmlbeans_208.xsd"/>
<include name="xmlbeans_228.xsd"/>
<include name="xmlbeans_307_maxallowedenum.xsd"/>
<include name="xmlbeans_307_morethanallowedenum.xsd"/>
</fileset>
<pathelement location="${cases.location}/xbean/xmltokensource"/>
</path>
</pathconvert>
<schemaComp schemaName="sMISC" src="${miscs}" dest="build/test-misc" classpathref="xmlbeans-test"/>
<!-- don't include in normal test classpath -->
<schemaComp schemaName="sSYSCACHE" src="${cases.location}/xbean/misc/syscachetest1.xsd" dest="build/test-syscache/1" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sSYSCACHE" src="${cases.location}/xbean/misc/syscachetest2.xsd" dest="build/test-syscache/2" classpathref="xmlbeans-test"/>
</target>
<target name="test-compile" depends="process-test-resources" description="Compile test sources and resources">
<javac destdir="build/test-classes"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
classpathref="xmlbeans-test"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<classpath>
<dirset dir="build" includes="test-*/generated-resources"/>
</classpath>
<src path="src/test/java"/>
<src>
<dirset dir="build" includes="test-*/generated-sources"/>
</src>
<exclude name="**/extensions/**"/>
<exclude name="**/drt/**"/>
</javac>
<mkdir dir="build/test-syscache/1/classes"/>
<javac destdir="build/test-syscache/1/classes"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
classpathref="xmlbeans-test"
srcdir="build/test-syscache/1/generated-sources"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<classpath location="build/test-syscache/1/generated-resources"/>
</javac>
<mkdir dir="build/test-syscache/2/classes"/>
<javac destdir="build/test-syscache/2/classes"
debug="true"
debuglevel="lines,vars,source"
includeantruntime="false"
classpathref="xmlbeans-test"
srcdir="build/test-syscache/2/generated-sources"
target="${jdk.version.class}"
source="${jdk.version.source}"
>
<classpath location="build/test-syscache/2/generated-resources"/>
</javac>
</target>
<target name="test" depends="test-compile" description="Run the tests">
<junit printsummary="yes" showoutput="no" haltonerror="true" haltonfailure="true" includeantruntime="false" fork="true">
<classpath refid="xmlbeans-test"/>
<classpath>
<pathelement location="${cases.location}"/>
<pathelement location="build/test-classes"/>
<dirset dir="build" includes="test-*/generated-resources"/>
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg value="-Xmx256m"/>
<jvmarg value="-Djava.io.tmpdir=${basedir}/build/tmp"/>
<!-- For tests that need to access case files directly -->
<sysproperty key="cases.location" path="${basedir}/src/test/resources"/>
<sysproperty key="xbean.rootdir" path="${basedir}"/>
<batchtest fork="yes" todir="build/test-results">
<fileset dir="src/test/java">
<include name="**/*Tests.java"/>
<include name="**/*Test.java"/>
<exclude name="**/extensions/**"/>
<exclude name="**/drt/**"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="javadocs" description="Build the javadocs.">
<property name="javadocs.dir" value="build/javadocs"/>
<delete dir="${javadocs.dir}"/>
<mkdir dir="${javadocs.dir}"/>
<!-- force Java 8 source compatibility - see https://stackoverflow.com/questions/56409697 -->
<javadoc sourcepathref="sources"
destdir="${javadocs.dir}"
windowtitle="XMLBeans ${version.base} Documentation"
source="8">
<classpath>
<pathelement location="build/classes"/>
<fileset dir="lib/main" includes="*.jar"/>
</classpath>
<excludepackage name="org.apache.xmlbeans.impl.repackage.*"/>
<excludepackage name="org.apache.xmlbeans.impl.xb.*"/>
<link href="https://docs.oracle.com/javase/9/docs/api/"/>
<!-- <link href="https://javadoc.io/doc/xml-apis/xml-apis/1.4.01/"/>-->
<link href="https://javadoc.io/doc/com.github.javaparser/javaparser-core/3.15.21"/>
<link href="https://ant.apache.org/manual/api/"/>
</javadoc>
</target>
<target name="package" depends="compile,javadocs" description="Builds our jars in the build directory">
<jar jarfile="build/xmlbeans-${version.base}.jar" update="false" index="true">
<fileset dir="build/classes" excludes="org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"/>
<fileset dir="." includes="LICENSE.txt,NOTICE.txt"/>
<fileset dir="build/generated-resources"/>
<mappedresources>
<fileset dir="src/main/resources" excludes="maven"/>
<cutdirsmapper dirs="1"/>
</mappedresources>
<manifest>
<attribute name="Multi-Release" value="true"/>
<section name="org/apache/xmlbeans/">
<attribute name="Comment" value="Apache XmlBeans version ${version.base}"/>
<attribute name="Implementation-Title" value="org.apache.xmlbeans"/>
<attribute name="Implementation-Version" value="${version.base}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-URL" value="https://xmlbeans.apache.org/"/>
</section>
</manifest>
</jar>
<jar jarfile="build/xmlbeans-${version.base}-javadoc.jar" update="false" index="false">
<fileset dir="." includes="LICENSE.txt,NOTICE.txt,docs/**"/>
<fileset dir="build/javadocs"/>
<manifest>
<section name="org/apache/xmlbeans/">
<attribute name="Comment" value="Apache XmlBeans version ${version.base} - Javadocs"/>
<attribute name="Implementation-Title" value="org.apache.xmlbeans"/>
<attribute name="Implementation-Version" value="${version.base}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-URL" value="https://xmlbeans.apache.org/"/>
</section>
</manifest>
</jar>
<chainedmapper id="src-mapper">
<cutdirsmapper dirs="1"/>
<firstmatchmapper>
<globmapper from="schema/*" to="org/apache/xmlbeans/src/*"/>
<identitymapper />
</firstmatchmapper>
</chainedmapper>
<jar jarfile="build/xmlbeans-${version.base}-sources.jar" update="false" index="false" duplicate="preserve">
<fileset dir="." includes="LICENSE.txt,NOTICE.txt"/>
<fileset dir="src/main/java"/>
<fileset dir="build/generated-sources"/>
<!--
<mappedresources>
<fileset dir="src" excludes="toolschema/**,shell/**"/>
<mapper refid="src-mapper"/>
</mappedresources>
<zipfileset dir="src/toolschema" prefix="org/apache/xmlbeans/src" excludes="**/*.xsd"/>
<mappedresources>
<fileset dir="build" includes="generated-sources/**,generated-resources/**" excludes="**/*.xsb,**/*.class"/>
<mapper refid="src-mapper"/>
</mappedresources>
-->
<manifest>
<section name="org/apache/xmlbeans/">
<attribute name="Comment" value="Apache XmlBeans version ${version.base} - Sources"/>
<attribute name="Implementation-Title" value="org.apache.xmlbeans"/>
<attribute name="Implementation-Version" value="${version.base}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-URL" value="https://xmlbeans.apache.org/"/>
</section>
</manifest>
</jar>
<tstamp>
<format property="tstamp.dist" pattern="yyyyMMdd"/>
</tstamp>
<property name="prefix" value="xmlbeans-${version.base}"/>
<zip destfile="build/xmlbeans-src-${version.base}-${tstamp.dist}.zip" update="false">
<zipfileset dir="." excludes="build/**,tmp/**,.idea/**,bin/**,lib/**,/src/main/shell/**,.settings/**,.project,build.javacheck.xml,release-guide.txt" prefix="${prefix}"/>
<zipfileset dir="src/main/shell" prefix="${prefix}/bin" />
<zipfileset dir="build/javadocs" prefix="${prefix}/javadocs" />
</zip>
<tar destfile="build/xmlbeans-src-${version.base}-${tstamp.dist}.tgz" compression="gzip" longfile="posix">
<tarfileset dir="." excludes="build/**,tmp/**,.idea/**,bin/**,lib/**,/src/main/shell/**,.settings/**,.project,build.javacheck.xml,release-guide.txt" prefix="${prefix}"/>
<tarfileset dir="src/main/shell" prefix="${prefix}/bin" />
<tarfileset dir="build/javadocs" prefix="${prefix}/javadocs" />
</tar>
<zip destfile="build/xmlbeans-bin-${version.base}-${tstamp.dist}.zip" update="false">
<zipfileset dir="." includes="LICENSE.txt,NOTICE.txt,docs/**" prefix="${prefix}"/>
<zipfileset dir="samples" includes="Any/**,DateTime/**,MixedContent/**,OrderMatters/**,SchemaEnum/**,Validation/**,XQueryXPath/**,XsdConfig/**" prefix="${prefix}/samples"/>
<zipfileset dir="src/main/shell" prefix="${prefix}/bin"/>
<zipfileset dir="xkit" prefix="${prefix}"/>
<zipfileset dir="src/main/schema/xsd" includes="*.xsd" prefix="${prefix}/schemas/s4s"/>
<zipfileset dir="src/main/schema/xml" includes="*.xsd" prefix="${prefix}/schemas/s4s"/>
<zipfileset dir="${cases.location}/xbean/xmlobject" includes="numerals.xsd,easypo.xsd*,nameworld.xsd" prefix="${prefix}/schemas"/>
<zipfileset dir="build" prefix="${prefix}/lib">
<include name="xmlbeans-${version.base}.jar"/>
<include name="xmlbeans-${version.base}-javadoc.jar"/>
<include name="xmlbeans-${version.base}-sources.jar"/>
</zipfileset>
</zip>
<tar destfile="build/xmlbeans-bin-${version.base}-${tstamp.dist}.tgz" compression="gzip" longfile="posix">
<tarfileset dir="." includes="LICENSE.txt,NOTICE.txt,docs/**" prefix="${prefix}"/>
<tarfileset dir="samples" includes="Any/**,DateTime/**,MixedContent/**,OrderMatters/**,SchemaEnum/**,Validation/**,XQueryXPath/**,XsdConfig/**" prefix="${prefix}/samples"/>
<tarfileset dir="src/main/shell" prefix="${prefix}/bin"/>
<tarfileset dir="xkit" prefix="${prefix}"/>
<tarfileset dir="src/main/schema/xsd" includes="*.xsd" prefix="${prefix}/schemas/s4s"/>
<tarfileset dir="src/main/schema/xml" includes="*.xsd" prefix="${prefix}/schemas/s4s"/>
<tarfileset dir="${cases.location}/xbean/xmlobject" includes="numerals.xsd,easypo.xsd*,nameworld.xsd" prefix="${prefix}/schemas"/>
<tarfileset dir="build" prefix="${prefix}/lib">
<include name="xmlbeans-${version.base}.jar"/>
<include name="xmlbeans-${version.base}-javadoc.jar"/>
<include name="xmlbeans-${version.base}-sources.jar"/>
</tarfileset>
</tar>
</target>
<!-- spot any files which are missing the correct license headers -->
<target name="rat-check" description="Runs the Apache Creadur Rat check against the source code">
<mkdir dir="${rat.reportdir}" />
<downloadfile src="${rat.url}" dest="${rat.jar}"/>
<typedef resource="org/apache/rat/anttasks/antlib.xml"
uri="antlib:org.apache.rat.anttasks"
classpath="${rat.jar}" />
<rat:report xmlns:rat="antlib:org.apache.rat.anttasks" reportFile="${rat.report}">
<fileset dir="src/">
<exclude name="main/resources/**/META-INF/services/**"/>
<exclude name="**/*.iml" />
<exclude name="**/XML.xsd"/>
<exclude name="**/XMLSchema.xsd"/>
<exclude name="**/zvon*.xml"/>
<exclude name="**/xmldsig-core-schema.xsd"/>
<exclude name="test/resources/xbean/xmlobject/japanese/**"/>
<exclude name="test/resources/xbean/compile/scomp/j2ee/**"/>
<exclude name="test/resources/xbean/dom/W3C/level2/core/files/**"/>
<exclude name="test/resources/xbean/xmlobject/soap-envelope.xsd"/>
<exclude name="test/resources/xbean/xmlobject/soap12-encoding.xsd"/>
</fileset>
</rat:report>
<!-- remove clutter to compact build output -->
<!-- replaceregexp doesn't work within loadfile ... -->
<replaceregexp file="${rat.report}" match="\s+Printing headers for files without AL header.++" replace="" flags="s"/>
<loadfile property="rat.reportcontent" srcFile="${rat.report}">
<filterchain>
<linecontainsregexp negate="true">
<regexp pattern="^\s+(AL|B|N)\s+"/>
</linecontainsregexp>
</filterchain>
</loadfile>
<echo>${rat.reportcontent}</echo>
<!-- fail the build if at least one note is in the report -->
<fail><condition><matches pattern="[1-9][0-9]* Unknown Licens" string="${rat.reportcontent}"/></condition></fail>
</target>
<!-- spot any cases where we've accidently used methods we shouldn't -->
<!-- See https://github.com/policeman-tools/forbidden-apis for details of the checks that this can do -->
<target name="forbidden-apis-check"
description="Runs the Forbiddens APIs checker against the source code">
<downloadfile src="${forbidden.url}" dest="${forbidden.jar}"/>
<taskdef name="forbiddenapis"
classname="de.thetaphi.forbiddenapis.ant.AntTask"
classpath="${forbidden.jar}"/>
<path id="forbiddenapis.classpath">
<path refid="xmlbeans-test"/>
<path path="${ant.jar}"/>
</path>
<!-- first check rules that apply to all the source code -->
<forbiddenapis
suppressAnnotation="org.apache.poi.util.SuppressForbidden"
targetVersion="${ant.build.javac.target}"
classpathref="forbiddenapis.classpath"
>
<bundledsignatures name="jdk-unsafe"/>
<bundledsignatures name="jdk-deprecated"/>
<bundledsignatures name="jdk-internal"/>
<bundledsignatures name="jdk-non-portable"/>
<bundledsignatures name="jdk-reflection"/>
<!-- sources -->
<fileset dir="build/classes"/>
</forbiddenapis>
</target>
<!-- forbidden-apis-check is currently not included as it is still failing... -->
<target name="jenkins"
depends="test,package,rat-check"
description="Combines all targets that are executed in CI runs"/>
<available property="maven.ant.tasks.present" classname="org.apache.maven.artifact.ant.Pom"/>
<target name="maven.ant.tasks-check">
<fail unless="maven.ant.tasks.present">
Maven ant tasks not found.
Please make sure the maven-ant-tasks jar is in ANT_HOME/lib, or made
available to Ant using other mechanisms like -lib or CLASSPATH.
You can download the Maven Ant Tasks from https://maven.apache.org/ant-tasks/download.html
</fail>
</target>
<target name="mvn-install" depends="maven.ant.tasks-check,package" description="Install XmlBeans artifacts into the local repository. Equivalent of 'mvn install'">
<copy file="${basedir}/main/resources/maven/pom.xml" todir="${basedir}/build" filtering="true">
<filterset>
<filter token="VERSION" value="${version.base}"/>
</filterset>
</copy>
<mvn:install file="${basedir}/build/xmlbeans-${version.base}.jar">
<pom file="${basedir}/build/pom.xml"/>
<attach file="${basedir}/build/xmlbeans-${version.base}-sources.jar" type="jar" classifier="sources"/>
<attach file="${basedir}/build/xmlbeans-${version.base}-javadoc.jar" type="jar" classifier="javadoc"/>
</mvn:install>
</target>
</project>