| 1 |
<?xml version="1.0"?> |
|---|
| 2 |
|
|---|
| 3 |
<!-- =================================================================== |
|---|
| 4 |
Define a macro to fetch jars from the bedework repository or from |
|---|
| 5 |
the generated library in the named project. |
|---|
| 6 |
|
|---|
| 7 |
IF a project is named and we cannot locate the named file we try the |
|---|
| 8 |
repository. |
|---|
| 9 |
|
|---|
| 10 |
For jars fetched from the archive we have a two step process, first check |
|---|
| 11 |
that a copy in a local cache is up to date, second copy from the local cache |
|---|
| 12 |
into the final destination. This allows the caller to delete and recreate the |
|---|
| 13 |
destination, ensuring that jar version changes don't result in multiple |
|---|
| 14 |
copies of a jar. |
|---|
| 15 |
|
|---|
| 16 |
@param name Name of the jar e.g. junit |
|---|
| 17 |
@param version optional version for the jar |
|---|
| 18 |
@param src optional url for the get task |
|---|
| 19 |
@param lib optional destination for the get task |
|---|
| 20 |
@param libcache optional location of the cache |
|---|
| 21 |
@param property optional name of property to hold location of resulting jar |
|---|
| 22 |
@param project optional project name for local fetch from generated quickstart. |
|---|
| 23 |
=================================================================== --> |
|---|
| 24 |
<project name="getJar" basedir="." default=""> |
|---|
| 25 |
<macrodef name="getJar"> |
|---|
| 26 |
<attribute name="name"/> |
|---|
| 27 |
<attribute name="version" default="" /> |
|---|
| 28 |
<attribute name="src" default="http://bedework.org/downloads/lib"/> |
|---|
| 29 |
<attribute name="lib" default="${lib.dir}"/> |
|---|
| 30 |
<attribute name="libcache" default="${org.bedework.libcache.dir}"/> |
|---|
| 31 |
<attribute name="property" default="" /> |
|---|
| 32 |
<attribute name="project" default="" /> |
|---|
| 33 |
<attribute name="projectHome" default="" /> |
|---|
| 34 |
<sequential> |
|---|
| 35 |
<taskdef resource="net/sf/antcontrib/antcontrib.properties" /> |
|---|
| 36 |
|
|---|
| 37 |
<mkdir dir="@{libcache}" /> |
|---|
| 38 |
|
|---|
| 39 |
<!-- Names are of form |
|---|
| 40 |
<name-part>-<version>.jar or |
|---|
| 41 |
<name-part>.jar |
|---|
| 42 |
--> |
|---|
| 43 |
|
|---|
| 44 |
<if> |
|---|
| 45 |
<equals arg1="@{version}" arg2="" /> |
|---|
| 46 |
<then> |
|---|
| 47 |
<var name="org.bedework.getjar.jarname" value="@{name}.jar" /> |
|---|
| 48 |
</then> |
|---|
| 49 |
<else> |
|---|
| 50 |
<var name="org.bedework.getjar.jarname" value="@{name}-@{version}.jar" /> |
|---|
| 51 |
</else> |
|---|
| 52 |
</if> |
|---|
| 53 |
|
|---|
| 54 |
<!-- Ensure projectHome is set to something |
|---|
| 55 |
--> |
|---|
| 56 |
|
|---|
| 57 |
<if> |
|---|
| 58 |
<equals arg1="@{projectHome}" arg2="" /> |
|---|
| 59 |
<then> |
|---|
| 60 |
<var name="org.bedework.getjar.projecthome" |
|---|
| 61 |
value="${project.home}/../@{project}" /> |
|---|
| 62 |
</then> |
|---|
| 63 |
<else> |
|---|
| 64 |
<var name="org.bedework.getjar.projecthome" value="@{projectHome}" /> |
|---|
| 65 |
</else> |
|---|
| 66 |
</if> |
|---|
| 67 |
|
|---|
| 68 |
<var name="org.bedework.getjar.dest" |
|---|
| 69 |
value="@{lib}/${org.bedework.getjar.jarname}" /> |
|---|
| 70 |
|
|---|
| 71 |
<var name="org.bedework.getjar.finished" value="false" /> |
|---|
| 72 |
|
|---|
| 73 |
<!-- If a project or projecthome was specified try to get it from the |
|---|
| 74 |
local file system |
|---|
| 75 |
--> |
|---|
| 76 |
<if> |
|---|
| 77 |
<or> |
|---|
| 78 |
<not> |
|---|
| 79 |
<equals arg1="@{project}" arg2="" /> |
|---|
| 80 |
</not> |
|---|
| 81 |
<not> |
|---|
| 82 |
<equals arg1="@{projecthome}" arg2="" /> |
|---|
| 83 |
</not> |
|---|
| 84 |
</or> |
|---|
| 85 |
<then> |
|---|
| 86 |
<var name="org.bedework.getjar.project.jar" |
|---|
| 87 |
value="${org.bedework.getjar.projecthome}/dist/${org.bedework.getjar.jarname}" /> |
|---|
| 88 |
<noisyMsg message="check ${org.bedework.getjar.project.jar}" /> |
|---|
| 89 |
|
|---|
| 90 |
<if> |
|---|
| 91 |
<available file="${org.bedework.getjar.project.jar}" /> |
|---|
| 92 |
<then> |
|---|
| 93 |
<!-- Say we found the file --> |
|---|
| 94 |
<var name="org.bedework.getjar.finished" value="true" /> |
|---|
| 95 |
|
|---|
| 96 |
<if> |
|---|
| 97 |
<not> |
|---|
| 98 |
<uptodate srcfile="${org.bedework.getjar.project.jar}" |
|---|
| 99 |
targetfile="${org.bedework.getjar.dest}" /> |
|---|
| 100 |
</not> |
|---|
| 101 |
<then> |
|---|
| 102 |
<noisyMsg message="Fetch ${org.bedework.getjar.jarname} from project @{project}" /> |
|---|
| 103 |
<copy file="${org.bedework.getjar.project.jar}" |
|---|
| 104 |
todir="@{lib}" overwrite="yes" preservelastmodified="true" /> |
|---|
| 105 |
</then> |
|---|
| 106 |
</if> |
|---|
| 107 |
</then> |
|---|
| 108 |
</if> |
|---|
| 109 |
</then> |
|---|
| 110 |
</if> |
|---|
| 111 |
|
|---|
| 112 |
<!-- if org.bedework.getjar.finished is true we found a local file, |
|---|
| 113 |
otherwise we need to check the repository. --> |
|---|
| 114 |
|
|---|
| 115 |
<if> |
|---|
| 116 |
<equals arg1="${org.bedework.getjar.finished}" arg2="false" /> |
|---|
| 117 |
<then> |
|---|
| 118 |
<if> |
|---|
| 119 |
<equals arg1="${org.bedework.offline.build}" arg2="yes" /> |
|---|
| 120 |
<then> |
|---|
| 121 |
<noisyMsg message="Offline: skip check for ${org.bedework.getjar.jarname}" /> |
|---|
| 122 |
</then> |
|---|
| 123 |
<else> |
|---|
| 124 |
<!-- Not offline - check repository --> |
|---|
| 125 |
<noisyMsg message="Fetch ${org.bedework.getjar.jarname} from archive" /> |
|---|
| 126 |
<get src="@{src}/${org.bedework.getjar.jarname}" |
|---|
| 127 |
dest="@{libcache}/${org.bedework.getjar.jarname}" |
|---|
| 128 |
ignoreerrors="true" |
|---|
| 129 |
verbose="${org.bedework.getjar.noisy}" |
|---|
| 130 |
usetimestamp="true"/> |
|---|
| 131 |
</else> |
|---|
| 132 |
</if> |
|---|
| 133 |
|
|---|
| 134 |
<if> |
|---|
| 135 |
<not> |
|---|
| 136 |
<available file="@{libcache}/${org.bedework.getjar.jarname}" /> |
|---|
| 137 |
</not> |
|---|
| 138 |
<then> |
|---|
| 139 |
<echo message="******************************************************" /> |
|---|
| 140 |
<echo message="File ${org.bedework.getjar.jarname} is not available" /> |
|---|
| 141 |
<echo message="******************************************************" /> |
|---|
| 142 |
</then> |
|---|
| 143 |
<else> |
|---|
| 144 |
<if> |
|---|
| 145 |
<isset property="org.bedework.getjar.jar.listfile" /> |
|---|
| 146 |
<then> |
|---|
| 147 |
<!-- Write the name to the list --> |
|---|
| 148 |
<echo file="${org.bedework.getjar.jar.listfile}" |
|---|
| 149 |
append="yes" |
|---|
| 150 |
message="@{name}" /> |
|---|
| 151 |
</then> |
|---|
| 152 |
</if> |
|---|
| 153 |
|
|---|
| 154 |
<copy file="@{libcache}/${org.bedework.getjar.jarname}" |
|---|
| 155 |
todir="@{lib}" overwrite="yes" preservelastmodified="true" /> |
|---|
| 156 |
</else> |
|---|
| 157 |
</if> |
|---|
| 158 |
|
|---|
| 159 |
</then> |
|---|
| 160 |
</if> |
|---|
| 161 |
|
|---|
| 162 |
<if> |
|---|
| 163 |
<not> |
|---|
| 164 |
<equals arg1="@{property}" arg2="" /> |
|---|
| 165 |
</not> |
|---|
| 166 |
<then> |
|---|
| 167 |
<noisyMsg message="set property @{property} to ${org.bedework.getjar.dest}" /> |
|---|
| 168 |
|
|---|
| 169 |
<property name="@{property}" location="${org.bedework.getjar.dest}" /> |
|---|
| 170 |
</then> |
|---|
| 171 |
<elseif> |
|---|
| 172 |
<isset property="org.bedework.getjar.property.prefix" /> |
|---|
| 173 |
<then> |
|---|
| 174 |
<noisyMsg message="set property ${org.bedework.getjar.property.prefix}.@{name} to ${org.bedework.getjar.dest}" /> |
|---|
| 175 |
|
|---|
| 176 |
<property name="${org.bedework.getjar.property.prefix}.@{name}" |
|---|
| 177 |
location="${org.bedework.getjar.dest}" /> |
|---|
| 178 |
</then> |
|---|
| 179 |
</elseif> |
|---|
| 180 |
<else> |
|---|
| 181 |
<noisyMsg message="set property org.bedework.getjar.jarloc.@{name} to ${org.bedework.getjar.dest}" /> |
|---|
| 182 |
|
|---|
| 183 |
<property name="org.bedework.getjar.jarloc.@{name}" |
|---|
| 184 |
location="${org.bedework.getjar.dest}" /> |
|---|
| 185 |
</else> |
|---|
| 186 |
</if> |
|---|
| 187 |
</sequential> |
|---|
| 188 |
</macrodef> |
|---|
| 189 |
</project> |
|---|