| 1 |
~~ The MIT License |
| 2 |
~~ |
| 3 |
~~ Copyright (c) 2009 codehaus.org. |
| 4 |
~~ |
| 5 |
~~ Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
~~ of this software and associated documentation files (the "Software"), to deal |
| 7 |
~~ in the Software without restriction, including without limitation the rights |
| 8 |
~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
~~ copies of the Software, and to permit persons to whom the Software is |
| 10 |
~~ furnished to do so, subject to the following conditions: |
| 11 |
~~ |
| 12 |
~~ The above copyright notice and this permission notice shall be included in |
| 13 |
~~ all copies or substantial portions of the Software. |
| 14 |
~~ |
| 15 |
~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 |
~~ THE SOFTWARE. |
| 22 |
~~ |
| 23 |
|
| 24 |
----- |
| 25 |
Sample project |
| 26 |
----- |
| 27 |
Stephen Connolly |
| 28 |
------ |
| 29 |
2009-11-06 |
| 30 |
------ |
| 31 |
|
| 32 |
Sample project |
| 33 |
|
| 34 |
* Sample project |
| 35 |
|
| 36 |
The following sample project is based on the integration tests for this antlib |
| 37 |
(but with the hacks to make it work when invoked from Maven removed) |
| 38 |
|
| 39 |
--- |
| 40 |
<?xml version="1.0" encoding="UTF-8"?> |
| 41 |
<project name="sample-project" xmlns:as="antlib:org.codehaus.mojo.animal_sniffer"> |
| 42 |
|
| 43 |
<property environment="env"/> |
| 44 |
|
| 45 |
<path id="jre"> |
| 46 |
<fileset dir="\${java.home}" includes="lib/rt.jar"/> |
| 47 |
<fileset dir="\${java.home}" includes="lib/jce.jar"/> |
| 48 |
<fileset dir="\${java.home}" includes="lib/jsse.jar"/> |
| 49 |
</path> |
| 50 |
|
| 51 |
<typedef uri="antlib:org.codehaus.mojo.animal_sniffer"> |
| 52 |
<classpath path="lib/${project.artifactId}-${project.version}.jar"/> |
| 53 |
</typedef> |
| 54 |
|
| 55 |
<target name="clean"> |
| 56 |
<delete dir="build"/> |
| 57 |
</target> |
| 58 |
|
| 59 |
<target name="compile" depends="package-api2"> |
| 60 |
<mkdir dir="build/classes"/> |
| 61 |
<javac srcdir="src/main/java" destdir="build/classes" fork="true"> |
| 62 |
<classpath> |
| 63 |
<path path="build/api2.jar"/> |
| 64 |
</classpath> |
| 65 |
</javac> |
| 66 |
</target> |
| 67 |
|
| 68 |
<target name="package" depends="compile"> |
| 69 |
<mkdir dir="build"/> |
| 70 |
<jar destfile="build/${ant.project.name}.jar" basedir="build/classes"/> |
| 71 |
</target> |
| 72 |
|
| 73 |
<target name="verify" depends="package"> |
| 74 |
<as:check-signature> |
| 75 |
<classpath path="build/${ant.project.name}.jar"/> |
| 76 |
</as:check-signature> |
| 77 |
</target> |
| 78 |
|
| 79 |
<target name="build-signatures"> |
| 80 |
<as:build-signatures destfile="build/jdk.sig"> |
| 81 |
<path> |
| 82 |
<fileset dir="\${java.home}" includes="lib/rt.jar"/> |
| 83 |
<fileset dir="\${java.home}" includes="lib/jce.jar"/> |
| 84 |
<fileset dir="\${java.home}" includes="lib/jsse.jar"/> |
| 85 |
</path> |
| 86 |
</as:build-signatures> |
| 87 |
</target> |
| 88 |
|
| 89 |
<target name="compile-api1"> |
| 90 |
<mkdir dir="build/api1"/> |
| 91 |
<javac srcdir="src/api1/java" destdir="build/api1" fork="true"/> |
| 92 |
</target> |
| 93 |
|
| 94 |
<target name="compile-api2"> |
| 95 |
<mkdir dir="build/api2"/> |
| 96 |
<javac srcdir="src/api2/java" destdir="build/api2" fork="true"/> |
| 97 |
</target> |
| 98 |
|
| 99 |
<target name="package-api1" depends="compile-api1"> |
| 100 |
<mkdir dir="build"/> |
| 101 |
<jar destfile="build/api1.jar" basedir="build/api1"/> |
| 102 |
</target> |
| 103 |
|
| 104 |
<target name="package-api2" depends="compile-api2"> |
| 105 |
<mkdir dir="build"/> |
| 106 |
<jar destfile="build/api2.jar" basedir="build/api2"/> |
| 107 |
</target> |
| 108 |
|
| 109 |
<target name="build-signatures-api1" depends="package-api1"> |
| 110 |
<as:build-signatures destfile="build/api1.sig"> |
| 111 |
<path> |
| 112 |
<fileset dir="build" includes="api1.jar"/> |
| 113 |
</path> |
| 114 |
</as:build-signatures> |
| 115 |
</target> |
| 116 |
|
| 117 |
<target name="build-signatures-api2" depends="package-api2"> |
| 118 |
<as:build-signatures destfile="build/api2.sig"> |
| 119 |
<path> |
| 120 |
<fileset dir="build" includes="api2.jar"/> |
| 121 |
</path> |
| 122 |
</as:build-signatures> |
| 123 |
</target> |
| 124 |
|
| 125 |
<target name="check-signatures-api1" depends="package, build-signatures-api1"> |
| 126 |
<!-- |
| 127 |
in this case we are checking signatures not of the jdk, but of our API |
| 128 |
so we need to add the classpath of the jdk, or else we will have |
| 129 |
an error due to java.lang.Object being undefined |
| 130 |
--> |
| 131 |
<as:check-signature signature="build/api1.sig" classpathRef="jre"> |
| 132 |
<path path="build/${ant.project.name}.jar"/> |
| 133 |
<ignore className="java.*"/> |
| 134 |
<ignore className="javax.*"/> |
| 135 |
</as:check-signature> |
| 136 |
</target> |
| 137 |
|
| 138 |
<target name="check-signatures-api2" depends="package, build-signatures-api2"> |
| 139 |
<!-- |
| 140 |
in this case we are checking signatures not of the jdk, but of our API |
| 141 |
so we need to add the classpath of the jdk, or else we will have |
| 142 |
an error due to java.lang.Object being undefined |
| 143 |
--> |
| 144 |
<as:check-signature signature="build/api2.sig" classpathRef="jre"> |
| 145 |
<path path="build/${ant.project.name}.jar"/> |
| 146 |
<ignore className="java.*"/> |
| 147 |
<ignore className="javax.*"/> |
| 148 |
</as:check-signature> |
| 149 |
</target> |
| 150 |
|
| 151 |
</project> |
| 152 |
--- |