Skip to content

Commit

Permalink
First attempt to upgrade maven-ant-tasks to maven-resolver-ant-tasks
Browse files Browse the repository at this point in the history
- declare new resolver namespace and point to the new taskdef
- remove the maven.repo.local handling (supported by default)
- declare the minimum set of remote repositories to compile
- drop the mvn-init task and include resolve in the relevant tasks
- declare top-level install-pom task to use local pom-bio-formats
  • Loading branch information
sbesson committed Dec 9, 2022
1 parent c0eabb7 commit bf8076e
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 79 deletions.
125 changes: 66 additions & 59 deletions ant/java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ Download Apache Ant from http://ant.apache.org/.
Type "ant -p" for a list of targets.
-->

<project xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<project xmlns:resolver="antlib:org.apache.maven.resolver.ant">
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
<fileset dir="${root.dir}/jar" includes="maven-resolver-ant-tasks-*.jar"/>
</classpath>
</taskdef>

<property file="${root.dir}/ant/java.properties"/>
<import file="${root.dir}/ant/common.xml"/>

Expand All @@ -23,64 +29,58 @@ Type "ant -p" for a list of targets.
<available file="${tests.dir}"/>
</condition>

<path id="maven-ant-tasks.classpath"
path="${lib.dir}/maven-ant-tasks-2.1.3.jar"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath"/>

<artifact:pom file="pom.xml" id="maven.pom"/>

<target name="mvn-init" unless="compile.classpath">
<mkdir dir="${build.dir}"/>
<condition property="maven.repo.local" value="${maven.repo.local}"
else="${user.home}/.m2/repository">
<isset property="maven.repo.local"/>
</condition>
<artifact:localRepository id="local.repository"
path="${maven.repo.local}"/>
<artifact:dependencies pathId="compile.classpath" useScope="compile"
cacheDependencyRefs="true"
dependencyRefsBuildFile="${build.dir}/compile-dependencies.xml">
<pom refid="maven.pom"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" useScope="test"
cacheDependencyRefs="true"
dependencyRefsBuildFile="${build.dir}/test-dependencies.xml">
<pom refid="maven.pom"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath"
filesetId="runtime.fileset"
useScope="runtime" cacheDependencyRefs="true"
dependencyRefsBuildFile="${build.dir}/runtime-dependencies.xml">
<pom refid="maven.pom"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
</target>

<resolver:pom file="pom.xml" id="pom"/>

<resolver:remoterepo id="ome" url="https://artifacts.openmicroscopy.org/artifactory/maven/" type="default" releases="true" snapshots="false"/>
<resolver:remoterepo id="unidata" url="https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases" type="default" releases="true"/>
<resolver:remoterepos id="resolver.repositories">
<resolver:remoterepo refid="central"/>
<resolver:remoterepo refid="ome"/>
<resolver:remoterepo refid="unidata"/>
</resolver:remoterepos>
<!-- Main build targets -->

<target name="compile" depends="mvn-init, copy-resources" description="compile classes">
<target name="compile" depends="copy-resources" description="compile classes">
<mkdir dir="${classes.dir}"/>
<javac debug="true" includeantruntime="false" fork="true"

<resolver:resolve>
<dependencies>
<pom refid="pom"/>
</dependencies>
<path refid="compile.classpath" classpath="compile"/>
<path refid="runtime.classpath" classpath="runtime"/>
</resolver:resolve>

<javac
classpathref="compile.classpath"
debug="true"
includeAntRuntime="false"
fork="true"
deprecation="${component.deprecation}"
source="${component.java-version}"
target="${component.java-version}"
encoding="UTF-8"
srcdir="${src.dir}" destdir="${classes.dir}"
includes="${component.source}">
<classpath refid="compile.classpath" />
includes="${component.source}"/>
<!--<compilerarg value="-Xlint:unchecked"/>-->
</javac>
</target>

<target name="compile-tests" depends="compile, mvn-init, copy-test-resources"
<target name="compile-tests" depends="compile"
description="compile test classes" if="doTests">
<mkdir dir="${test-classes.dir}"/>
<javac debug="true" includeantruntime="false" fork="true"

<resolver:resolve>
<dependencies>
<pom refid="pom"/>
</dependencies>
<path refid="test.classpath" classpath="test"/>
</resolver:resolve>

<javac
classpathref="alltest.classpath"
debug="true"
includeantruntime="false"
fork="true"
deprecation="${component.deprecation}"
source="${component.java-version}"
target="${component.java-version}"
Expand All @@ -89,7 +89,7 @@ Type "ant -p" for a list of targets.
includes="${component.source}">
<classpath refid="test.classpath"/>
<classpath path="${classes.dir}"/>
</javac>
</javac>
</target>

