| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<project name="Libvirt Java Bindings" default="build" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> |
| 3 |
<property file="build.properties" /> |
| 4 |
<property name="jar" value="libvirt-${version}" /> |
| 5 |
<property name="jar.file" value="target/${jar}.jar" /> |
| 6 |
<property name="src" value="libvirt-java-${version}" /> |
| 7 |
<property name="src.file" value="target/${src}.tar.gz" /> |
| 8 |
<property name="spec" value="libvirt-java.spec" /> |
| 9 |
<property name="spec.file" value="target/${spec}" /> |
| 10 |
|
| 11 |
<path id="compile.classpath"> |
| 12 |
<fileset dir="${jar.dir}"> |
| 13 |
<include name="jna.jar" /> |
| 14 |
</fileset> |
| 15 |
</path> |
| 16 |
|
| 17 |
<path id="test.classpath"> |
| 18 |
<fileset dir="${jar.dir}"> |
| 19 |
<include name="jna.jar" /> |
| 20 |
<include name="junit.jar" /> |
| 21 |
</fileset> |
| 22 |
<pathelement location="target/classes" /> |
| 23 |
<pathelement location="target/testclasses" /> |
| 24 |
</path> |
| 25 |
|
| 26 |
<target name="init"> |
| 27 |
<mkdir dir="target/classes" /> |
| 28 |
<mkdir dir="target/testclasses" /> |
| 29 |
<copy file="README.in" tofile="README" overwrite="true" filtering="true"> |
| 30 |
<filterset filtersfile="build.properties" /> |
| 31 |
</copy> |
| 32 |
</target> |
| 33 |
|
| 34 |
<target name="clean" description="cleans up all created artifacts"> |
| 35 |
<delete dir="target" /> |
| 36 |
</target> |
| 37 |
|
| 38 |
<target name="build" depends="init" description="builds the code and jar files"> |
| 39 |
<javac srcdir="src/main/java" includes="**/*.java" classpathref="compile.classpath" destdir="target/classes" /> |
| 40 |
<javac srcdir="src/test/java" includes="**/*.java" classpathref="test.classpath" destdir="target/testclasses" /> |
| 41 |
<jar destfile="${jar.file}" basedir="target/classes" /> |
| 42 |
</target> |
| 43 |
|
| 44 |
<target name="test" depends="build" description="tests the code"> |
| 45 |
<junit printsummary="yes" fork="yes"> |
| 46 |
<formatter type="plain" /> |
| 47 |
<classpath refid="test.classpath" /> |
| 48 |
<test name="org.libvirt.TestJavaBindings" outfile="target/testResults"> |
| 49 |
</test> |
| 50 |
</junit> |
| 51 |
</target> |
| 52 |
|
| 53 |
<target name="docs" depends="build" description="builds the javadoc"> |
| 54 |
<mkdir dir="target/javadoc" /> |
| 55 |
<javadoc sourcepath="src/main/java" classpathref="compile.classpath" destdir="target/javadoc" /> |
| 56 |
</target> |
| 57 |
|
| 58 |
<target name="src" depends="init" description="creates a src tarball"> |
| 59 |
<mkdir dir="target/libvirt-java-${version}" /> |
| 60 |
<copy todir="target/libvirt-java-${version}"> |
| 61 |
<fileset dir="." excludes="target/**,.gitignore,.git/**,.*,.*/**" /> |
| 62 |
</copy> |
| 63 |
<tar basedir="target" includes="libvirt-java-${version}/**" compression="gzip" destfile="${src.file}" /> |
| 64 |
</target> |
| 65 |
|
| 66 |
<target name="spec" depends="init" description="generates the spec file"> |
| 67 |
<copy file="libvirt-java.spec.in" tofile="${spec.file}" overwrite="true" filtering="true"> |
| 68 |
<filterset filtersfile="build.properties" /> |
| 69 |
</copy> |
| 70 |
</target> |
| 71 |
|
| 72 |
<target name="package" depends="src,build,docs,spec" description="builds the rpms"> |
| 73 |
<copy file="${src.file}" todir="${rpm.topdir}/SOURCES" /> |
| 74 |
<copy file="${spec.file}" todir="${rpm.topdir}/SPECS" /> |
| 75 |
<rpm specfile="${spec}" command="-ba" topdir="${rpm.topdir}" /> |
| 76 |
</target> |
| 77 |
|
| 78 |
<target name="maven" depends="build" description="publish the maven repo"> |
| 79 |
<mkdir dir="target/repo" /> |
| 80 |
<get src="http://mirror.its.uidaho.edu/pub/apache/maven/binaries/maven-ant-tasks-2.1.0.jar" dest="target/maven-ant-tasks-2.1.0.jar" /> |
| 81 |
<copy file="pom.xml.in" tofile="target/pom.xml" overwrite="true" filtering="true"> |
| 82 |
<filterset filtersfile="build.properties" /> |
| 83 |
</copy> |
| 84 |
<path id="maven-ant-tasks.classpath" path="target/maven-ant-tasks-2.1.0.jar" /> |
| 85 |
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" /> |
| 86 |
<input message="Username for copying source files: " |
| 87 |
addproperty="scp.username"/> |
| 88 |
<input message="Passphrase: " |
| 89 |
addproperty="scp.passphrase"/> |
| 90 |
<scp file="${scp.username}@www.libvirt.org:/data/www/maven2" |
| 91 |
todir="target/repo" |
| 92 |
keyfile="${user.home}/.ssh/id_rsa" |
| 93 |
sftp="true" |
| 94 |
passphrase="${scp.passphrase}" |
| 95 |
/> |
| 96 |
<artifact:pom id="mypom" file="target/pom.xml" /> |
| 97 |
<artifact:install file="${jar.file}"> |
| 98 |
<localRepository path="target/repo" /> |
| 99 |
<pom refid="mypom" /> |
| 100 |
</artifact:install> |
| 101 |
<scp todir="${scp.username}@www.libvirt.org:/data/www/maven2" |
| 102 |
keyfile="${user.home}/.ssh/id_rsa" |
| 103 |
sftp="true" |
| 104 |
passphrase="${scp.passphrase}"> |
| 105 |
<fileset dir="target/repo"> |
| 106 |
</fileset> |
| 107 |
</scp> |
| 108 |
</target> |
| 109 |
|
| 110 |
<target name="publish_source" depends="build" description="Publish the source tarball"> |
| 111 |
<input message="Username for copying source files: " |
| 112 |
addproperty="scp.username"/> |
| 113 |
<input message="Passphrase: " |
| 114 |
addproperty="scp.passphrase"/> |
| 115 |
<scp file="${src.file}" |
| 116 |
todir="${scp.username}@www.libvirt.org:/data/ftp/libvirt/java" |
| 117 |
keyfile="${user.home}/.ssh/id_rsa" |
| 118 |
sftp="true" |
| 119 |
passphrase="${scp.passphrase}" |
| 120 |
/> |
| 121 |
|
| 122 |
</target> |
| 123 |
|
| 124 |
<target name="publish_srpm" depends="build" description="publish the srpm"> |
| 125 |
<input message="Username for copying source files: " |
| 126 |
addproperty="scp.username"/> |
| 127 |
<input message="Passphrase: " |
| 128 |
addproperty="scp.passphrase"/> |
| 129 |
<scp todir="${scp.username}@www.libvirt.org:/data/ftp/libvirt/java" |
| 130 |
keyfile="${user.home}/.ssh/id_rsa" |
| 131 |
sftp="true" |
| 132 |
passphrase="${scp.passphrase}"> |
| 133 |
<fileset dir="${rpm.topdir}/SRPMS"> |
| 134 |
<include name="libvirt-java-${version}-${release}*.src.rpm"/> |
| 135 |
</fileset> |
| 136 |
</scp> |
| 137 |
</target> |
| 138 |
|
| 139 |
</project> |