Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.installer / org.gvsig.desktop.installer.installjamer / pom.xml @ 43830

History | View | Annotate | Download (15.6 KB)

1 42300 jjdelcerro
<?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 43830 jjdelcerro
    <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 42300 jjdelcerro
11 43830 jjdelcerro
    <build>
12 42300 jjdelcerro
13 43830 jjdelcerro
        <pluginManagement>
14
            <plugins>
15 42300 jjdelcerro
16 43830 jjdelcerro
                <plugin>
17
                    <groupId>org.codehaus.gmaven</groupId>
18
                    <artifactId>gmaven-plugin</artifactId>
19
                    <version>1.4</version>
20
                </plugin>
21 42300 jjdelcerro
22 43830 jjdelcerro
                <plugin>
23
                    <groupId>org.codehaus.mojo</groupId>
24
                    <artifactId>properties-maven-plugin</artifactId>
25
                    <version>1.0-alpha-2</version>
26
                </plugin>
27 42300 jjdelcerro
28 43830 jjdelcerro
            </plugins>
29
        </pluginManagement>
30 42300 jjdelcerro
31 43830 jjdelcerro
        <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 42300 jjdelcerro
53 43830 jjdelcerro
            <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 42300 jjdelcerro
// To deploy package use:
74
//    mvn -Ddeploy-installers -Dusername=USER -Dpassword=PASSWORD install
75
//
76
77
public class WebDAVClient {
78
79
    def log;
80
81
    private String user;
82
    private String password;
83
    private Object sardine;
84
85
    public WebDAVClient(log) {
86
            this.log = log;
87
    }
88
89
    public void login(String user, String password) {
90
        log.info("[WEBDAV] login as '"+user+"'.");
91
        def SardineFactory
92
        try {
93
            SardineFactory = "com.github.sardine.SardineFactory" as Class
94
        } catch (Exception ex) {
95
            log.error("[WEBDAV] can't get SardineFactory.",ex);
96
        }
97
        this.user = user;
98
        this.password = password;
99
        this.sardine = SardineFactory.begin(this.user,this.password);
100
        this.sardine.enablePreemptiveAuthentication("devel.gvsig.net");
101
        this.sardine.enablePreemptiveAuthentication("downloads.gvsig.net");
102
        this.sardine.enablePreemptiveAuthentication("devel.gvsig.org");
103
        this.sardine.enablePreemptiveAuthentication("downloads.gvsig.org");
104
    }
105
106
    public void login() {
107
        log.info("[WEBDAV] login as guest");
108
        this.sardine = SardineFactory.begin();
109
    }
110
111
    public boolean exists(String url) throws Exception {
112
        return sardine.exists(url);
113
    }
114
115
    public void makedirs(String url) throws Exception {
116
        log.info("[WEBDAV] makedirs '"+url+"'.");
117
        URL u = new URL(url);
118
        String[] x = u.getPath().split("/");
119
        String path = "";
120
        for( int i=1; i<x.length; i++ ) {
121
          path = path + "/" + x[i];
122
          URL t = new URL(u,path);
123
          mkdir(t.toString());
124
        }
125
    }
126
127
    public void mkdir(String url) throws Exception {
128
        if( ! exists(url) ) {
129
            log.info("[WEBDAV] mkdir '"+url+"'.");
130
            sardine.createDirectory(url);
131
        }
132
    }
133
134
    public void put(String source, String target) throws Exception {
135
        log.info("[WEBDAV] put '" + source + "' to '" + target + "'...");
136
        InputStream fis = new FileInputStream(new File(source));
137
        sardine.put(target, fis);
138
        log.info("[WEBDAV] put ok.");
139
    }
140
141
    public List list(String url) throws Exception {
142
        List resources = sardine.list(url);
143
        return resources;
144
    }
145
}
146
147
def getProjectBasePath() {
148
    s = project.basedir.getAbsolutePath()
149
    return s
150
}
151
152
def getProjectBaseFile() {
153
    f = project.basedir
154
    return f
155
}
156
157
def getProjectTargetPath() {
158
    s = project.basedir.getAbsolutePath() +"/target"
159
    return s
160
}
161
162
def getVersionWithBuildNumber(pakageinfo) {
163
    return pakageinfo.getProperty("version")+"-"+pakageinfo.getProperty("buildNumber")
164
}
165
166
def getVersionWithoutBuildNumber(pakageinfo) {
167
    return pakageinfo.getProperty("version") // .replaceFirst("-[0-9]*\$","")
168
}
169
170
def createLauncher(source,target) {
171
    log.info("Creating launcher ("+source+")...")
172
    source = getProjectBasePath() + source
173
    target = getProjectBasePath() + target
174
    s = new File(source).text
175
    s = s.replaceAll("@@gvsig.product.folder.path@@", gvsig_product_folder_path)
176
    s = s.replaceAll("@@org.gvsig.andami.updater.jar@@", org_gvsig_andami_updater_jar)
177
    s = s.replaceAll("@@version@@", getVersionWithBuildNumber(pakageinfo).replace("-","."))
178
    new File(target).write(s)
179
    log.info("Created "+target)
180
    ant.exec( command:"launch4jc "+ target )
181
    log.info("Created launcher ("+target+").")
182
}
183
184
def deployInstallers() {
185
        if( project.properties["username"] == null ) {
186
            print("Enter user name: ");
187
            user = System.console().readLine().toString()
188
            if( user != "" ) {
189
                project.properties.setProperty("username",user);
190
            }
191
        }
192
        if( project.properties["password"] == null ) {
193
            print("Enter password for user '" + project.properties["username"] + "': ");
194
            password = System.console().readPassword().toString()
195
            if( password != "" ) {
196
                project.properties.setProperty("password",password);
197
            }
198
        }
199
        WebDAVClient session = new WebDAVClient(log);
200
        if( project.properties["username"] == null || project.properties["password"] == null ) {
201
            log.info("[WEBDAV] creating non authenticated session.");
202
            log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session.");
203
            session.login();
204
        } else {
205
            session.login(project.properties["username"], project.properties["password"]);
206
        }
207
        // addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing"
208
        addonsRepo = "https://downloads.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.1.0-jre_7_windows_i586-1.7.72-0-devel-win-x86-j1_7.gvspkg"
244
    url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_7_windows_i586/" + jre_pkg_name
245
    target = getProjectTargetPath() + "/" + jre_pkg_name
246
    jre_path = System.getenv()["jre_gvspkg_path"]
247
    if(! new File(target).exists() ) {
248
      if( jre_path!=null ) {
249
        if( jre_path.endsWith(".gvspkg") ) {
250
          source = jre_path
251
        } else {
252
          source = jre_path + "/" + jre_pkg_name
253
        }
254
        if (source.startsWith("~" + File.separator)) {
255
            source = System.getenv().get("HOME") + source.substring(1);
256
        }
257
        if( ! new File(source).exists() ) {
258
          log.info("jre specified in jre_path variable not found - "+source)
259
          log.info("Downloading windows jre plugin")
260
          ant.get(src: url, dest: target)
261
        } else {
262
          log.info("Copy windows jre plugin")
263
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
264
        }
265
      } else {
266
        log.info("Downloading windows jre plugin")
267
        ant.get(src: url, dest: target)
268
      }
269
    } else {
270
      log.info("Skip download of jre, it exist in local filesystem.")
271
    }
272
}
273
274
def checkInstallJammerStatus() {
275
    logfile = getProjectTargetPath() + "/installjammer.log"
276
    s = new File(logfile).text
277
    if( s.contains("build completed with errors") ) {
278
        throw new RuntimeException("Can't builds installers, see installjammer.log")
279
    }
280
}
281
282
def main() {
283
    ant = new AntBuilder()
284
    log.info("For create windows launchers launch4j is requiered in the PATH. In linux link launch4j to launch4jc.")
285
    log.info("For create installer InstallJammer is required in the PATH.")
286
287
    log.info("Base path=" + getProjectBasePath())
288
289
    installation_folder = getProjectTargetPath() + "/product/gvsig-desktop"
290
    pool_folder = getProjectTargetPath() + "/pool.d"
291
    new File(installation_folder).mkdirs()
292
    new File(pool_folder,"pool").mkdirs()
293
294
    gvsig_product_folder_path = project.properties["gvsig.product.folder.path"]
295
296
297
    log.info("Getting a local copy of product folder...")
298
    ant.copy( todir: installation_folder ) {
299
      fileset( dir: gvsig_product_folder_path )
300
    }
301
    gvsig_product_folder_path = installation_folder
302
303
304
    log.info("Populate the pool folder...")
305
    ant.move( todir: pool_folder + "/pool" ) {
306
    fileset( dir: installation_folder + "/install/" )
307
    }
308
    new File(installation_folder,"install").mkdirs()
309
310
    log.info("Preparing basic package set (gvspks)...")
311
    gvspks_folder = new File(getProjectBaseFile(),"target/gvspks")
312
    gvspks_folder.mkdirs()
313
    filenames = new FileNameFinder().getFileNames(pool_folder,"**/*.gvspkg")
314
    for( filename in filenames ) {
315
      file = new File(filename)
316
      ant.copy(file:filename, todir:gvspks_folder.getAbsolutePath())
317
    }
318
    ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath())
