Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2007 / build / build.xml @ 33449

History | View | Annotate | Download (9.76 KB)

1
<project name="gvSIG build" basedir="../.." 
2
                 default="mvn-configure-eclipse-workspace" 
3
                 xmlns:artifact="antlib:org.apache.maven.artifact.ant">
4

    
5
        <description>
6
                Ant tasks and macros to interact with maven
7
        </description>
8

    
9
        <!-- set global properties for this build -->
10
        <dirname file="${ant.file.Complete_build_system}" property="ant.file.Complete_build_system.dir"/>
11
        <dirname file="${ant.file.Complete_build_system.dir}" property="workspace_loc"/>
12

    
13
        <property name="mavendir" location="${ant.file.Complete_build_system.dir}/maven" />
14
        <!--property environment="environment"/-->
15
        <property name="ant.libs.dir" location="../../ant-tasks"/>
16

    
17
        <!-- ============================= -->
18
        <!-- External ant tasks definition -->
19
        <!-- ============================= -->
20

    
21
        <!-- Maven ant tasks registration -->
22
        <path id="maven-ant-tasks.classpath" path="${ant.libs.dir}/maven-ant-tasks-2.0.10.jar" />
23
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
24
           uri="antlib:org.apache.maven.artifact.ant"
25
           classpathref="maven-ant-tasks.classpath" />
26

    
27
        <!-- ant-contrib library load -->
28
        <taskdef resource="net/sf/antcontrib/antlib.xml">
29
                <classpath>
30
                        <pathelement location="${ant.libs.dir}/ant-contrib-1.0b3.jar"/>
31
                        <pathelement location="${ant.libs.dir}/bcel-5.1.jar"/>
32
                        <pathelement location="${ant.libs.dir}/commons-httpclient-3.0.1.jar"/>
33
                        <pathelement location="${ant.libs.dir}/commons-logging-1.0.4.jar"/>
34
                        <pathelement location="${ant.libs.dir}/ivy-1.3.1.jar"/>
35
                </classpath>
36
        </taskdef>
37

    
38
        <!-- Maven targets -->
39
        <macrodef name="maven">
40
                <attribute name="arg" />
41
                <sequential>
42
                        <echo>mvn @{arg}</echo>
43
                        <artifact:mvn mavenHome="../../maven" fork="true" failonerror="true">
44
                                <arg line="@{arg}"/>
45
                        </artifact:mvn>
46
                </sequential>
47
        </macrodef>
48

    
49
        <target name="mvn-clean" 
50
                        description="Cleans all artifacts">
51
                <maven arg="clean" />
52
        </target>
53

    
54
        <target name="mvn-install" 
55
                        description="Compiles and installs">
56
                <maven arg="install" />
57
        </target>
58

    
59
        <target name="mvn-install-without-tests" 
60
                         description="Compiles and installs without launching tests">
61
                <maven arg="-Dmaven.test.skip=true install" />
62
        </target>
63

    
64
        <target name="mvn-reinstall" depends="mvn-clean,mvn-install" 
65
                    description="Performs a clean install"/>
66

    
67
        <target name="mvn-reinstall-without-tests" 
68
                        depends="mvn-clean,mvn-install-without-tests" 
69
                        description="Performs a clean install without launching tests"/>
70

    
71
        <target name="mvn-deploy" 
72
                        description="Compiles, installs and deploys">
73
                <maven arg="deploy" />
74
        </target>
75

    
76
        <target name="mvn-configure-eclipse-workspace"
77
                        description="Configures the eclipse workspace for maven integration">
78

    
79
                <input message="Eclipse workspace folder to configure?:"
80
                           addproperty="eclipse.workspace"
81
                           defaultvalue="${workspace_loc}"/>
82

    
83
                <maven arg="-Declipse.workspace='${eclipse.workspace}' eclipse:add-maven-repo" />
84
                <mkdir dir="${eclipse.workspace}/.metadata/.plugins/org.eclipse.ui.workbench" />
85
                <copy file="../../metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml"  
86
                          todir="${eclipse.workspace}/.metadata/.plugins/org.eclipse.ui.workbench" />
87
        </target>
88

    
89
        <target name="mvn-eclipse-clean"
90
                        description="Cleans the maven generated eclipse project files">
