root/trunk/build/getJar.xml

Revision 1894 (checked in by douglm, 5 years ago)

More changes to the build process. Main build now pulls jars out of the archive and out of each projects bin directory.

Also remove some unused ant build code.

Not yet complete but close.

  • Property svn:eol-style set to LF
Line 
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 localtion 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="@{lib}/../libcache"/>
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           <echo 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                   <echo message="Fetch ${org.bedework.getjar.jarname} from project @{project}" />
103                   <copy file="${org.bedework.getjar.project.jar}"
104                         todir="@{lib}" overwrite="yes" />
105                 </then>
106               </if>
107             </then>
108           </if>
109         </then>
110       </if>
111
112       <if>
113         <equals arg1="${org.bedework.getjar.finished}" arg2="false" />
114         <then>
115           <echo message="Fetch ${org.bedework.getjar.jarname} from archive" />
116           <get src="@{src}/${org.bedework.getjar.jarname}"
117                dest="@{libcache}/${org.bedework.getjar.jarname}"
118                ignoreerrors="true"
119                verbose="true"
120                usetimestamp="true"/>
121
122           <copy file="@{libcache}/${org.bedework.getjar.jarname}"
123                 todir="@{lib}" overwrite="yes" />
124         </then>
125       </if>
126
127       <if>
128         <not>
129           <equals arg1="@{property}" arg2="" />
130         </not>
131         <then>
132           <echo message="set property @{property} to ${org.bedework.getjar.dest}" />
133           <property name="@{property}" location="${org.bedework.getjar.dest}" />
134         </then>
135         <elseif>
136           <isset property="org.bedework.getjar.property.prefix" />
137           <then>
138             <echo message="set property ${org.bedework.getjar.property.prefix}.@{name} to ${org.bedework.getjar.dest}" />
139             <property name="${org.bedework.getjar.property.prefix}.@{name}"
140                       location="${org.bedework.getjar.dest}" />
141           </then>
142         </elseif>
143         <else>
144           <echo message="set property org.bedework.getjar.jarloc.@{name} to ${org.bedework.getjar.dest}" />
145           <property name="org.bedework.getjar.jarloc.@{name}"
146                     location="${org.bedework.getjar.dest}" />
147         </else>
148       </if>
149     </sequential>
150   </macrodef>
151 </project>
Note: See TracBrowser for help on using the browser.