svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.58 / org.gvsig.desktop.installer / pom.xml @ 44345
History | View | Annotate | Download (15.5 KB)
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
---|---|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
3 |
|
4 |
<modelVersion>4.0.0</modelVersion> |
5 |
<groupId>org.gvsig</groupId> |
6 |
<artifactId>org.gvsig.desktop.installer</artifactId> |
7 |
<version>1.0.0</version> |
8 |
<packaging>pom</packaging> |
9 |
<name>${project.artifactId}</name> |
10 |
|
11 |
<build>
|
12 |
|
13 |
<pluginManagement>
|
14 |
<plugins>
|
15 |
|
16 |
<plugin>
|
17 |
<groupId>org.codehaus.gmaven</groupId> |
18 |
<artifactId>gmaven-plugin</artifactId> |
19 |
<version>1.4</version> |
20 |
</plugin>
|
21 |
|
22 |
<plugin>
|
23 |
<groupId>org.codehaus.mojo</groupId> |
24 |
<artifactId>properties-maven-plugin</artifactId> |
25 |
<version>1.0-alpha-2</version> |
26 |
</plugin>
|
27 |
|
28 |
</plugins>
|
29 |
</pluginManagement>
|
30 |
|
31 |
<plugins>
|
32 |
<plugin>
|
33 |
<groupId>org.codehaus.mojo</groupId> |
34 |
<artifactId>properties-maven-plugin</artifactId> |
35 |
<executions>
|
36 |
<execution>
|
37 |
<phase>install</phase> |
38 |
<goals>
|
39 |
<goal>read-project-properties</goal> |
40 |
</goals>
|
41 |
<configuration>
|
42 |
<files>
|
43 |
<!-- Define gvsig.product.folder.path in this property -->
|
44 |
<file>${env.HOME}/.gvsig-devel.properties</file> |
45 |
<file>${project.basedir}/gvsig-devel.properties</file> |
46 |
</files>
|
47 |
<quiet>true</quiet> |
48 |
</configuration>
|
49 |
</execution>
|
50 |
</executions>
|
51 |
</plugin>
|
52 |
|
53 |
<plugin>
|
54 |
<groupId>org.codehaus.gmaven</groupId> |
55 |
<artifactId>gmaven-plugin</artifactId> |
56 |
<dependencies>
|
57 |
<dependency>
|
58 |
<groupId>com.github.lookfirst</groupId> |
59 |
<artifactId>sardine</artifactId> |
60 |
<version>5.0.1</version> |
61 |
</dependency>
|
62 |
</dependencies>
|
63 |
<inherited>false</inherited> |
64 |
<executions>
|
65 |
<execution>
|
66 |
<id>release</id> |
67 |
<phase>install</phase> |
68 |
<goals>
|
69 |
<goal>execute</goal> |
70 |
</goals>
|
71 |
<configuration>
|
72 |
<source><![CDATA[ |
73 |
|
74 |
// To deploy package use: |
75 |
// mvn -Ddeploy-installers -Dusername=USER -Dpassword=PASSWORD install |
76 |
// |
77 |
|
78 |
public class WebDAVClient { |
79 |
|
80 |
def log; |
81 |
|
82 |
private String user; |
83 |
private String password; |
84 |
private Object sardine; |
85 |
|
86 |
public WebDAVClient(log) { |
87 |
this.log = log; |
88 |
} |
89 |
|
90 |
public void login(String user, String password) { |
91 |
log.info("[WEBDAV] login as '"+user+"'."); |
92 |
def SardineFactory |
93 |
try { |
94 |
SardineFactory = "com.github.sardine.SardineFactory" as Class |
95 |
} catch (Exception ex) { |
96 |
log.error("[WEBDAV] can't get SardineFactory.",ex); |
97 |
} |
98 |
this.user = user; |
99 |
this.password = password; |
100 |
this.sardine = SardineFactory.begin(this.user,this.password); |
101 |
this.sardine.enablePreemptiveAuthentication("devel.gvsig.net"); |
102 |
this.sardine.enablePreemptiveAuthentication("downloads.gvsig.net"); |
103 |
this.sardine.enablePreemptiveAuthentication("devel.gvsig.org"); |
104 |
this.sardine.enablePreemptiveAuthentication("downloads.gvsig.org"); |
105 |
} |
106 |
|
107 |
public void login() { |
108 |
log.info("[WEBDAV] login as guest"); |
109 |
this.sardine = SardineFactory.begin(); |
110 |
} |
111 |
|
112 |
public boolean exists(String url) throws Exception { |
113 |
return sardine.exists(url); |
114 |
} |
115 |
|
116 |
public void makedirs(String url) throws Exception { |
117 |
log.info("[WEBDAV] makedirs '"+url+"'."); |
118 |
URL u = new URL(url); |
119 |
String[] x = u.getPath().split("/"); |
120 |
String path = ""; |
121 |
for( int i=1; i<x.length; i++ ) { |
122 |
path = path + "/" + x[i]; |
123 |
URL t = new URL(u,path); |
124 |
mkdir(t.toString()); |
125 |
} |
126 |
} |
127 |
|
128 |
public void mkdir(String url) throws Exception { |
129 |
if( ! exists(url) ) { |
130 |
log.info("[WEBDAV] mkdir '"+url+"'."); |
131 |
sardine.createDirectory(url); |
132 |
} |
133 |
} |
134 |
|
135 |
public void put(String source, String target) throws Exception { |
136 |
log.info("[WEBDAV] put '" + source + "' to '" + target + "'..."); |
137 |
InputStream fis = new FileInputStream(new File(source)); |
138 |
sardine.put(target, fis); |
139 |
log.info("[WEBDAV] put ok."); |
140 |
} |
141 |
|
142 |
public List list(String url) throws Exception { |
143 |
List resources = sardine.list(url); |
144 |
return resources; |
145 |
} |
146 |
} |
147 |
|
148 |
def getProjectBasePath() { |
149 |
s = project.basedir.getAbsolutePath() |
150 |
return s |
151 |
} |
152 |
|
153 |
def getProjectBaseFile() { |
154 |
f = project.basedir |
155 |
return f |
156 |
} |
157 |
|
158 |
def getProjectTargetPath() { |
159 |
s = project.basedir.getAbsolutePath() +"/target" |
160 |
return s |
161 |
} |
162 |
|
163 |
def getVersionWithBuildNumber(pakageinfo) { |
164 |
return pakageinfo.getProperty("version")+"-"+pakageinfo.getProperty("buildNumber") |
165 |
} |
166 |
|
167 |
def getVersionWithoutBuildNumber(pakageinfo) { |
168 |
return pakageinfo.getProperty("version") // .replaceFirst("-[0-9]*\$","") |
169 |
} |
170 |
|
171 |
def createLauncher(source,target) { |
172 |
log.info("Creating launcher ("+source+")...") |
173 |
source = getProjectBasePath() + source |
174 |
target = getProjectBasePath() + target |
175 |
s = new File(source).text |
176 |
s = s.replaceAll("@@gvsig.product.folder.path@@", gvsig_product_folder_path) |
177 |
s = s.replaceAll("@@org.gvsig.andami.updater.jar@@", org_gvsig_andami_updater_jar) |
178 |
s = s.replaceAll("@@version@@", getVersionWithBuildNumber(pakageinfo).replace("-",".")) |
179 |
new File(target).write(s) |
180 |
log.info("Created "+target) |
181 |
ant.exec( command:"launch4jc "+ target ) |
182 |
log.info("Created launcher ("+target+").") |
183 |
} |
184 |
|
185 |
def deployInstallers() { |
186 |
if( project.properties["username"] == null ) { |
187 |
print("Enter user name: "); |
188 |
user = System.console().readLine().toString() |
189 |
if( user != "" ) { |
190 |
project.properties.setProperty("username",user); |
191 |
} |
192 |
} |
193 |
if( project.properties["password"] == null ) { |
194 |
print("Enter password for user '" + project.properties["username"] + "': "); |
195 |
password = System.console().readPassword().toString() |
196 |
if( password != "" ) { |
197 |
project.properties.setProperty("password",password); |
198 |
} |
199 |
} |
200 |
WebDAVClient session = new WebDAVClient(log); |
201 |
if( project.properties["username"] == null || project.properties["password"] == null ) { |
202 |
log.info("[WEBDAV] creating non authenticated session."); |
203 |
log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session."); |
204 |
session.login(); |
205 |
} else { |
206 |
session.login(project.properties["username"], project.properties["password"]); |
207 |
} |
208 |
// addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing" |
209 |
addonsRepo = "https://downloads.gvsig.org/download/gvsig-desktop" |
210 |
targetfolder = addonsRepo + |
211 |
"/dists/" + |
212 |
getVersionWithoutBuildNumber(pakageinfo) + |
213 |
"/builds/" + |
214 |
pakageinfo.getProperty("buildNumber") |
215 |
sourcefolder = getProjectTargetPath() |
216 |
|
217 |
session.makedirs(targetfolder); |
218 |
|
219 |
base_fname = "gvSIG-desktop-" + |
220 |
getVersionWithBuildNumber(pakageinfo) + |
221 |
"-" + |
222 |
pakageinfo.getProperty("state") |
223 |
|
224 |
fname = base_fname + "-all-x86-online.zip" |
225 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
226 |
|
227 |
fname = base_fname + "-lin-x86-online.run" |
228 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
229 |
|
230 |
fname = base_fname + "-win-x86-online.exe" |
231 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
232 |
|
233 |
session.makedirs(targetfolder+"/misc"); |
234 |
fname = base_fname + "-all-all-pool.zip" |
235 |
session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname); |
236 |
|
237 |
session.makedirs(targetfolder+"/misc"); |
238 |
fname = base_fname + "-all-all.gvspks" |
239 |
session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname); |
240 |
} |
241 |
|
242 |
def download_jre() { |
243 |
jre_pkg_name = "gvSIG-desktop-2.0.0-jre_6_windows_i586-1.6.26-0-devel-win-x86-j1_6.gvspkg" |
244 |
url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_6_windows_i586/" + jre_pkg_name |
245 |
target = getProjectTargetPath() + "/" + jre_pkg_name |
246 |
if(! new File(target).exists() ) { |
247 |
if( project.properties["jre.path"]!=null ) { |
248 |
if( project.properties["jre.path"].endsWith(".gvspkg") ) { |
249 |
source = project.properties["jre.path"] |
250 |
} else { |
251 |
source = project.properties["jre.path"] + "/" + jre_pkg_name |
252 |
} |
253 |
if (source.startsWith("~" + File.separator)) { |
254 |
source = System.getenv().get("HOME") + source.substring(1); |
255 |
} |
256 |
if( ! new File(source).exists() ) { |
257 |
log.info("jre specified in jre.path variable not found - "+source) |
258 |
log.info("Downloading windows jre plugin") |
259 |
ant.get(src: url, dest: target) |
260 |
} else { |
261 |
log.info("Copy windows jre plugin") |
262 |
ant.copy(file:source, todir:getProjectTargetPath() + "/") |
263 |
} |
264 |
} else { |
265 |
log.info("Downloading windows jre plugin") |
266 |
ant.get(src: url, dest: target) |
267 |
} |
268 |
} else { |
269 |
log.info("Skip download of jre, it exist in local filesystem.") |
270 |
} |
271 |
} |
272 |
|
273 |
def checkInstallJammerStatus() { |
274 |
logfile = getProjectTargetPath() + "/installjammer.log" |
275 |
s = new File(logfile).text |
276 |
if( s.contains("build completed with errors") ) { |
277 |
throw new RuntimeException("Can't builds installers, see installjammer.log") |
278 |
} |
279 |
} |
280 |
|
281 |
def main() { |
282 |
ant = new AntBuilder() |
283 |
log.info("For create windows launchers launch4j is requiered in the PATH. In linux link launch4j to launch4jc.") |
284 |
log.info("For create installer InstallJammer is required in the PATH.") |
285 |
|
286 |
log.info("Base path=" + getProjectBasePath()) |
287 |
|
288 |
installation_folder = getProjectTargetPath() + "/product/gvsig-desktop" |
289 |
pool_folder = getProjectTargetPath() + "/pool.d" |
290 |
new File(installation_folder).mkdirs() |
291 |
new File(pool_folder,"pool").mkdirs() |
292 |
|
293 |
gvsig_product_folder_path = project.properties["gvsig.product.folder.path"] |
294 |
|
295 |
|
296 |
log.info("Getting a local copy of product folder...") |
297 |
ant.copy( todir: installation_folder ) { |
298 |
fileset( dir: gvsig_product_folder_path ) |
299 |
} |
300 |
gvsig_product_folder_path = installation_folder |
301 |
|
302 |
|
303 |
log.info("Populate the pool folder...") |
304 |
ant.move( todir: pool_folder + "/pool" ) { |
305 |
fileset( dir: installation_folder + "/install/" ) |
306 |
} |
307 |
new File(installation_folder,"install").mkdirs() |
308 |
|
309 |
log.info("Preparing basic package set (gvspks)...") |
310 |
gvspks_folder = new File(getProjectBaseFile(),"target/gvspks") |
311 |
gvspks_folder.mkdirs() |
312 |
filenames = new FileNameFinder().getFileNames(pool_folder,"**/*.gvspkg") |
313 |
for( filename in filenames ) { |
314 |
file = new File(filename) |
315 |
ant.copy(file:filename, todir:gvspks_folder.getAbsolutePath()) |
316 |
} |
317 |
ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath()) |
318 |
|
319 |
log.info("Finding andami updater jar...") |
320 |
org_gvsig_andami_updater_jar = new FileNameFinder().getFileNames( |
321 |
gvsig_product_folder_path+"/lib", |
322 |
'org.gvsig.andami.updater-*.jar' |
323 |
)[0] |
324 |
if( org_gvsig_andami_updater_jar == null ) { |
325 |
log.error("Can't find andami updater jar") |
326 |
assert false |
327 |
} |
328 |
org_gvsig_andami_updater_jar = new File(org_gvsig_andami_updater_jar).getName() |
329 |
log.info("Found andami updater :"+org_gvsig_andami_updater_jar) |
330 |
|
331 |
File file = new File(gvsig_product_folder_path + "/gvSIG/extensiones/org.gvsig.app.mainplugin/package.info") |
332 |
log.info("Loading package.info - " + file.getAbsolutePath()) |
333 |
pakageinfo = new Properties() |
334 |
pakageinfo.load(file.newDataInputStream()) |
335 |
|
336 |
createLauncher("/src/main/launch4j/gvsig-desktop.xml", "/target/product/gvsig-desktop/gvsig-desktop.xml") |
337 |
createLauncher("/src/main/launch4j/gvsig-desktop-devel.xml", "/target/product/gvsig-desktop/gvsig-desktop-devel.xml") |
338 |
createLauncher("/src/main/launch4j/gvsig-package-installer.xml", "/target/product/gvsig-desktop/gvsig-package-installer.xml") |
339 |
createLauncher("/src/main/launch4j/gvsig-desktop-portable.xml", "/target/product/gvsig-desktop/tools/gvsig-desktop-portable.xml") |
340 |
|
341 |
download_jre() |
342 |
|
343 |
log.info("Download busybox.exe.") |
344 |
ant.get(src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/busybox.exe", dest: gvsig_product_folder_path+"/tools/busybox.exe") |
345 |
|
346 |
// De momento duplicamos el busybox, pero deberia corregirse en el installjamer |
347 |
// para que lo busque en tools. |
348 |
ant.copy(file:gvsig_product_folder_path+"/tools/busybox.exe", todir:gvsig_product_folder_path+"/busybox.exe") |
349 |
|
350 |
source = getProjectTargetPath() + "/" + jre_pkg_name |
351 |
target = gvsig_product_folder_path + "/gvSIG/extensiones/" |
352 |
log.info("Installing plugin windows jre plugin to " + target + "...") |
353 |
ant.unzip(src: source, dest: target) |
354 |
log.info("jre installed.") |
355 |
|
356 |
log.info("Building zip installer...") |
357 |
source = getProjectTargetPath() + "/product" |
358 |
target = getProjectTargetPath() + |
359 |
"/gvSIG-desktop-" + |
360 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
361 |
pakageinfo.getProperty("state") + "-all-x86-online.zip" |
362 |
ant.zip(destfile: target, basedir: source) |
363 |
|
364 |
log.info("Building pool zip...") |
365 |
source = getProjectTargetPath()+"/pool.d" |
366 |
target = getProjectTargetPath() + |
367 |
"/gvSIG-desktop-" + |
368 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
369 |
pakageinfo.getProperty("state") + "-all-all-pool.zip" |
370 |
ant.zip(destfile: target, basedir: source) |
371 |
|
372 |
log.info("Building basic package-set (gvspks)...") |
373 |
source = getProjectTargetPath()+"/gvspks" |
374 |
target = getProjectTargetPath() + |
375 |
"/gvSIG-desktop-" + |
376 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
377 |
pakageinfo.getProperty("state") + "-all-all.gvspks" |
378 |
ant.zip(destfile: target, basedir: source) |
379 |
|
380 |
|
381 |
cmd = [ "installjammer" , |
382 |
"--output-dir", getProjectTargetPath(), |
383 |
"-DBaseDir", gvsig_product_folder_path, |
384 |
"-DVersion", getVersionWithoutBuildNumber(pakageinfo), |
385 |
"-DInstallVersion", getVersionWithoutBuildNumber(pakageinfo), |
386 |
"-DDevelState", pakageinfo.getProperty("state"), |
387 |
"-DBuildVersion", pakageinfo.getProperty("buildNumber"), |
388 |
"--build-for-release", |
389 |
"--build-dir", getProjectTargetPath() + "/installjammer", |
390 |
"--build-log-file", getProjectTargetPath() + "/installjammer.log", |
391 |
"--verbose", |
392 |
"--build", |
393 |
getProjectBasePath() + "/src/main/installjammer/gvsig-standard-installer.mpi" |
394 |
] |
395 |
log.info("Launching InstallJammer - " + cmd.join(" ") ) |
396 |
ant.exec( command: cmd.join(" ") ) |
397 |
|
398 |
checkInstallJammerStatus() |
399 |
|
400 |
if( project.properties["deploy-installers"] != null ) { |
401 |
deployInstallers() |
402 |
} |
403 |
} |
404 |
|
405 |
main() |
406 |
|
407 |
]]></source> |
408 |
</configuration>
|
409 |
</execution>
|
410 |
</executions>
|
411 |
</plugin>
|
412 |
</plugins>
|
413 |
</build>
|
414 |
|
415 |
</project>
|