Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / build / build.xml @ 29319

History | View | Annotate | Download (9.7 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 pom="../../../${lib.artifactId}/pom.xml">
124
                        <arg value="eclipse:eclipse" />
125
                </artifact:mvn>
126
        </target>
127

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
294
</project>