<target name="exec" depends="compile" description="execute package">
Expand Down Expand Up @@ -194,17 +194,25 @@ your FindBugs installation's lib directory. E.g.:
<attribute name="Implementation-URL" value="https://www.openmicroscopy.org/bio-formats/"/>
</manifest>
</jar>
<artifact:install file="${artifact.dir}/${component.jar}">
<artifact:localRepository id="local.repository"
path="${maven.repo.local}"/>
<pom refid="maven.pom"/>
</artifact:install>
<resolver:artifacts id="jar">
<artifact file="${artifact.dir}/${component.jar}" type="jar" />
</resolver:artifacts>
<resolver:install artifactsref="jar"/>
</target>

<target name="bundle" depends="init-timestamp,mvn-init" description="create bundle JAR">
<target name="bundle" depends="init-timestamp" description="create bundle JAR">
<mkdir dir="${artifact.dir}"/>
<resolver:resolve>
<dependencies>
<pom refid="pom"/>
</dependencies>
<path refid="runtime.classpath" classpath="runtime"/>
<files refid="runtime.fileset"/>
</resolver:resolve>

<jar destfile="${artifact.dir}/${bundle.jar}" filesetmanifest="skip">
<zipgroupfileset refid="runtime.fileset"/>
<!-- TODO: need to convert the above into a fileset for creating the uberJAR -->
<!-- <zipgroupfileset refid="runtime.fileset"/> -->
<manifest>
<attribute name="Main-Class" value="${bundle.main-class}"/>
<attribute name="Implementation-Title" value="${bundle.name}"/>
Expand All @@ -216,11 +224,10 @@ your FindBugs installation's lib directory. E.g.:
<attribute name="Implementation-URL" value="https://www.openmicroscopy.org/bio-formats/"/>
</manifest>
</jar>
<artifact:install file="${artifact.dir}/${bundle.jar}">
<pom refid="maven.pom"/>
<artifact:localRepository id="local.repository"
path="${maven.repo.local}"/>
</artifact:install>
<resolver:artifacts id="bundle">
<artifact file="${artifact.dir}/${bundle.jar}" type="jar" />
</resolver:artifacts>
<resolver:install artifactsref="bundle"/>
</target>

<target name="utils" depends="jar"
Expand Down Expand Up @@ -293,7 +300,7 @@ your FindBugs installation's lib directory. E.g.:
<!-- copy source files and text resources with filtering -->
</target>

<target name="copy-test-resources" depends="init" if="doTests">
<target name="copy-test-resources" depends="compile" if="doTests">
<!-- copy binary resources -->
<mkdir dir="${test.dir}"/>
<copy todir="${test.dir}" preservelastmodified="true">
Expand Down
4 changes: 3 additions & 1 deletion ant/toplevel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ Type "ant -p" for a list of targets.
<!-- API -->

<target name="deps-formats-api"
depends="copy-jars"/>
depends="copy-jars">
<ant dir="${root.dir}" target="install-pom"/>
</target>

<target name="compile-formats-api" depends="deps-formats-api"
description="compile classes for reader and writer APIs">
Expand Down
12 changes: 11 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,19 @@ Apache XML-RPC
License: Apache
-->

<project name="Bio-Formats" default="jars" basedir=".">
<project name="Bio-Formats" default="jars" basedir="." xmlns:resolver="antlib:org.apache.maven.resolver.ant">
<description>
Master build file for all Bio-Formats software components
</description>
<import file="ant/toplevel.xml"/>
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
<fileset dir="${root.dir}/jar" includes="maven-resolver-ant-tasks-*.jar"/>
</classpath>
</taskdef>

<target name="install-pom" description="generate top-level POM file">
<resolver:pom file="pom.xml" id="pom"/>
<resolver:install pomref="pom"/>
</target>
</project>
2 changes: 1 addition & 1 deletion components/bundles/bioformats_package/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Type "ant -p" for a list of targets.
<import file="${root.dir}/ant/java.xml"/>
<property file="build.properties"/>

<target name="docs" depends="javadoc-properties, mvn-init"
<target name="docs" depends="javadoc-properties"
description="generate the Javadocs for most components">
<echo>----------=========== Javadocs ===========----------</echo>
<tstamp>
Expand Down
34 changes: 17 additions & 17 deletions components/test-suite/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Type "ant -p" for a list of targets.
<delete dir="target"/>
</target>

<target name="test-file-handles" depends="compile"
<target name="test-file-handles" depends="compile-tests"
description="run tests for leaking file handles">
<exec executable="${basedir}/target-test-runner">
<!-- FileHandleTest is single-threaded -->
Expand All @@ -43,7 +43,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-open-bytes-performance" depends="compile"
<target name="test-open-bytes-performance" depends="compile-tests"
description="run tests for open bytes performance">
<exec executable="${basedir}/target-test-runner">
<arg value="-t${testng.threadCount}"/>
Expand All @@ -62,15 +62,15 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-tiff-writer" depends="compile"
<target name="test-tiff-writer" depends="compile-tests"
description="run tests for TIFF writing (conversion)">
<exec executable="${basedir}/target-test-runner">
<arg value="loci.tests.testng.TiffWriterTest"/>
<arg value="${filename}"/>
</exec>
</target>

