svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.installer / pom.xml @ 41453
History | View | Annotate | Download (15.2 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 |
} |
102 |
|
103 |
public void login() { |
104 |
log.info("[WEBDAV] login as guest"); |
105 |
this.sardine = SardineFactory.begin(); |
106 |
} |
107 |
|
108 |
public boolean exists(String url) throws Exception { |
109 |
return sardine.exists(url); |
110 |
} |
111 |
|
112 |
public void makedirs(String url) throws Exception { |
113 |
log.info("[WEBDAV] makedirs '"+url+"'."); |
114 |
URL u = new URL(url); |
115 |
String[] x = u.getPath().split("/"); |
116 |
String path = ""; |
117 |
for( int i=1; i<x.length; i++ ) { |
118 |
path = path + "/" + x[i]; |
119 |
URL t = new URL(u,path); |
120 |
mkdir(t.toString()); |
121 |
} |
122 |
} |
123 |
|
124 |
public void mkdir(String url) throws Exception { |
125 |
if( ! exists(url) ) { |
126 |
log.info("[WEBDAV] mkdir '"+url+"'."); |
127 |
sardine.createDirectory(url); |
128 |
} |
129 |
} |
130 |
|
131 |
public void put(String source, String target) throws Exception { |
132 |
log.info("[WEBDAV] put '" + source + "' to '" + target + "'..."); |
133 |
InputStream fis = new FileInputStream(new File(source)); |
134 |
sardine.put(target, fis); |
135 |
log.info("[WEBDAV] put ok."); |
136 |
} |
137 |
|
138 |
public List list(String url) throws Exception { |
139 |
List resources = sardine.list(url); |
140 |
return resources; |
141 |
} |
142 |
} |
143 |
|
144 |
def getProjectBasePath() { |
145 |
s = project.basedir.getAbsolutePath() |
146 |
return s |
147 |
} |
148 |
|
149 |
def getProjectBaseFile() { |
150 |
f = project.basedir |
151 |
return f |
152 |
} |
153 |
|
154 |
def getProjectTargetPath() { |
155 |
s = project.basedir.getAbsolutePath() +"/target" |
156 |
return s |
157 |
} |
158 |
|
159 |
def getVersionWithBuildNumber(pakageinfo) { |
160 |
return pakageinfo.getProperty("version")+"-"+pakageinfo.getProperty("buildNumber") |
161 |
} |
162 |
|
163 |
def getVersionWithoutBuildNumber(pakageinfo) { |
164 |
return pakageinfo.getProperty("version") // .replaceFirst("-[0-9]*\$","") |
165 |
} |
166 |
|
167 |
def createLauncher(source,target) { |
168 |
log.info("Creating launcher ("+source+")...") |
169 |
source = getProjectBasePath() + source |
170 |
target = getProjectBasePath() + target |
171 |
s = new File(source).text |
172 |
s = s.replaceAll("@@gvsig.product.folder.path@@", gvsig_product_folder_path) |
173 |
s = s.replaceAll("@@org.gvsig.andami.updater.jar@@", org_gvsig_andami_updater_jar) |
174 |
s = s.replaceAll("@@version@@", getVersionWithBuildNumber(pakageinfo).replace("-",".")) |
175 |
new File(target).write(s) |
176 |
log.info("Created "+target) |
177 |
ant.exec( command:"launch4jc "+ target ) |
178 |
log.info("Created launcher ("+target+").") |
179 |
} |
180 |
|
181 |
def deployInstallers() { |
182 |
if( project.properties["username"] == null ) { |
183 |
print("Enter user name: "); |
184 |
user = System.console().readLine().toString() |
185 |
if( user != "" ) { |
186 |
project.properties.setProperty("username",user); |
187 |
} |
188 |
} |
189 |
if( project.properties["password"] == null ) { |
190 |
print("Enter password for user '" + project.properties["username"] + "': "); |
191 |
password = System.console().readPassword().toString() |
192 |
if( password != "" ) { |
193 |
project.properties.setProperty("password",password); |
194 |
} |
195 |
} |
196 |
WebDAVClient session = new WebDAVClient(log); |
197 |
if( project.properties["username"] == null || project.properties["password"] == null ) { |
198 |
log.info("[WEBDAV] creating non authenticated session."); |
199 |
log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session."); |
200 |
session.login(); |
201 |
} else { |
202 |
session.login(project.properties["username"], project.properties["password"]); |
203 |
} |
204 |
// addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing" |
205 |
addonsRepo = "https://downloads.gvsig.org/download/gvsig-desktop" |
206 |
targetfolder = addonsRepo + |
207 |
"/dists/" + |
208 |
getVersionWithoutBuildNumber(pakageinfo) + |
209 |
"/builds/" + |
210 |
pakageinfo.getProperty("buildNumber") |
211 |
sourcefolder = getProjectTargetPath() |
212 |
|
213 |
session.makedirs(targetfolder); |
214 |
|
215 |
base_fname = "gvSIG-desktop-" + |
216 |
getVersionWithBuildNumber(pakageinfo) + |
217 |
"-" + |
218 |
pakageinfo.getProperty("state") |
219 |
|
220 |
fname = base_fname + "-all-x86-online.zip" |
221 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
222 |
|
223 |
fname = base_fname + "-lin-x86-online.run" |
224 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
225 |
|
226 |
fname = base_fname + "-win-x86-online.exe" |
227 |
session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname); |
228 |
|
229 |
session.makedirs(targetfolder+"/misc"); |
230 |
fname = base_fname + "-all-all-pool.zip" |
231 |
session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname); |
232 |
|
233 |
session.makedirs(targetfolder+"/misc"); |
234 |
fname = base_fname + "-all-all.gvspks" |
235 |
session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname); |
236 |
} |
237 |
|
238 |
def download_jre() { |
239 |
jre_pkg_name = "gvSIG-desktop-2.0.0-jre_6_windows_i586-1.6.26-0-devel-win-x86-j1_6.gvspkg" |
240 |
url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_6_windows_i586/" + jre_pkg_name |
241 |
target = getProjectTargetPath() + "/" + jre_pkg_name |
242 |
if(! new File(target).exists() ) { |
243 |
if( project.properties["jre.path"]!=null ) { |
244 |
if( project.properties["jre.path"].endsWith(".gvspkg") ) { |
245 |
source = project.properties["jre.path"] |
246 |
} else { |
247 |
source = project.properties["jre.path"] + "/" + jre_pkg_name |
248 |
} |
249 |
if (source.startsWith("~" + File.separator)) { |
250 |
source = System.getenv().get("HOME") + source.substring(1); |
251 |
} |
252 |
if( ! new File(source).exists() ) { |
253 |
log.info("jre specified in jre.path variable not found - "+source) |
254 |
log.info("Downloading windows jre plugin") |
255 |
ant.get(src: url, dest: target) |
256 |
} else { |
257 |
log.info("Copy windows jre plugin") |
258 |
ant.copy(file:source, todir:getProjectTargetPath() + "/") |
259 |
} |
260 |
} else { |
261 |
log.info("Downloading windows jre plugin") |
262 |
ant.get(src: url, dest: target) |
263 |
} |
264 |
} else { |
265 |
log.info("Skip download of jre, it exist in local filesystem.") |
266 |
} |
267 |
} |
268 |
|
269 |
def checkInstallJammerStatus() { |
270 |
logfile = getProjectTargetPath() + "/installjammer.log" |
271 |
s = new File(logfile).text |
272 |
if( s.contains("build completed with errors") ) { |
273 |
throw new RuntimeException("Can't builds installers, see installjammer.log") |
274 |
} |
275 |
} |
276 |
|
277 |
def main() { |
278 |
ant = new AntBuilder() |
279 |
log.info("For create windows launchers launch4j is requiered in the PATH. In linux link launch4j to launch4jc.") |
280 |
log.info("For create installer InstallJammer is required in the PATH.") |
281 |
|
282 |
log.info("Base path=" + getProjectBasePath()) |
283 |
|
284 |
installation_folder = getProjectTargetPath() + "/product/gvsig-desktop" |
285 |
pool_folder = getProjectTargetPath() + "/pool.d" |
286 |
new File(installation_folder).mkdirs() |
287 |
new File(pool_folder,"pool").mkdirs() |
288 |
|
289 |
gvsig_product_folder_path = project.properties["gvsig.product.folder.path"] |
290 |
|
291 |
|
292 |
log.info("Getting a local copy of product folder...") |
293 |
ant.copy( todir: installation_folder ) { |
294 |
fileset( dir: gvsig_product_folder_path ) |
295 |
} |
296 |
gvsig_product_folder_path = installation_folder |
297 |
|
298 |
|
299 |
log.info("Populate the pool folder...") |
300 |
ant.move( todir: pool_folder + "/pool" ) { |
301 |
fileset( dir: installation_folder + "/install/" ) |
302 |
} |
303 |
new File(installation_folder,"install").mkdirs() |
304 |
|
305 |
log.info("Preparing basic package set (gvspks)...") |
306 |
gvspks_folder = new File(getProjectBaseFile(),"target/gvspks") |
307 |
gvspks_folder.mkdirs() |
308 |
filenames = new FileNameFinder().getFileNames(pool_folder,"**/*.gvspkg") |
309 |
for( filename in filenames ) { |
310 |
file = new File(filename) |
311 |
ant.copy(file:filename, todir:gvspks_folder.getAbsolutePath()) |
312 |
} |
313 |
ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath()) |
314 |
|
315 |
log.info("Finding andami updater jar...") |
316 |
org_gvsig_andami_updater_jar = new FileNameFinder().getFileNames( |
317 |
gvsig_product_folder_path+"/lib", |
318 |
'org.gvsig.andami.updater-*.jar' |
319 |
)[0] |
320 |
if( org_gvsig_andami_updater_jar == null ) { |
321 |
log.error("Can't find andami updater jar") |
322 |
assert false |
323 |
} |
324 |
org_gvsig_andami_updater_jar = new File(org_gvsig_andami_updater_jar).getName() |
325 |
log.info("Found andami updater :"+org_gvsig_andami_updater_jar) |
326 |
|
327 |
File file = new File(gvsig_product_folder_path + "/gvSIG/extensiones/org.gvsig.app.mainplugin/package.info") |
328 |
log.info("Loading package.info - " + file.getAbsolutePath()) |
329 |
pakageinfo = new Properties() |
330 |
pakageinfo.load(file.newDataInputStream()) |
331 |
|
332 |
createLauncher("/src/main/launch4j/gvsig-desktop.xml", "/target/product/gvsig-desktop/gvsig-desktop.xml") |
333 |
createLauncher("/src/main/launch4j/gvsig-desktop-devel.xml", "/target/product/gvsig-desktop/gvsig-desktop-devel.xml") |
334 |
createLauncher("/src/main/launch4j/gvsig-package-installer.xml", "/target/product/gvsig-desktop/gvsig-package-installer.xml") |
335 |
createLauncher("/src/main/launch4j/gvsig-desktop-portable.xml", "/target/product/gvsig-desktop/tools/gvsig-desktop-portable.xml") |
336 |
|
337 |
download_jre() |
338 |
|
339 |
log.info("Download busybox.exe.") |
340 |
ant.get(src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/busybox.exe", dest: gvsig_product_folder_path+"/tools/busybox.exe") |
341 |
|
342 |
// De momento duplicamos el busybox, pero deberia corregirse en el installjamer |
343 |
// para que lo busque en tools. |
344 |
ant.copy(file:gvsig_product_folder_path+"/tools/busybox.exe", todir:gvsig_product_folder_path+"/busybox.exe") |
345 |
|
346 |
source = getProjectTargetPath() + "/" + jre_pkg_name |
347 |
target = gvsig_product_folder_path + "/gvSIG/extensiones/" |
348 |
log.info("Installing plugin windows jre plugin to " + target + "...") |
349 |
ant.unzip(src: source, dest: target) |
350 |
log.info("jre installed.") |
351 |
|
352 |
log.info("Building zip installer...") |
353 |
source = getProjectTargetPath() + "/product" |
354 |
target = getProjectTargetPath() + |
355 |
"/gvSIG-desktop-" + |
356 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
357 |
pakageinfo.getProperty("state") + "-all-x86-online.zip" |
358 |
ant.zip(destfile: target, basedir: source) |
359 |
|
360 |
log.info("Building pool zip...") |
361 |
source = getProjectTargetPath()+"/pool.d" |
362 |
target = getProjectTargetPath() + |
363 |
"/gvSIG-desktop-" + |
364 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
365 |
pakageinfo.getProperty("state") + "-all-all-pool.zip" |
366 |
ant.zip(destfile: target, basedir: source) |
367 |
|
368 |
log.info("Building basic package-set (gvspks)...") |
369 |
source = getProjectTargetPath()+"/gvspks" |
370 |
target = getProjectTargetPath() + |
371 |
"/gvSIG-desktop-" + |
372 |
getVersionWithBuildNumber(pakageinfo) + "-" + |
373 |
pakageinfo.getProperty("state") + "-all-all.gvspks" |
374 |
ant.zip(destfile: target, basedir: source) |
375 |
|
376 |
|
377 |
cmd = [ "installjammer" , |
378 |
"--output-dir", getProjectTargetPath(), |
379 |
"-DBaseDir", gvsig_product_folder_path, |
380 |
"-DVersion", getVersionWithoutBuildNumber(pakageinfo), |
381 |
"-DInstallVersion", getVersionWithoutBuildNumber(pakageinfo), |
382 |
"-DDevelState", pakageinfo.getProperty("state"), |
383 |
"-DBuildVersion", pakageinfo.getProperty("buildNumber"), |
384 |
"--build-for-release", |
385 |
"--build-dir", getProjectTargetPath() + "/installjammer", |
386 |
"--build-log-file", getProjectTargetPath() + "/installjammer.log", |
387 |
"--verbose", |
388 |
"--build", |
389 |
getProjectBasePath() + "/src/main/installjammer/gvsig-standard-installer.mpi" |
390 |
] |
391 |
log.info("Launching InstallJammer - " + cmd.join(" ") ) |
392 |
ant.exec( command: cmd.join(" ") ) |
393 |
|
394 |
checkInstallJammerStatus() |
395 |
|
396 |
if( project.properties["deploy-installers"] != null ) { |
397 |
deployInstallers() |
398 |
} |
399 |
} |
400 |
|
401 |
main() |
402 |
|
403 |
]]></source> |
404 |
</configuration>
|
405 |
</execution>
|
406 |
</executions>
|
407 |
</plugin>
|
408 |
</plugins>
|
409 |
</build>
|
410 |
|
411 |
</project>
|