aboutsummaryrefslogtreecommitdiffstats
path: root/tools/antipede/build.xtarget
blob: 90957cfc85c5e2788d752c70f60f1bc0b6b50e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
  <target name="-init">
   <tstamp>
     <format property="YEAR" pattern="yyyy" locale="en"/>
   </tstamp>
   
   <buildnumber/>
   <echo>
    --------------------------------------------------------------

      Using ${ant.version}
      Build file ${ant.file}
      Build number ${build.number}
      Project Name ${ant.project.name}
      Java Version ${ant.java.version}      
      Timestamp ${DSTAMP}${TSTAMP}

    --------------------------------------------------------------
   </echo>
       
   <!--
    The location of tools.jar, relative to the JAVA_HOME home.
    If tools.jar is not present, exit with an error, since it
    means that a JDK is not installed.
    -->
    <property name="tools.jar" value="${java.home}/../lib/tools.jar"/>
    <available file="${tools.jar}" property="tools.jar.present"/>
    <fail unless="tools.jar.present" message="tools.jar not found. Probably JDK not installed."/>    


    <!-- fixed centipede dirs -->
    <property name="tools.dir"                   value="tools"/>
    
    <property name="temp.dir"                    value="tools/tmp"/>
    <mkdir   dir="${temp.dir}"/>
    <property name="cents.dir"                   value="tools/cents"/>
    <mkdir   dir="${cents.dir}"/>
        
    <property name="antipede.dir"                value="tools/antipede"/>
    <property name="antipede.lib.dir"            value="tools/antipede/lib"/>
    
    <property name="cent.lib.dir.name"           value="lib"/>
    <property name="task.properties.name"        value="tasks.properties"/>
    <property name="cent.jar.suffix"             value="cent.jar"/>    
    <property name="cent.dir.suffix"             value="cent"/>    
    
                        
    <!-- define all ant tasks in antipede -->
    <taskdef file="${antipede.dir}/${task.properties.name}">
     <classpath>
      <path>
       <fileset dir="${antipede.lib.dir}" casesensitive="yes"> 
         <include name="*.jar"/>
         <include name="*.zip"/>
       </fileset>  
      </path>
     </classpath>
    </taskdef>
    
    <!--
    Load project information
    -->
    <xmlproperty file="module.xml"     prefix="xgump"    keeproot="true"  collapseAttributes="true" />
    <xmlproperty file="status.xml"     prefix="xstatus"  keeproot="false" collapseAttributes="true" />   
    <xmlproperty file="layout.xml"     prefix="xlayout"  keeproot="false" collapseAttributes="true" />
    <xmlproperty file="properties.xml"                   keeproot="false" collapseAttributes="true" />
    
    <antcall target="get-needed-cents"/>

    <delete file="${temp.dir}/${task.properties.name}"/>
                        
    <!-- put all ant task definitions in cents in a single file -->
    <antipede-trycatch><try>
    
    <concat destfile="${temp.dir}/${task.properties.name}" append="no">
      <fileset dir=".">
       <patternset>
         <include name="${cents.dir}/*.${cent.dir.suffix}/${task.properties.name}"/>
       </patternset>
     </fileset>          
    </concat>

    <!-- define the tasks found in cents -->
    <taskdef file="${temp.dir}/${task.properties.name}">
     <classpath>      
      <fileset dir="./tools">
        <include name="**/*.jar"/>
      </fileset>
     </classpath>
    </taskdef>
    
    </try>
    <catch><echo message="Unable to load tasks... could be already loaded." /></catch>
    </antipede-trycatch>

   
  </target>

  <!-- ================================ -->
  <!--  Used only by the -init target   -->
  <!-- =================================--> 
  <target  name="get-needed-cents">
  
    <style basedir="."
           destdir="${temp.dir}"
           includes="properties.xml"
           extension=".build.xml"
           style="${antipede.dir}/resources/stylesheets/getcent.xsl"/>
           
    <ant antfile="${temp.dir}/properties.build.xml"
         inheritall="true" 
         dir="."
         target="getcents" />        

    <style basedir="."
           destdir="${temp.dir}"
           includes="module.xml"
           extension=".build.xml"
           style="${antipede.dir}/resources/stylesheets/getcorelibs.xsl"/>
<!--           
     <ant antfile="${temp.dir}/module.build.xml"
         inheritall="true" 
         dir="."
         target="getcorelibs" />        
