|
10 | 10 | ** Paths are relative to the build.xml that imports this template.
|
11 | 11 | **
|
12 | 12 | -->
|
13 |
| -<project name="plugin_common" basedir="." xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if" xmlns:unless="ant:unless" xmlns:ivy="antlib:org.apache.ivy.ant"> |
| 13 | +<project name="plugin_common" basedir="." xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if" xmlns:unless="ant:unless" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:mvn="antlib:org.apache.maven.resolver.ant" > |
14 | 14 |
|
15 | 15 | <property name="josm" location="../../core/dist/josm-custom.jar"/>
|
16 | 16 | <property name="josm.ivy" location="../../core/ivy.xml"/>
|
|
42 | 42 | <property name="ivy.jar.dir" location="${ivy.home}/lib"/>
|
43 | 43 | <property name="ivy.jar.file" location="${ivy.jar.dir}/ivy.jar"/>
|
44 | 44 | <property name="ivy.version" value="2.5.1"/>
|
| 45 | + <property name="maven.artifact.resolver.version" value="1.5.1"/> |
| 46 | + <property name="maven.artifact.resolver.parent.dir" value="${user.home}/.m2/repository/org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.artifact.resolver.version}/"/> |
| 47 | + <property name="maven.artifact.resolver.jar.file" value="${maven.artifact.resolver.parent.dir}/maven-resolver-ant-tasks-${maven.artifact.resolver.version}-uber.jar"/> |
45 | 48 | <property name="jacoco.inclbootstrapclasses" value="false" />
|
46 | 49 | <property name="jacoco.inclnolocationclasses" value="false" />
|
47 | 50 | <property name="junit.printsummary" value="on" />
|
|
110 | 113 | <!-- to be overridden by plugins that need to perform additional tasks before compiling -->
|
111 | 114 | </target>
|
112 | 115 | <target name="compile" depends="init, pre-compile, resolve-tools" unless="skip-compile">
|
| 116 | + <condition property="plugin.classpath.actual.defined"> |
| 117 | + <isreference refid="plugin.classpath.actual" type="path"/> |
| 118 | + </condition> |
| 119 | + <path id="plugin.classpath.actual" unless:set="plugin.classpath.actual.defined"> |
| 120 | + <path refid="plugin.classpath"/> |
| 121 | + </path> |
113 | 122 | <echo message="compiling sources for ${plugin.jar} ..."/>
|
114 | 123 | <path id="jdk.boot.classpath">
|
115 | 124 | <path refid="errorprone_javac.classpath"/>
|
|
133 | 142 | <compilerarg value="-Xlint:unchecked"/>
|
134 | 143 | <compilerarg value="-Xplugin:ErrorProne -Xep:StringSplitter:OFF -Xep:ReferenceEquality:OFF -Xep:InsecureCryptoUsage:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsHashCode:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF" />
|
135 | 144 | <compilerarg line="-Xmaxwarns 1000"/>
|
136 |
| - <classpath refid="plugin.classpath"/> |
| 145 | + <classpath refid="plugin.classpath.actual"/> |
137 | 146 | </javac>
|
138 | 147 | </target>
|
139 | 148 | <!--
|
|
279 | 288 | <target name="pre-javadoc">
|
280 | 289 | <!-- to be overridden by plugins that need to perform additional tasks before generating javadoc -->
|
281 | 290 | </target>
|
282 |
| - <target name="javadoc" depends="pre-javadoc" unless="skip-javadoc"> |
| 291 | + <target name="javadoc" depends="pre-javadoc,pre-compile" unless="skip-javadoc"> |
| 292 | + <mkdir dir="${plugin.doc.dir}"/> |
283 | 293 | <javadoc destdir="${plugin.doc.dir}"
|
284 | 294 | executable="${javadoc.executable}"
|
285 | 295 | encoding="UTF-8"
|
|
288 | 298 | private="true"
|
289 | 299 | linksource="true"
|
290 | 300 | author="false">
|
291 |
| - <classpath refid="plugin.classpath"/> |
| 301 | + <classpath refid="plugin.classpath" unless:set="plugin.classpath.dependencies"/> |
| 302 | + <classpath refid="plugin.classpath.dependencies" if:set="plugin.classpath.dependencies"/> |
292 | 303 | <sourcepath>
|
293 | 304 | <pathelement path="${plugin.src.dir}" />
|
294 | 305 | <pathelement path="gen" />
|
|
660 | 671 | org/osgeo/**/*.java,
|
661 | 672 | "/>
|
662 | 673 | <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
|
| 674 | + <formatter type="plain"/> |
663 | 675 | <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
|
664 | 676 | </checkstyle>
|
665 | 677 | </target>
|
|
676 | 688 | nested="false"
|
677 | 689 | jvmargs="-Xmx1024m"
|
678 | 690 | >
|
679 |
| - <auxClasspath refid="plugin.classpath" /> |
| 691 | + <auxClasspath refid="plugin.classpath" unless:set="plugin.classpath.dependencies"/> |
| 692 | + <auxClasspath refid="plugin.classpath.dependencies" if:set="plugin.classpath.dependencies"/> |
680 | 693 | <sourcePath path="${basedir}/src" />
|
681 | 694 | <class location="${plugin.build.dir}" />
|
682 | 695 | </spotbugs>
|
|
714 | 727 | <!--
|
715 | 728 | ** Ivy tasks
|
716 | 729 | -->
|
| 730 | + <target name="is-ivy"> |
| 731 | + <condition property="isIvy"> |
| 732 | + <available file="ivy.xml"/> |
| 733 | + </condition> |
| 734 | + </target> |
717 | 735 | <target name="download-ivy">
|
718 | 736 | <mkdir dir="${ivy.jar.dir}"/>
|
719 | 737 | <get src="https://josm.openstreetmap.de/nexus/content/repositories/public/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
|
|
742 | 760 | </fileset>
|
743 | 761 | </delete>
|
744 | 762 | </target>
|
745 |
| - <target name="fetch_dependencies" depends="clean_ivy, init-ivy"> |
| 763 | + <target name="fetch-dependencies-ivy" depends="clean_ivy, init-ivy, is-ivy" if="isIvy"> |
746 | 764 | <echo>fetching dependencies with ivy</echo>
|
747 | 765 | <available property="plugin.ivysettings.exists" file="ivy_settings.xml"/>
|
748 | 766 | <ivy:settings file="ivy_settings.xml" if:set="plugin.ivysettings.exists"/>
|
749 | 767 | <ivy:settings file="${josm.ivysettings}" unless:set="plugin.ivysettings.exists"/>
|
750 | 768 | <ivy:resolve />
|
751 | 769 | <ivy:retrieve pattern="${plugin.lib.dir}/[artifact]-[revision](-[classifier]).[ext]" conf="default" />
|
752 | 770 | </target>
|
753 |
| - <target name="ivy-checkdepsupdate" description="Display dependency updates on the console" depends="fetch_dependencies"> |
| 771 | + <target name="ivy-checkdepsupdate" description="Display dependency updates on the console" depends="fetch-dependencies-ivy"> |
754 | 772 | <ivy:checkdepsupdate/>
|
755 | 773 | </target>
|
| 774 | + <!-- |
| 775 | + ** Maven tasks |
| 776 | + --> |
| 777 | + <target name="is-maven" depends="is-ivy"> |
| 778 | + <condition property="isMaven"> |
| 779 | + <and> |
| 780 | + <available file="pom.xml"/> |
| 781 | + <not> |
| 782 | + <isset property="isIvy"/> |
| 783 | + </not> |
| 784 | + </and> |
| 785 | + </condition> |
| 786 | + </target> |
| 787 | + <target name="download-maven" depends="is-maven" if="isMaven"> |
| 788 | + <mkdir dir="${maven.artifact.resolver.parent.dir}"/> |
| 789 | + <get src="https://josm.openstreetmap.de/nexus/content/repositories/public/org/apache/maven/resolver/maven-resolver-ant-tasks/${maven.artifact.resolver.version}/maven-resolver-ant-tasks-${maven.artifact.resolver.version}-uber.jar" |
| 790 | + dest="${maven.artifact.resolver.jar.file}" |
| 791 | + usetimestamp="true"/> |
| 792 | + </target> |
| 793 | + <target name="init-maven" depends="is-maven,download-maven" if="isMaven"> |
| 794 | + <path id="maven.lib.path"> |
| 795 | + <fileset dir="${maven.artifact.resolver.parent.dir}" includes="*.jar"/> |
| 796 | + </path> |
| 797 | + <taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml" classpathref="maven.lib.path"/> |
| 798 | + </target> |
| 799 | + <target name="fetch-dependencies-maven" depends="is-maven,init-maven,clean_ivy" if="isMaven"> |
| 800 | + <mvn:pom file="pom.xml"/> |
| 801 | + <mvn:pom file="pom.xml" id="pom"/> |
| 802 | + <!-- This stanza is necessary since the maven resolver doesn't read repo settings from the pom.xml file --> |
| 803 | + <!-- resolver.repositories makes it global --> |
| 804 | + <mvn:remoterepos id="resolver.repositories"> |
| 805 | + <mvn:remoterepo id="JOSM" url="https://josm.openstreetmap.de/nexus/content/repositories/public/" /> |
| 806 | + </mvn:remoterepos> |
| 807 | + <mkdir dir="${plugin.lib.dir}"/> |
| 808 | + <mvn:resolve> |
| 809 | + <!-- For some reason, compile time josm-unittest dependencies get included --> |
| 810 | + <mvn:dependencies pomRef="pom"> |
| 811 | + <mvn:exclusion groupId="org.openstreetmap.josm" artifactId="josm-unittest"/> |
| 812 | + <mvn:exclusion groupId="org.junit.platform"/> |
| 813 | + <mvn:exclusion groupId="org.junit.vintage"/> |
| 814 | + <mvn:exclusion groupId="org.junit.jupiter"/> |
| 815 | + </mvn:dependencies> |
| 816 | + <mvn:files refid="lib.files" dir="${plugin.lib.dir}" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,!test"/> |
| 817 | + </mvn:resolve> |
| 818 | + <echo message="${toString:lib.files}"/> |
| 819 | + <mvn:resolve> |
| 820 | + <mvn:path refid="classpath.provided" scopes="provided"/> |
| 821 | + </mvn:resolve> |
| 822 | + <mvn:resolve> |
| 823 | + <mvn:path refid="testlib.classpath" classpath="test"/> |
| 824 | + </mvn:resolve> |
| 825 | + <mvn:resolve> |
| 826 | + <mvn:dependencies> |
| 827 | + <mvn:dependency groupId="org.jacoco" artifactId="org.jacoco.ant" version="${pom.properties.jacoco.version}" classifier="nodeps" type="jar" scope="test"/> |
| 828 | + </mvn:dependencies> |
| 829 | + <mvn:path refid="jacocotest.classpath" classpath="test"/> |
| 830 | + </mvn:resolve> |
| 831 | + <mvn:resolve> |
| 832 | + <mvn:dependencies> |
| 833 | + <mvn:dependency groupId="com.puppycrawl.tools" artifactId="checkstyle" version="${pom.properties.checkstyle.version}" scope="compile"/> |
| 834 | + </mvn:dependencies> |
| 835 | + <mvn:path refid="checkstyle.classpath" classpath="compile"/> |
| 836 | + </mvn:resolve> |
| 837 | + <mvn:resolve> |
| 838 | + <mvn:dependencies> |
| 839 | + <mvn:dependency groupId="com.github.spotbugs" artifactId="spotbugs" version="${pom.properties.spotbugs.version}" scope="compile"/> |
| 840 | + <mvn:dependency groupId="com.github.spotbugs" artifactId="spotbugs-ant" version="${pom.properties.spotbugs.version}" scope="compile"/> |
| 841 | + </mvn:dependencies> |
| 842 | + <mvn:path refid="spotbugs.classpath" classpath="compile"/> |
| 843 | + </mvn:resolve> |
| 844 | + <path id="plugin.classpath.actual"> |
| 845 | + <path refid="plugin.classpath"/> |
| 846 | + <path refid="classpath.provided"/> |
| 847 | + </path> |
| 848 | + </target> |
| 849 | + |
| 850 | + <target name="fetch_dependencies" depends="fetch-dependencies-ivy,fetch-dependencies-maven"> |
| 851 | + <!-- We can depend upon ivy and/or maven right now. --> |
| 852 | + </target> |
756 | 853 | </project>
|
0 commit comments