blob: 49ea7dda112783013071a746f1bf514789af65e9 [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="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="compile.debug" value="true"/>
<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">
<javaversion exactly="1.8"/>
</condition>
<macrodef name="dependency">
<attribute name="prefix"/>
<attribute name="artifact"/>
<attribute name="usage"/>
<attribute name="packaging" default="jar"/>
<attribute name="repo" default="${repository.m2}"/>
<attribute name="snapshot" default=""/>
<attribute name="query" default=""/>
<attribute name="target" default=""/>
<attribute name="url" default=""/>
<sequential>
<local name="groupDir"/>
<loadresource property="groupDir">
<string>@{artifact}</string>
<filterchain>
<replaceregex pattern="([^:]+).*" replace="\1"/>
<replaceregex pattern="\." replace="/" flags="g"/>
</filterchain>
</loadresource>
<local name="artifactId"/>
<loadresource property="artifactId">
<string>@{artifact}</string>
<filterchain>
<replaceregex pattern="[^:]+:([^:]+).*" replace="\1"/>
</filterchain>
</loadresource>
<local name="versionDir"/>
<loadresource property="versionDir">
<string>@{artifact}</string>
<filterchain>
<replaceregex pattern="[^:]+:[^:]+:(.*)" replace="\1"/>
</filterchain>
</loadresource>
<local name="version"/>
<property name="version" value="${versionDir}" if:blank="@{snapshot}"/>
<property name="version" value="@{snapshot}"/>
<local name="usageDir"/>
<loadresource property="usageDir">
<string>@{usage}</string>
<filterchain>
<replaceregex pattern="^([^/])" replace="/lib/\1"/>
<prefixlines prefix="${basedir}"/>
</filterchain>
</loadresource>
<local name="jarLoc"/>
<property name="jarLoc" value="${usageDir}/@{target}" unless:blank="@{target}"/>
<property name="jarLoc" value="${usageDir}/${artifactId}-${version}.@{packaging}"/>
<local name="urlLoc"/>
<property name="urlLoc" value="@{url}" unless:blank="@{url}"/>
<property name="urlLoc" value="@{repo}/${groupDir}/${artifactId}/${versionDir}/${artifactId}-${version}.@{packaging}@{query}"/>
<property name="@{prefix}.@{packaging}" value="${jarLoc}"/>
<property name="@{prefix}.url" value="${urlLoc}"/>
<!-- TODO: add library to a queue for downloading ... -->
</sequential>
</macrodef>
<!-- dependencies -->
<dependency prefix="xml-apis" artifact="xml-apis:xml-apis:1.4.01" usage="java8"/>
<dependency prefix="saxon" artifact="net.sf.saxon:Saxon-HE:10.2" 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.16.1" 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.13" usage="util"/>
<!-- api checks -->
<dependency prefix="forbidden" artifact="de.thetaphi:forbiddenapis:3.0.1" 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}" if:true="${isJava8}"/>
<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"/>
<delete dir="lib/main" includes="javaparser-core-3.15.21.jar"/>
<delete dir="lib/util" includes="forbiddenapis-2.6.jar,apache-rat-0.12.jar"/>
<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 release="8"
destdir="@{rscDir}"
debug="${compile.debug}"
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"/>
<!-- remove deprecated and not supported XMLInputStream API -->
<replaceregexp match="^.*@deprecated.*XMLInputStream.*\r?\n.*\r?\n.*\r?\n.*\r?\n" replace="" flags="gm">
<fileset dir="build/bootstrap/generated-sources" includes="**/*.java"/>
</replaceregexp>
<mkdir dir="build/classes"/>
<mkdir dir="build/generated-sources"/>
<javac release="8"
destdir="build/classes"
debug="${compile.debug}"
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 release="8"
destdir="build/classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
includeantruntime="false"
target="${jdk.version.class}"
source="${jdk.version.source}">
<src refid="sources"/>
<classpath path="${saxon.jar}"/>
</javac>
<javac release="9"
srcdir="${basedir}/src/main/multimodule/java9"
destdir="${basedir}/src/main/multimodule/java9"
includeantruntime="false"
debug="${compile.debug}"
debuglevel="lines,vars,source"
fork="true"
unless:true="${isJava8}">
<compilerarg line="--patch-module org.apache.xmlbeans=${basedir}/build/classes"/>
<modulepath>
<pathelement path="lib/main"/>
</modulepath>
</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 release="8"
destdir="build/test-classes"
debug="${compile.debug}"
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 release="8"
destdir="build/test-syscache/1/classes"
debug="${compile.debug}"
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 release="8"
destdir="build/test-syscache/2/classes"
debug="${compile.debug}"
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"/>
<zipfileset dir="src/main/multimodule/java9" prefix="META-INF/versions/9" excludes="*.java"/>
<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>
<!-- forbiddenapis bundled signatures max supported version is 14 -->
<condition property="forbiddenVersion" value="14">
<javaversion atleast="15"/>
</condition>
<property name="forbiddenVersion" value="${ant.java.version}"/>
<!-- first check rules that apply to all the source code -->
<forbiddenapis
suppressAnnotation="org.apache.poi.util.SuppressForbidden"
targetVersion="${forbiddenVersion}"
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,findbugs"
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}/src/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>
<!-- disabling findbugs until jenkins is updated to a current IBM JDK
see https://stackoverflow.com/a/48561534/2066598
this should be replaced by spotbugs when available in the jenkins warnings plugin -->
<target name="findbugs" depends="package">
<property name="spotbugs.home" value="build/findbugs" />
<property name="spotbugs.lib" value="/build/findbugs/lib" />
<!-- findbugs successor, spotbugs ... need to use the dependencies used in the spotbugs release. -->
<!-- compare with the entries found in the MANIFEST.MF of spotbugs.jar -->
<dependency prefix="spotbugs" artifact="com.github.spotbugs:spotbugs:4.0.2" usage="${spotbugs.lib}" target="spotbugs.jar"/>
<dependency prefix="spotbugs-ant" artifact="com.github.spotbugs:spotbugs-ant:4.0.2" usage="${spotbugs.lib}" target="spotbugs-ant.jar"/>
<dependency prefix="spotbugs-anno" artifact="com.github.spotbugs:spotbugs-annotations:4.0.2" usage="${spotbugs.lib}" target="spotbugs-annotations.jar"/>
<dependency prefix="spotbugs.asm" artifact="org.ow2.asm:asm:8.0.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.asm-analysis" artifact="org.ow2.asm:asm-analysis:8.0.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.asm-commons" artifact="org.ow2.asm:asm-commons:8.0.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.asm-tree" artifact="org.ow2.asm:asm-tree:8.0.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.asm-util" artifact="org.ow2.asm:asm-util:8.0.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.jsr305" artifact="com.google.code.findbugs:jsr305:3.0.2" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.dom4j" artifact="org.dom4j:dom4j:2.1.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.jaxen" artifact="jaxen:jaxen:1.1.6" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.bcel" artifact="org.apache.bcel:bcel:6.4.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.slf4j-api" artifact="org.slf4j:slf4j-api:1.8.0-beta4" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.commons-lang3" artifact="org.apache.commons:commons-lang3:3.10" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.commons-text" artifact="org.apache.commons:commons-text:1.8" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.jcip-annotations" artifact="net.jcip:jcip-annotations:1.0" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.icu4j" artifact="com.ibm.icu:icu4j:63.2" usage="${spotbugs.lib}" target="icu4j-63.1.jar"/>
<dependency prefix="spotbugs.log4j-api" artifact="org.apache.logging.log4j:log4j-api:2.13.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.log4j-core" artifact="org.apache.logging.log4j:log4j-core:2.13.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.log4j-slf4j18-impl" artifact="org.apache.logging.log4j:log4j-slf4j18-impl:2.13.1" usage="${spotbugs.lib}"/>
<dependency prefix="spotbugs.saxon" artifact="net.sf.saxon:Saxon-HE:9.9.1-2" usage="${spotbugs.lib}"/>
<mkdir dir="${basedir}${spotbugs.lib}/config"/>
<downloadfile src="${spotbugs.url}" dest="${spotbugs.jar}"/>
<downloadfile src="${spotbugs-ant.url}" dest="${spotbugs-ant.jar}"/>
<downloadfile src="${spotbugs-anno.url}" dest="${spotbugs-anno.jar}"/>
<downloadfile src="${spotbugs.dom4j.url}" dest="${spotbugs.dom4j.jar}"/>
<downloadfile src="${spotbugs.jaxen.url}" dest="${spotbugs.jaxen.jar}"/>
<downloadfile src="${spotbugs.bcel.url}" dest="${spotbugs.bcel.jar}"/>
<downloadfile src="${spotbugs.slf4j-api.url}" dest="${spotbugs.slf4j-api.jar}"/>
<downloadfile src="${spotbugs.commons-lang3.url}" dest="${spotbugs.commons-lang3.jar}"/>
<downloadfile src="${spotbugs.commons-text.url}" dest="${spotbugs.commons-text.jar}"/>
<downloadfile src="${spotbugs.jcip-annotations.url}" dest="${spotbugs.jcip-annotations.jar}"/>
<downloadfile src="${spotbugs.jsr305.url}" dest="${spotbugs.jsr305.jar}"/>
<downloadfile src="${spotbugs.asm.url}" dest="${spotbugs.asm.jar}"/>
<downloadfile src="${spotbugs.asm-analysis.url}" dest="${spotbugs.asm-analysis.jar}"/>
<downloadfile src="${spotbugs.asm-commons.url}" dest="${spotbugs.asm-commons.jar}"/>
<downloadfile src="${spotbugs.asm-tree.url}" dest="${spotbugs.asm-tree.jar}"/>
<downloadfile src="${spotbugs.asm-util.url}" dest="${spotbugs.asm-util.jar}"/>
<downloadfile src="${spotbugs.log4j-api.url}" dest="${spotbugs.log4j-api.jar}"/>
<downloadfile src="${spotbugs.log4j-core.url}" dest="${spotbugs.log4j-core.jar}"/>
<downloadfile src="${spotbugs.log4j-slf4j18-impl.url}" dest="${spotbugs.log4j-slf4j18-impl.jar}"/>
<downloadfile src="${spotbugs.saxon.url}" dest="${spotbugs.saxon.jar}"/>
<downloadfile src="${spotbugs.icu4j.url}" dest="${spotbugs.icu4j.jar}"/>
<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties">
<classpath>
<pathelement location="${spotbugs-ant.jar}"/>
</classpath>
</taskdef>
<echo file="${basedir}${spotbugs.lib}/config/log4j2.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
]]></echo>
<spotbugs home="${spotbugs.home}"
output="xml:withMessages"
outputFile="build/findbugs.xml"
effort="max"
failOnError="true">
<fileset dir="build">
<include name="xmlbeans-4.0.0.jar"/>
</fileset>
<auxClasspath path="${xml-apis.jar}"/>
<auxClasspath path="${saxon.jar}"/>
<auxClasspath path="${ant.jar}"/>
<auxClasspath path="${javaparser.core.jar}"/>
<sourcePath path="src/main/java" />
</spotbugs>
<!-- instead of calling findbugs again, we simply transform the xml -->
<makeurl file="${basedir}${spotbugs.lib}/spotbugs.jar" property="findbugs.jarurl"/>
<!-- although there's a findbugs history task too, it doesn't make much sense to provide it, -->
<!-- as the build directory (i.e. the old findbugs.xml) is deleted regularly -->
<xslt basedir="build" destdir="build" includes="findbugs.xml" force="true">
<style>
<url url="jar:${findbugs.jarurl}!/fancy.xsl"/>
</style>
<classpath>
<pathelement location="${spotbugs.saxon.jar}"/>
</classpath>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
</project>