-->
    
    <!-- Unpack jarred cents -->
    <antipede-foreach target="-cent-unjar" param="current.cent.jar">
     <fileset dir="." casesensitive="yes"> 
      <patternset>
       <include name="${cents.dir}/*.${cent.jar.suffix}"/>
      </patternset>
     </fileset>  
    </antipede-foreach>

    <delete dir="${cents.dir}/META-INF"/>  
    
  </target>   
  
  <!-- ================================ -->
  <!--  Used only by the -init target   -->
  <!-- =================================--> 
  <target  name="-cent-unjar" depends="-cent-unjar-expand,-cent-unjar-keep"/>      
  
  <!-- ================================ -->
  <!--  Used only by the -init target   -->
  <!-- =================================--> 
  <target  name="-cent-unjar-check">
      
    <basename property="current.cent.jar.name" file="${current.cent.jar}" suffix=".jar"/>
    
    <condition property="cent-unjar.not.required">
      <and>
        <uptodate targetfile="${cents.dir}/${current.cent.jar.name}.${cent.dir.suffix}/${task.properties.name}"
                  srcfile="${current.cent.jar}"/>
        <available type="file" file="${cents.dir}/${current.cent.jar.name}.${cent.dir.suffix}/${task.properties.name}"/>
      </and>
    </condition>
 
  </target>       

  <!-- ====================================== -->
  <!--  Used only by the -cent-unjar target   -->
  <!-- ====================================== --> 
  <target  name="-cent-unjar-expand" unless="cent-unjar.not.required" 
           depends="-cent-unjar-check">
      <echo message="Expanding ${current.cent.jar}..." />
      <unjar src="${current.cent.jar}" dest="${cents.dir}"/> 
      <touch>
        <fileset dir="${cents.dir}/${current.cent.jar.name}.${cent.dir.suffix}"/>
      </touch>      
      <echo message="... ${current.cent.jar} expanded in ${current.cent.jar.name}." />    
  </target> 

  <!-- ====================================== -->
  <!--  Used only by the -cent-unjar target   -->
  <!-- =======================================--> 
  <target  name="-cent-unjar-keep" if="cent-unjar.not.required"
           depends="-cent-unjar-check">
      <echo message="${current.cent.jar} is uptodate with respect to ${current.cent.jar.name}." />
      <echo message="No need to expand it." />
  </target> 
            
  <!-- ============================================= -->
  <!-- Simple utility target to call a cent target   -->
  <!-- ==============================================-->
  <target name="call-cent">
     <ant antfile="tools/cents/${cent-name}.cent/xbuild.xml"
         inheritall="true" 
         dir="."
         target="${cent-target}" />       
  </target>            
  
  
  <!-- ================================== -->
  <!--   Create a cent.jar package        -->
  <!--   using an already deployed cent   -->
  <!-- ================================== -->
  
  <target  name="jar-cent"   depends="-init">

    <antcall target="call-cent">
      <param name="cent-name"   value="centipede"/> 
      <param name="cent-target" value="jar-cent"/> 
    </antcall>
    
  </target>      

  <!-- ================================== -->
  <!--   Create a cent.jar package        -->
  <!--   using an already deployed cent   -->
  <!-- ================================== -->
  
  <target  name="update-cent">

    <centipede-user-input name="cent-name">Please select a cent to update: </centipede-user-input> 
    <delete file="${cents.dir}/${cent-name}.${cent.jar.suffix}"/>
    <delete  dir="${cents.dir}/${cent-name}.${cent.dir.suffix}"/>
    
    <antcall target="get-needed-cents"/>
            
  </target>   

  <!-- ================================== -->
  <!--   Create a cent.jar package        -->
  <!--   using an already deployed cent   -->
  <!-- ================================== -->
  
  <target  name="update-all-cents">
  
    <property name="yn" value="n"/>
    <centipede-user-input name="yn">This will delete and download all cents. Are you sure? [y/n]: </centipede-user-input> 
   
   
    <condition property="stopit">
     <not>
      <equals arg1="${yn}" arg2="y"/>
     </not>
    </condition>

    <fail if="stopit"/>
   
    <delete  dir="${cents.dir}"/>
    <mkdir   dir="${cents.dir}"/>
    
    <antcall target="get-needed-cents"/>
    
  </target>   
      
  <!-- ================================== -->
  <!--   Create a cent.jar package        -->
  <!--   using an already deployed cent   -->
  <!-- ================================== -->
  
  <target  name="create-dtd"   depends="-init">
    <antstructure output="${xlayout.build.dir}/build.dtd"/>
  </target>