Statistics
| Revision:

svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.47 / org.gvsig.desktop.installer / pom.xml @ 43228

History | View | Annotate | Download (15.5 KB)

1 40435 jjdelcerro
<?xml version="1.0" encoding="UTF-8"?>
2 40497 jjdelcerro
<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 40435 jjdelcerro
4 40531 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 40435 jjdelcerro
11
  <build>
12 40531 jjdelcerro
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 40435 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 40538 jjdelcerro
                                        <!-- Define gvsig.product.folder.path in this property -->
44 40581 jjdelcerro
                                        <file>${env.HOME}/.gvsig-devel.properties</file>
45 40538 jjdelcerro
                                        <file>${project.basedir}/gvsig-devel.properties</file>
46 40435 jjdelcerro
                          </files>
47 40531 jjdelcerro
                          <quiet>true</quiet>
48 40435 jjdelcerro
                      </configuration>
49
                  </execution>
50
              </executions>
51
          </plugin>
52 40497 jjdelcerro
53 40435 jjdelcerro
          <plugin>
54 40497 jjdelcerro
              <groupId>org.codehaus.gmaven</groupId>
55
              <artifactId>gmaven-plugin</artifactId>
56 41358 jjdelcerro
            <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 40435 jjdelcerro
              <executions>
65 40497 jjdelcerro
                <execution>
66
                  <id>release</id>
67
                  <phase>install</phase>
68
                  <goals>
69
                    <goal>execute</goal>
70
                  </goals>
71
                  <configuration>
72
                    <source><![CDATA[
73 41222 jjdelcerro
74 41357 jjdelcerro
// To deploy package use:
75 41367 jjdelcerro
//    mvn -Ddeploy-installers -Dusername=USER -Dpassword=PASSWORD install
76 41357 jjdelcerro
//
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 41355 jjdelcerro
        }
98 41357 jjdelcerro
        this.user = user;
99
        this.password = password;
100
        this.sardine = SardineFactory.begin(this.user,this.password);
101 41476 jjdelcerro
        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 41357 jjdelcerro
    }
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 41364 jjdelcerro
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 41357 jjdelcerro
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 41364 jjdelcerro
    source = getProjectBasePath() + source
174
    target = getProjectBasePath() + target
175 41357 jjdelcerro
    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 41364 jjdelcerro
        if( project.properties["username"] == null ) {
187 41357 jjdelcerro
            print("Enter user name: ");
188
            user = System.console().readLine().toString()
189
            if( user != "" ) {
190 41364 jjdelcerro
                project.properties.setProperty("username",user);
191 41357 jjdelcerro
            }
192
        }
193
        if( project.properties["password"] == null ) {
194 41364 jjdelcerro
            print("Enter password for user '" + project.properties["username"] + "': ");
195 41357 jjdelcerro
            password = System.console().readPassword().toString()
196
            if( password != "" ) {
197
                project.properties.setProperty("password",password);
198
            }
199
        }
200
        WebDAVClient session = new WebDAVClient(log);
201 41366 jjdelcerro
        if( project.properties["username"] == null || project.properties["password"] == null ) {
202 41357 jjdelcerro
            log.info("[WEBDAV] creating non authenticated session.");
203 41367 jjdelcerro
            log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session.");
204 41357 jjdelcerro
            session.login();
205 41355 jjdelcerro
        } else {
206 41366 jjdelcerro
            session.login(project.properties["username"], project.properties["password"]);
207 41357 jjdelcerro
        }
208 41433 jjdelcerro
        // addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing"
209 41453 jjdelcerro
        addonsRepo = "https://downloads.gvsig.org/download/gvsig-desktop"
210 41357 jjdelcerro
        targetfolder = addonsRepo +
211
            "/dists/" +
212
            getVersionWithoutBuildNumber(pakageinfo) +
213
            "/builds/" +
214
            pakageinfo.getProperty("buildNumber")
215 41364 jjdelcerro
        sourcefolder  = getProjectTargetPath()
216 41357 jjdelcerro
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 41433 jjdelcerro
237
        session.makedirs(targetfolder+"/misc");
238
        fname = base_fname + "-all-all.gvspks"
239
        session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname);
240 41357 jjdelcerro
}
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 41447 jjdelcerro
    target = getProjectTargetPath() + "/" + jre_pkg_name
246 41357 jjdelcerro
    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 41355 jjdelcerro
        } else {
251 41357 jjdelcerro
          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 41355 jjdelcerro
          log.info("Downloading windows jre plugin")
259
          ant.get(src: url, dest: target)
260
      } else {
261 41357 jjdelcerro
          log.info("Copy windows jre plugin")
262 41364 jjdelcerro
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
263 41357 jjdelcerro
      }
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 40531 jjdelcerro
273 41359 jjdelcerro
def checkInstallJammerStatus() {
274 41364 jjdelcerro
    logfile = getProjectTargetPath() + "/installjammer.log"
275 41360 jjdelcerro
    s = new File(logfile).text
276 41359 jjdelcerro
    if( s.contains("build completed with errors") ) {
277
        throw new RuntimeException("Can't builds installers, see installjammer.log")
278
    }
279
}
280
281 41364 jjdelcerro
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 40435 jjdelcerro
286 41364 jjdelcerro
    log.info("Base path=" + getProjectBasePath())
287 40435 jjdelcerro
288 41364 jjdelcerro
    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 40497 jjdelcerro
293 41364 jjdelcerro
    gvsig_product_folder_path = project.properties["gvsig.product.folder.path"]
294 40535 jjdelcerro
295 40538 jjdelcerro
296 41364 jjdelcerro
    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 40538 jjdelcerro
302
303 41364 jjdelcerro
    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 40538 jjdelcerro
309 41364 jjdelcerro
    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 41365 jjdelcerro
    ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath())
318 40538 jjdelcerro
319 41364 jjdelcerro
    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 40538 jjdelcerro
331 41364 jjdelcerro
    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 40538 jjdelcerro
336 41364 jjdelcerro
    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 40538 jjdelcerro
341 41364 jjdelcerro
    download_jre()
342 40538 jjdelcerro
343 41364 jjdelcerro
    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 40538 jjdelcerro
346 41364 jjdelcerro
    // 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 40538 jjdelcerro
350 41364 jjdelcerro
    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 40538 jjdelcerro
356 41364 jjdelcerro
    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 40538 jjdelcerro
364 41364 jjdelcerro
    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 41357 jjdelcerro
372 41364 jjdelcerro
    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 41357 jjdelcerro
380 41364 jjdelcerro
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 41357 jjdelcerro
}
404
405 41364 jjdelcerro
main()
406
407 40497 jjdelcerro
                    ]]></source>
408
                  </configuration>
409
                </execution>
410 40435 jjdelcerro
              </executions>
411
          </plugin>
412
      </plugins>
413
  </build>
414 40497 jjdelcerro
415 40538 jjdelcerro
</project>