319
320
    log.info("Finding andami updater jar...")
321
    org_gvsig_andami_updater_jar = new FileNameFinder().getFileNames(
322
      gvsig_product_folder_path+"/lib",
323
      'org.gvsig.andami.updater-*.jar'
324
    )[0]
325
    if( org_gvsig_andami_updater_jar == null ) {
326
      log.error("Can't find andami updater jar")
327
      assert false
328
    }
329
    org_gvsig_andami_updater_jar = new File(org_gvsig_andami_updater_jar).getName()
330
    log.info("Found andami updater :"+org_gvsig_andami_updater_jar)
331
332
    File file = new File(gvsig_product_folder_path + "/gvSIG/extensiones/org.gvsig.app.mainplugin/package.info")
333
    log.info("Loading package.info - " + file.getAbsolutePath())
334
    pakageinfo = new Properties()
335
    pakageinfo.load(file.newDataInputStream())
336
337
    //createLauncher("/src/main/launch4j/gvsig-desktop.xml", "/target/product/gvsig-desktop/gvsig-desktop.xml")
338
    // createLauncher("/src/main/launch4j/gvsig-desktop-devel.xml", "/target/product/gvsig-desktop/gvsig-desktop-devel.xml")
339
    //createLauncher("/src/main/launch4j/gvsig-package-installer.xml", "/target/product/gvsig-desktop/gvsig-package-installer.xml")