<target name="test-equivalent" depends="compile"
<target name="test-equivalent" depends="compile-tests"
description="test if two files are pixels-equivalent">
<testng testname="Pixels equivalence test" failureProperty="failedTest">
<classpath>
Expand All @@ -90,7 +90,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-convert" depends="compile"
<target name="test-convert" depends="compile-tests"
description="run automated tests on writers">
<testng groups="all" testname="Writer tests"
listener="loci.tests.testng.DotTestListener"
Expand All @@ -113,7 +113,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-all" depends="compile"
<target name="test-all" depends="compile-tests"
description="run all automated tests">
<testng groups="all" testname="All tests"
listeners="loci.tests.testng.DotTestListener,loci.tests.testng.OrderingListener"
Expand Down Expand Up @@ -145,7 +145,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="gen-cache" depends="compile"
<target name="gen-cache" depends="compile-tests"
description="generate config files for automated test suite">
<testng groups="cache" testname="Cache generation"
listener="loci.tests.testng.DotTestListener"
Expand Down Expand Up @@ -175,7 +175,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="gen-config" depends="compile"
<target name="gen-config" depends="compile-tests"
description="generate config files for automated test suite">
<testng groups="config" testname="Config generation"
listener="loci.tests.testng.DotTestListener"
Expand Down Expand Up @@ -208,7 +208,7 @@ Type "ant -p" for a list of targets.
</target>
<target name="test-config" depends="gen-config"/>

<target name="gen-file-list" depends="compile"
<target name="gen-file-list" depends="compile-tests"
description="generate list of files to be tested">
<testng groups="file-list" testname="File list generation"
listener="loci.tests.testng.DotTestListener"
Expand Down Expand Up @@ -239,7 +239,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-automated" depends="compile"
<target name="test-automated" depends="compile-tests"
description="run automated tests in group 'automated'">

<testng groups="automated" testname="Automated tests"
Expand Down Expand Up @@ -277,7 +277,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-memoizer" depends="compile"
<target name="test-memoizer" depends="compile-tests"
description="run automated tests in group 'memoizer'">

<condition property="testng.threadCount" value="1">
Expand Down Expand Up @@ -321,7 +321,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-fast" depends="compile"
<target name="test-fast" depends="compile-tests"
description="run automated tests in group 'fast'">
<testng groups="fast" testname="Fast tests"
listeners="loci.tests.testng.DotTestListener,loci.tests.testng.OrderingListener"
Expand Down Expand Up @@ -353,7 +353,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-pixels" depends="compile"
<target name="test-pixels" depends="compile-tests"
description="run automated tests in group 'pixels'">
<testng groups="pixels" testname="Pixels tests"
listeners="loci.tests.testng.DotTestListener,loci.tests.testng.OrderingListener"
Expand Down Expand Up @@ -385,7 +385,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-xml" depends="compile"
<target name="test-xml" depends="compile-tests"
description="run automated tests in group 'xml'">
<testng groups="xml" testname="XML tests"
listeners="loci.tests.testng.DotTestListener,loci.tests.testng.OrderingListener"
Expand Down Expand Up @@ -417,7 +417,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="test-type" depends="compile"
<target name="test-type" depends="compile-tests"
description="run automated tests in group 'type'">
<testng groups="type" testname="Type tests"
listeners="loci.tests.testng.DotTestListener,loci.tests.testng.OrderingListener"
Expand Down Expand Up @@ -449,7 +449,7 @@ Type "ant -p" for a list of targets.
<fail if="failedTest"/>
</target>

<target name="gen-config-xml" depends="compile"
<target name="gen-config-xml" depends="compile-tests"
description="generate OME-XML files for automated test suite">
<testng groups="config-xml" testname="OME-XML generation"
listener="loci.tests.testng.DotTestListener"
Expand Down Expand Up @@ -479,7 +479,7 @@ Type "ant -p" for a list of targets.
</target>
<target name="test-config-xml" depends="gen-config-xml"/>

<target name="test-metadata" depends="compile"
<target name="test-metadata" depends="compile-tests"
description="test metadata level support for a single file">
<testng testname="Metadata tests" failureProperty="failedTest">
<classpath>
Expand Down
Binary file removed jar/maven-ant-tasks-2.1.3.jar
Binary file not shown.
Binary file added jar/maven-resolver-ant-tasks-1.4.0-uber.jar
Binary file not shown.

0 comments on commit bf8076e

Please sign in to comment.