91
                <maven arg="eclipse:clean" />
92
        </target>
93

    
94
        <target name="mvn-eclipse-eclipse"
95
                        description="Generates an eclipse project configuration from the pom.xml">
96
                <maven arg="eclipse:eclipse" />
97
        </target>
98

    
99
        <target name="mvn-create-library"
100
                        description="Generates a new library project with the initial structure and configuration">
101

    
102
                <input message="Library maven groupId:"
103
                           addproperty="lib.groupId"
104
                           defaultvalue="org.gvsig" />
105

    
106
                <input message="Library maven artifactId:"
107
                           addproperty="lib.artifactId"/>
108

    
109
                <input message="Library main java package:"
110
                           addproperty="lib.package"
111
                           defaultvalue="${lib.artifactId}"/>
112

    
113
                <input message="Library version:"
114
                           addproperty="lib.version"
115
                           defaultvalue="2.0-SNAPSHOT" />
116

    
117
                <maven arg="archetype:generate -B -DarchetypeGroupId=org.gvsig -DarchetypeArtifactId=org.gvsig.library-archetype -DgroupId=${lib.groupId} -DartifactId=${lib.artifactId} -Dversion=${lib.version} -Dpackage=${lib.package}" />
118

    
119
                <move todir="../../../${lib.artifactId}">
120
                        <fileset dir="${lib.artifactId}" />
121
                </move>
122

    
123
                <artifact:mvn mavenHome="../../maven" fork="true" failonerror="true"
124
                                          dir="../../../${lib.artifactId}">
125
                        <arg line="eclipse:eclipse"/>
126
                </artifact:mvn>
127
        </target>
128

    
129
        <!-- Projects checkout targets -->
130
        <target name="svn.checkout.all" depends="svn.getparams" description="Checkouts all projects defined in a parent module pom.xml">
131

    
132
                <artifact:pom id="pom" file="pom.xml" />
133
                <for list="${pom.modules}" param="svn.module" delimiter=",[]" trim="true">
134
                        <sequential>
135
                                <var name="svn.isgroup" unset="true"/>
136
                                <propertyregex property="svn.module"
137
                                      input="@{svn.module}"
138
                                      regexp="[./]*(.*)"
139
                                      replace="\1"
140
                                      casesensitive="false" 
141
                                              override="true"/>
142
                                <available file="../${svn.module}" property="svn.isgroup"/>
143
                                <antcall target="svn.checkout.group">
144
                                        <param name="svn.module" value="${svn.module}"/>
145
                                </antcall>
146
                                <antcall target="svn.checkout.project">
147
                                        <param name="svn.module" value="${svn.module}"/>
148
                                </antcall>
149
                        </sequential>
150
                </for>
151
        </target>
152

    
153
        <target name="svn.update.all"  
154
                        description="Updates all projects defined in a parent module pom.xml">
155

    
156
                <artifact:pom id="pom" file="pom.xml" />
157
                <for list="${pom.modules}" param="svn.module" delimiter=",[]" trim="true">
158
                        <sequential>
159
                                <var name="svn.isgroup" unset="true"/>
160
                                <propertyregex property="svn.module"
161
                                      input="@{svn.module}"
162
                                      regexp="[./]*(.*)"
163
                                      replace="\1"
164
                                      casesensitive="false" 
165
                                              override="true"/>
166
                                <available file="../${svn.module}" property="svn.isgroup"/>
167
                                <antcall target="svn.update.group">
168
                                        <param name="svn.module" value="${svn.module}"/>
169
                                </antcall>
170
                                <antcall target="svn.update.project">
171
                                        <param name="svn.module" value="${svn.module}"/>
172
                                </antcall>
173
                        </sequential>
174
                </for>
175
        </target>
176

    
177
        <target name="svn.checkout.group" if="svn.isgroup">
178
                <echo>group: ${svn.module}</echo>
179
                <ant dir="../${svn.module}" target="svn.checkout.all"/>
180
        </target>
181

    
182
        <target name="svn.checkout.project" unless="svn.isgroup" 
183
                        depends="svn.get.project.path">
184
                <echo>project: ${svn.module}</echo>
185
                <antcall target="svn.checkout">
186
                        <param name="svn.project.path" value="../../.."/>
187
                        <param name="svn.project.url" value="${svn.repository.url}/${svn.module}"/>
