1<project name="umlgraph" default="compile" basedir="." 2 xmlns:artifact="antlib:org.apache.maven.artifact.ant" > 3 4<description> 5 The specification for the Java-based umlgraph build processes. 6</description> 7 8<!-- set global properties for this build --> 9<property name="src" location="src/main/java"/> 10<property name="testsrc" location="src/test"/> 11<property name="build" location="build"/> 12<property name="javadoc" location="javadoc"/> 13<property name="lib" location="lib"/> 14<property name="testsrc" location="test/src"/> 15<property name="testout" location="${basedir}/testdata/dot-out"/> 16<property name="testref" location="${basedir}/testdata/dot-ref"/> 17 18<property name="dist" location="dist" /> 19 20<!-- define Maven coordinates; see https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7c.DeploySnapshotsandStageReleaseswithAnt --> 21<property name="groupId" value="org.umlgraph" /> 22<property name="artifactId" value="UmlGraph" /> 23 24<!-- define artifacts' name, which follows the convention of Maven --> 25<property name="maven-jar" value="${dist}/lib/${artifactId}-${version}.jar" /> 26<property name="maven-javadoc-jar" value="${dist}/lib/${artifactId}-${version}-javadoc.jar" /> 27<property name="maven-sources-jar" value="${dist}/lib/${artifactId}-${version}-sources.jar" /> 28 29<!-- defined maven snapshots and staging repository id and url --> 30<!-- passwords are stored in \Users\Diomidis Spinellis\.m2\settings.xml --> 31<property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" /> 32<property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" /> 33<property name="maven-staging-repository-id" value="sonatype-nexus-staging" /> 34<property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" /> 35 36<!-- import environment variables --> 37<property environment="env"/> 38 39<target name="init"> 40 <!-- Create the time stamp --> 41 <tstamp/> 42 <!-- Create the build directory structure used by compile --> 43 <mkdir dir="${build}"/> 44 <mkdir dir="${lib}"/> 45 <mkdir dir="testdata/dot-out"/> 46 <mkdir dir="${javadoc}"/> 47 <mkdir dir="${dist}/lib"/> 48</target> 49 50<target name="version"> 51 <echo>Version is ${VERSION}</echo> 52 <echo file="src/main/java/org/umlgraph/doclet/Version.java">/* Automatically generated file */ 53package org.umlgraph.doclet; 54class Version { public static String VERSION = "${VERSION}";} 55 </echo> 56</target> 57 58<target name="compile" depends="init,version" 59 description="compile the source, build library " > 60 <javac srcdir="${src}" destdir="${build}" debug="true" 61 deprecation="true" includeantruntime="false" > 62 <compilerarg value="-Xlint"/> 63 <classpath> 64 <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/> 65 </classpath> 66 </javac> 67 <jar basedir="${build}" destfile="${lib}/UmlGraph.jar" includes="org/umlgraph/doclet/*.class"> 68 <manifest> 69 <attribute name="Main-Class" value="org.umlgraph.doclet.UmlGraph"/> 70 <attribute name="Class-Path" value="tools.jar"/> 71 </manifest> 72 </jar> 73</target> 74 75<target name="testcompile" depends="init" 76 description="compile the test code " > 77 <javac srcdir="${testsrc}" destdir="${build}" debug="true" 78 deprecation="true" includeantruntime="false" > 79 <classpath> 80 <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/> 81 </classpath> 82 <compilerarg value="-Xlint"/> 83 </javac> 84</target> 85 86<target name="test" depends="compile,testcompile" 87 description="run the regression tests" > 88 <java classname="org.umlgraph.test.BasicTest" fork="true"> 89 <classpath> 90 <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/> 91 <pathelement location="${build}"/> 92 <pathelement location="${lib}/UmlGraph.jar"/> 93 </classpath> 94 </java> 95 <java classname="org.umlgraph.test.UmlDocTest" fork="true"> 96 <classpath> 97 <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/> 98 <pathelement location="${build}"/> 99 <pathelement location="${lib}/UmlGraph.jar"/> 100 </classpath> 101 </java> 102 <apply executable="dot" dest="${testout}" parallel="false"> 103 <arg value="-Tpng"/> 104 <arg value="-o"/> 105 <targetfile/> 106 <srcfile/> 107 <fileset dir="${testout}" includes="*.dot"/> 108 <mapper type="glob" from="*.dot" to="*.png"/> 109 </apply> 110 <apply executable="dot" dest="${testref}" parallel="false"> 111 <arg value="-Tpng"/> 112 <arg value="-o"/> 113 <targetfile/> 114 <srcfile/> 115 <fileset dir="${testref}" includes="*.dot"/> 116 <mapper type="glob" from="*.dot" to="*.png"/> 117 </apply> 118</target> 119 120<target name="javadocs" depends="compile"> 121 <javadoc sourcepath="${src}" packagenames="org.umlgraph.doclet.*" destdir="${javadoc}" private="true"> 122 <doclet name="org.umlgraph.doclet.UmlGraphDoc" path="${lib}/UmlGraph.jar"> 123 <param name="-inferrel"/> 124 <param name="-inferdep"/> 125 <param name="-collapsible"/> 126 <param name="-hide" value="java.*"/> 127 <param name="-collpackages" value="java.util.*"/> 128 <param name="-qualify"/> 129 <param name="-postfixpackage"/> 130 <param name="-nodefontsize" value="9"/> 131 <param name="-nodefontpackagesize" value="7"/> 132 <param name="-link" value="http://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/"/> 133 <param name="-link" value="http://download.oracle.com/javase/7/docs/api/"/> 134 </doclet> 135 </javadoc> 136</target> 137 138<target name="pom" description="generate the pom.xml file with the correct version"> 139 <copy file="pom.template.xml" 140 tofile="pom.xml" 141 filtering="yes" overwrite="yes"> 142 <filterchain> 143 <filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/> 144 </filterchain> 145 </copy> 146</target> 147 148<target name="dist" depends="compile" description="generate the distribution"> 149 <!-- build the main artifact --> 150 <jar jarfile="${maven-jar}" basedir="${build}" /> 151 152 <!-- build the javadoc artifact --> 153 <javadoc sourcepath="${src}" destdir="${dist}/javadoc" /> 154 <jar jarfile="${maven-javadoc-jar}"> 155 <fileset dir="${dist}/javadoc" /> 156 </jar> 157 158 <!-- build the sources artifact --> 159 <jar jarfile="${maven-sources-jar}"> 160 <fileset dir="${src}" /> 161 </jar> 162</target> 163 164<target name="deploy" depends="dist,pom" description="deploy snapshot version to Maven snapshot repository"> 165 <!-- for this to work install http://maven.apache.org/ant-tasks/download.html into ant/lib --> 166 <artifact:mvn> 167 <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" /> 168 <arg value="-Durl=${maven-snapshots-repository-url}" /> 169 <arg value="-DrepositoryId=${maven-snapshots-repository-id}" /> 170 <arg value="-DpomFile=pom.xml" /> 171 <arg value="-Dfile=${maven-jar}" /> 172 </artifact:mvn> 173 <artifact:mvn> 174 <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" /> 175 <arg value="-Durl=${maven-snapshots-repository-url}" /> 176 <arg value="-DrepositoryId=${maven-snapshots-repository-id}" /> 177 <arg value="-DpomFile=pom.xml" /> 178 <arg value="-Dfile=${maven-sources-jar}" /> 179 <arg value="-Dclassifier=sources" /> 180 </artifact:mvn> 181 182 <!-- sign and deploy the javadoc artifact --> 183 <artifact:mvn> 184 <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" /> 185 <arg value="-Durl=${maven-snapshots-repository-url}" /> 186 <arg value="-DrepositoryId=${maven-snapshots-repository-id}" /> 187 <arg value="-DpomFile=pom.xml" /> 188 <arg value="-Dfile=${maven-javadoc-jar}" /> 189 <arg value="-Dclassifier=javadoc" /> 190 </artifact:mvn> 191</target> 192 193<!-- before this, update project version (both build.xml and pom.xml) from SNAPSHOT to RELEASE --> 194<target name="stage" depends="dist,pom" description="deploy release version to Maven staging repository"> 195 <!-- sign and deploy the main artifact --> 196 <artifact:mvn> 197 <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> 198 <arg value="-Durl=${maven-staging-repository-url}" /> 199 <arg value="-DrepositoryId=${maven-staging-repository-id}" /> 200 <arg value="-DpomFile=pom.xml" /> 201 <arg value="-Dfile=${maven-jar}" /> 202 <arg value="-Pgpg" /> 203 </artifact:mvn> 204 205 <!-- sign and deploy the sources artifact --> 206 <artifact:mvn> 207 <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> 208 <arg value="-Durl=${maven-staging-repository-url}" /> 209 <arg value="-DrepositoryId=${maven-staging-repository-id}" /> 210 <arg value="-DpomFile=pom.xml" /> 211 <arg value="-Dfile=${maven-sources-jar}" /> 212 <arg value="-Dclassifier=sources" /> 213 <arg value="-Pgpg" /> 214 </artifact:mvn> 215 216 <!-- sign and deploy the javadoc artifact --> 217 <artifact:mvn> 218 <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> 219 <arg value="-Durl=${maven-staging-repository-url}" /> 220 <arg value="-DrepositoryId=${maven-staging-repository-id}" /> 221 <arg value="-DpomFile=pom.xml" /> 222 <arg value="-Dfile=${maven-javadoc-jar}" /> 223 <arg value="-Dclassifier=javadoc" /> 224 <arg value="-Pgpg" /> 225 </artifact:mvn> 226</target> 227 228</project> 229