Skip to content

Commit

Permalink
Merge pull request #3923 from sbesson/maven-artifact-resolver
Browse files Browse the repository at this point in the history
Switch to Maven Artifact Resolver Ant tasks
  • Loading branch information
dgault authored Jan 12, 2023
2 parents a703611 + f06d32a commit 60bc356
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 81 deletions.
135 changes: 76 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,64 @@ 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:remoterepo id="jenkins" url="https://repo.jenkins-ci.org/releases/" type="default" releases="true"/>
<resolver:remoterepos id="resolver.repositories">
<resolver:remoterepo refid="central"/>
<resolver:remoterepo refid="ome"/>
<resolver:remoterepo refid="unidata"/>
<resolver:remoterepo refid="jenkins"/>
</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"

<path id="compile.classpath"/>
<path id="runtime.classpath"/>
<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"

<path id="test.classpath"/>
<resolver:resolve>
<dependencies>
<pom refid="pom"/>
</dependencies>
<path refid="test.classpath" classpath="test"/>
<properties prefix="dep." classpath="test"/>
</resolver:resolve>

<javac
classpathref="test.classpath"
debug="true"
includeantruntime="false"
fork="true"
deprecation="${component.deprecation}"
source="${component.java-version}"
target="${component.java-version}"
Expand All @@ -89,7 +95,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 +200,28 @@ 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"/>
</resolver:resolve>

<!-- Unzip the content of the runtime classpath to create the uberJAR -->
<unzip dest="${build.dir}/unzip">
<path refid="runtime.classpath"/>
</unzip>

<jar destfile="${artifact.dir}/${bundle.jar}" filesetmanifest="skip">
<zipgroupfileset refid="runtime.fileset"/>
<zipfileset dir="${build.dir}/unzip"/>
<manifest>
<attribute name="Main-Class" value="${bundle.main-class}"/>
<attribute name="Implementation-Title" value="${bundle.name}"/>
Expand All @@ -216,11 +233,11 @@ 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>
<delete dir="${build.dir}/unzip"/>
<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 +310,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
Loading

0 comments on commit 60bc356

Please sign in to comment.