188
                </antcall>
189
        </target>
190

    
191
        <target name="svn.update.group" if="svn.isgroup">
192
                <echo>group: ${svn.module}</echo>
193
                <ant dir="../${svn.module}" target="svn.update.all"/>
194
        </target>
195

    
196
        <target name="svn.update.project" unless="svn.isgroup" 
197
                        depends="svn.get.project.path">
198
                <echo>project: ${svn.module}</echo>
199
                <antcall target="svn.update">
200
                        <param name="svn.project.path" value="../../.."/>
201
                        <param name="svn.project.url" value="${svn.repository.url}/${svn.module}"/>
202
                </antcall>
203
        </target>
204

    
205
        <target name="svn.checkout">
206
                <echo>url: ${svn.project.url}</echo>
207
                <java classname="org.tmatesoft.svn.cli.SVN" 
208
          dir="${svn.project.path}" 
209
          fork="true" 
210
          failonerror="true">
211
                        <arg value="co" />
212
                        <arg value="--username"/>
213
                        <arg value="${svn.username}"/>
214
                        <arg value="--password"/>
215
                        <arg value="${svn.password}"/>
216
                        <arg value="${svn.project.url}" />
217
                        <classpath>
218
                                <pathelement location="${ant.libs.dir}/svnkit-1.2.3.jar" />
219
                                <pathelement location="${ant.libs.dir}/svnkit-cli-1.2.3.jar" />
220
                        </classpath>
221
                </java>
222
        </target>
223

    
224
        <target name="svn.update">
225
                <java classname="org.tmatesoft.svn.cli.SVN" 
226
                  dir="${svn.project.path}" 
227
                  fork="true" 
228
                  failonerror="true">
229
                        <arg value="update" />
230
                        <arg value="${svn.module}" />
231
                        <classpath>
232
                                <pathelement location="${ant.libs.dir}/svnkit-1.2.3.jar" />
233
                                <pathelement location="${ant.libs.dir}/svnkit-cli-1.2.3.jar" />
234
                        </classpath>
235
                </java>
236
        </target>
237

    
238
        <target name="svn.getparams">
239
                <input
240
            addproperty="svn.repository.url.option"
241
                  defaultvalue="a">
242
                  Select one SVN url to the branch to checkout:
243
                  a) Public (http://subversion.gvsig.org/gvSIG/branches/v2_0_0_prep)
244
                  b) Development (https://gvsig.org/svn/gvSIG/branches/v2_0_0_prep)
245
            </input>
246

    
247
                <condition property="svn.repository.url" 
248
                                     value="https://gvsig.org/svn/gvSIG/branches/v2_0_0_prep"
249
                                     else="http://subversion.gvsig.org/gvSIG/branches/v2_0_0_prep">
250
                        <equals arg1="${svn.repository.url.option}" arg2="b"/>
251
                </condition>
252

    
253
                <input
254
            message="SVN user name:"
255
            addproperty="svn.username"
256
              defaultvalue="guest" />
257

    
258
                <input
259
            message="SVN user password:"
260
            addproperty="svn.password"
261
                  defaultvalue="guest" />
262
        </target>
263

    
264
        <target name="svn.get.project.path">
265
                <description>
266
                        Converts a project name to a project path in subversion. 
267
                        Ej: libTools -> libraries/libTools
268
                </description>
269
                <propertyregex property="svn.module"
270
                      input="${svn.module}"
271
                      regexp="^lib.*"
272
                      replace="libraries/\0"
273
                      casesensitive="false" 
274
                              override="true"/>
275
                <propertyregex property="svn.module"
276
                      input="${svn.module}"
277
                      regexp="^ext.*"
278
                      replace="extensions/\0"
279
                      casesensitive="false" 
280
                              override="true"/>
281
                <propertyregex property="svn.module"
282
                      input="${svn.module}"
283
                      regexp="^app.*"
284
                      replace="applications/\0"
285
                      casesensitive="false" 
286
                              override="true"/>
287
                <propertyregex property="svn.module"
288
                      input="${svn.module}"
289
                      regexp="^_fw.*"
290
                      replace="frameworks/\0"
291
                      casesensitive="false" 
292
                              override="true"/>
293
        </target>
294

    
295
</project>