340
    //createLauncher("/src/main/launch4j/gvsig-desktop-portable.xml", "/target/product/gvsig-desktop/tools/gvsig-desktop-portable.xml")
341
342
    download_jre()
343
344
    log.info("Download busybox.exe.")
345
    ant.get(src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/busybox.exe", dest: gvsig_product_folder_path+"/busybox.exe")
346
347
    source = getProjectTargetPath() + "/" + jre_pkg_name
348
    target = gvsig_product_folder_path + "/gvSIG/extensiones/"
349
    log.info("Installing plugin windows jre plugin to " + target + "...")
350
    ant.unzip(src: source, dest: target)
351
    log.info("jre installed.")
352
353
    log.info("Building zip installer...")
354
    source  = getProjectTargetPath() + "/product"
355
    target  = getProjectTargetPath() +
356
      "/gvSIG-desktop-" +
357
      getVersionWithBuildNumber(pakageinfo) + "-" +
358
      pakageinfo.getProperty("state") + "-all-x86-online.zip"
359
    ant.zip(destfile: target, basedir: source)
360
361
    log.info("Building pool zip...")
362
    source  = getProjectTargetPath()+"/pool.d"
363
    target  = getProjectTargetPath() +
364
      "/gvSIG-desktop-" +
365
      getVersionWithBuildNumber(pakageinfo) + "-" +
366
      pakageinfo.getProperty("state") + "-all-all-pool.zip"
367
    ant.zip(destfile: target, basedir: source)
368
369
    log.info("Building basic package-set (gvspks)...")
370
    source  = getProjectTargetPath()+"/gvspks"
371
    target  = getProjectTargetPath() +
372
      "/gvSIG-desktop-" +
373
      getVersionWithBuildNumber(pakageinfo) + "-" +
374
      pakageinfo.getProperty("state") + "-all-all.gvspks"
375
    ant.zip(destfile: target, basedir: source)
376
377
378
    cmd = [ "installjammer" ,
379
      "--output-dir", getProjectTargetPath(),
380
      "-DBaseDir", gvsig_product_folder_path,
381
      "-DVersion",        getVersionWithoutBuildNumber(pakageinfo),
382
      "-DInstallVersion", getVersionWithoutBuildNumber(pakageinfo),
383
      "-DDevelState", pakageinfo.getProperty("state"),
384
      "-DBuildVersion", pakageinfo.getProperty("buildNumber"),
385
      "--build-for-release",
386
      "--build-dir", getProjectTargetPath() + "/installjammer",
387
      "--build-log-file", getProjectTargetPath() + "/installjammer.log",
388
      "--verbose",
389
      "--build",
390
      getProjectBasePath() + "/src/main/installjammer/gvsig-standard-installer.mpi"
391
    ]
392
    log.info("Launching InstallJammer - " + cmd.join(" ") )
393
    ant.exec( command: cmd.join(" ") )
394
395
    checkInstallJammerStatus()
396
397
    if( project.properties["deploy-installers"] != null ) {
398
        deployInstallers()
399
    }
400
}
401
402
main()
403
404
                    ]]></source>
405 43830 jjdelcerro
                        </configuration>
406
                    </execution>
407
                </executions>
408
            </plugin>
409
        </plugins>
410
    </build>
411 42300 jjdelcerro
412
</project>