Statistics
| Revision:

svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.39 / org.gvsig.desktop.installer / pom.xml @ 43814

History | View | Annotate | Download (15 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
    }
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 41364 jjdelcerro
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 41357 jjdelcerro
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 41364 jjdelcerro
    source = getProjectBasePath() + source
170
    target = getProjectBasePath() + target
171 41357 jjdelcerro
    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 41364 jjdelcerro
        if( project.properties["username"] == null ) {
183 41357 jjdelcerro
            print("Enter user name: ");
184
            user = System.console().readLine().toString()
185
            if( user != "" ) {
186 41364 jjdelcerro
                project.properties.setProperty("username",user);
187 41357 jjdelcerro
            }
188
        }
189
        if( project.properties["password"] == null ) {
190 41364 jjdelcerro
            print("Enter password for user '" + project.properties["username"] + "': ");
191 41357 jjdelcerro
            password = System.console().readPassword().toString()
192
            if( password != "" ) {
193
                project.properties.setProperty("password",password);
194
            }
195
        }
196
        WebDAVClient session = new WebDAVClient(log);
197 41366 jjdelcerro
        if( project.properties["username"] == null || project.properties["password"] == null ) {
198 41357 jjdelcerro
            log.info("[WEBDAV] creating non authenticated session.");
199 41367 jjdelcerro
            log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session.");
200 41357 jjdelcerro
            session.login();
201 41355 jjdelcerro
        } else {
202 41366 jjdelcerro
            session.login(project.properties["username"], project.properties["password"]);
203 41357 jjdelcerro
        }
204
        addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing"
205
        targetfolder = addonsRepo +
206
            "/dists/" +
207
            getVersionWithoutBuildNumber(pakageinfo) +
208
            "/builds/" +
209
            pakageinfo.getProperty("buildNumber")
210 41364 jjdelcerro
        sourcefolder  = getProjectTargetPath()
211 41357 jjdelcerro
212
        session.makedirs(targetfolder);
213
214
        base_fname = "gvSIG-desktop-" +
215
          getVersionWithBuildNumber(pakageinfo) +
216
          "-" +
217
          pakageinfo.getProperty("state")
218
219
        fname = base_fname + "-all-x86-online.zip"
220
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
221
222
        fname = base_fname + "-lin-x86-online.run"
223
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
224
225
        fname = base_fname + "-win-x86-online.exe"
226
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
227
228
        session.makedirs(targetfolder+"/misc");
229
        fname = base_fname + "-all-all-pool.zip"
230
        session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname);
231
}
232
233
def download_jre() {
234
    jre_pkg_name = "gvSIG-desktop-2.0.0-jre_6_windows_i586-1.6.26-0-devel-win-x86-j1_6.gvspkg"
235
    url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_6_windows_i586/" + jre_pkg_name
236 41364 jjdelcerro
    target = getProjectTargetPath() + jre_pkg_name
237 41357 jjdelcerro
    if(! new File(target).exists() ) {
238
      if( project.properties["jre.path"]!=null ) {
239
        if( project.properties["jre.path"].endsWith(".gvspkg") ) {
240
          source = project.properties["jre.path"]
241 41355 jjdelcerro
        } else {
242 41357 jjdelcerro
          source = project.properties["jre.path"] + "/" + jre_pkg_name
243
        }
244
      if (source.startsWith("~" + File.separator)) {
245
          source = System.getenv().get("HOME") + source.substring(1);
246
      }
247
        if( ! new File(source).exists() ) {
248
          log.info("jre specified in jre.path variable not found - "+source)
249 41355 jjdelcerro
          log.info("Downloading windows jre plugin")
250
          ant.get(src: url, dest: target)
251
      } else {
252 41357 jjdelcerro
          log.info("Copy windows jre plugin")
253 41364 jjdelcerro
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
254 41357 jjdelcerro
      }
255
      } else {
256
        log.info("Downloading windows jre plugin")
257
        ant.get(src: url, dest: target)
258
      }
259
    } else {
260
      log.info("Skip download of jre, it exist in local filesystem.")
261
    }
262
}
263 40531 jjdelcerro
264 41359 jjdelcerro
def checkInstallJammerStatus() {
265 41364 jjdelcerro
    logfile = getProjectTargetPath() + "/installjammer.log"
266 41360 jjdelcerro
    s = new File(logfile).text
267 41359 jjdelcerro
    if( s.contains("build completed with errors") ) {
268
        throw new RuntimeException("Can't builds installers, see installjammer.log")
269
    }
270
}
271
272 41364 jjdelcerro
def main() {
273
    ant = new AntBuilder()
274
    log.info("For create windows launchers launch4j is requiered in the PATH. In linux link launch4j to launch4jc.")
275
    log.info("For create installer InstallJammer is required in the PATH.")
276 40435 jjdelcerro
277 41364 jjdelcerro
    log.info("Base path=" + getProjectBasePath())
278 40435 jjdelcerro
279 41364 jjdelcerro
    installation_folder = getProjectTargetPath() + "/product/gvsig-desktop"
280
    pool_folder = getProjectTargetPath() + "/pool.d"
281
    new File(installation_folder).mkdirs()
282
    new File(pool_folder,"pool").mkdirs()
283 40497 jjdelcerro
284 41364 jjdelcerro
    gvsig_product_folder_path = project.properties["gvsig.product.folder.path"]
285 40535 jjdelcerro
286 40538 jjdelcerro
287 41364 jjdelcerro
    log.info("Getting a local copy of product folder...")
288
    ant.copy( todir: installation_folder ) {
289
      fileset( dir: gvsig_product_folder_path )
290
    }
291
    gvsig_product_folder_path = installation_folder
292 40538 jjdelcerro
293
294 41364 jjdelcerro
    log.info("Populate the pool folder...")
295
    ant.move( todir: pool_folder + "/pool" ) {
296
    fileset( dir: installation_folder + "/install/" )
297
    }
298
    new File(installation_folder,"install").mkdirs()
299 40538 jjdelcerro
300 41364 jjdelcerro
    log.info("Preparing basic package set (gvspks)...")
301
    gvspks_folder = new File(getProjectBaseFile(),"target/gvspks")
302
    gvspks_folder.mkdirs()
303
    filenames = new FileNameFinder().getFileNames(pool_folder,"**/*.gvspkg")
304
    for( filename in filenames ) {
305
      file = new File(filename)
306
      ant.copy(file:filename, todir:gvspks_folder.getAbsolutePath())
307
    }
308 41365 jjdelcerro
    ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath())
309 40538 jjdelcerro
310 41364 jjdelcerro
    log.info("Finding andami updater jar...")
311
    org_gvsig_andami_updater_jar = new FileNameFinder().getFileNames(
312
      gvsig_product_folder_path+"/lib",
313
      'org.gvsig.andami.updater-*.jar'
314
    )[0]
315
    if( org_gvsig_andami_updater_jar == null ) {
316
      log.error("Can't find andami updater jar")
317
      assert false
318
    }
319
    org_gvsig_andami_updater_jar = new File(org_gvsig_andami_updater_jar).getName()
320
    log.info("Found andami updater :"+org_gvsig_andami_updater_jar)
321 40538 jjdelcerro
322 41364 jjdelcerro
    File file = new File(gvsig_product_folder_path + "/gvSIG/extensiones/org.gvsig.app.mainplugin/package.info")
323
    log.info("Loading package.info - " + file.getAbsolutePath())
324
    pakageinfo = new Properties()
325
    pakageinfo.load(file.newDataInputStream())
326 40538 jjdelcerro
327 41364 jjdelcerro
    createLauncher("/src/main/launch4j/gvsig-desktop.xml", "/target/product/gvsig-desktop/gvsig-desktop.xml")
328
    createLauncher("/src/main/launch4j/gvsig-desktop-devel.xml", "/target/product/gvsig-desktop/gvsig-desktop-devel.xml")
329
    createLauncher("/src/main/launch4j/gvsig-package-installer.xml", "/target/product/gvsig-desktop/gvsig-package-installer.xml")
330
    createLauncher("/src/main/launch4j/gvsig-desktop-portable.xml", "/target/product/gvsig-desktop/tools/gvsig-desktop-portable.xml")
331 40538 jjdelcerro
332 41364 jjdelcerro
    download_jre()
333 40538 jjdelcerro
334 41364 jjdelcerro
    log.info("Download busybox.exe.")
335
    ant.get(src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/busybox.exe", dest: gvsig_product_folder_path+"/tools/busybox.exe")
336 40538 jjdelcerro
337 41364 jjdelcerro
    // De momento duplicamos el busybox, pero deberia corregirse en el installjamer
338
    // para que lo busque en tools.
339
    ant.copy(file:gvsig_product_folder_path+"/tools/busybox.exe", todir:gvsig_product_folder_path+"/busybox.exe")
340 40538 jjdelcerro
341 41364 jjdelcerro
    source = getProjectTargetPath() + "/" + jre_pkg_name
342
    target = gvsig_product_folder_path + "/gvSIG/extensiones/"
343
    log.info("Installing plugin windows jre plugin to " + target + "...")
344
    ant.unzip(src: source, dest: target)
345
    log.info("jre installed.")
346 40538 jjdelcerro
347 41364 jjdelcerro
    log.info("Building zip installer...")
348
    source  = getProjectTargetPath() + "/product"
349
    target  = getProjectTargetPath() +
350
      "/gvSIG-desktop-" +
351
      getVersionWithBuildNumber(pakageinfo) + "-" +
352
      pakageinfo.getProperty("state") + "-all-x86-online.zip"
353
    ant.zip(destfile: target, basedir: source)
354 40538 jjdelcerro
355 41364 jjdelcerro
    log.info("Building pool zip...")
356
    source  = getProjectTargetPath()+"/pool.d"
357
    target  = getProjectTargetPath() +
358
      "/gvSIG-desktop-" +
359
      getVersionWithBuildNumber(pakageinfo) + "-" +
360
      pakageinfo.getProperty("state") + "-all-all-pool.zip"
361
    ant.zip(destfile: target, basedir: source)
362 41357 jjdelcerro
363 41364 jjdelcerro
    log.info("Building basic package-set (gvspks)...")
364
    source  = getProjectTargetPath()+"/gvspks"
365
    target  = getProjectTargetPath() +
366
      "/gvSIG-desktop-" +
367
      getVersionWithBuildNumber(pakageinfo) + "-" +
368
      pakageinfo.getProperty("state") + "-all-all.gvspks"
369
    ant.zip(destfile: target, basedir: source)
370 41357 jjdelcerro
371 41364 jjdelcerro
372
    cmd = [ "installjammer" ,
373
      "--output-dir", getProjectTargetPath(),
374
      "-DBaseDir", gvsig_product_folder_path,
375
      "-DVersion",        getVersionWithoutBuildNumber(pakageinfo),
376
      "-DInstallVersion", getVersionWithoutBuildNumber(pakageinfo),
377
      "-DDevelState", pakageinfo.getProperty("state"),
378
      "-DBuildVersion", pakageinfo.getProperty("buildNumber"),
379
      "--build-for-release",
380
      "--build-dir", getProjectTargetPath() + "/installjammer",
381
      "--build-log-file", getProjectTargetPath() + "/installjammer.log",
382
      "--verbose",
383
      "--build",
384
      getProjectBasePath() + "/src/main/installjammer/gvsig-standard-installer.mpi"
385
    ]
386
    log.info("Launching InstallJammer - " + cmd.join(" ") )
387
    ant.exec( command: cmd.join(" ") )
388
389
    checkInstallJammerStatus()
390
391
    if( project.properties["deploy-installers"] != null ) {
392
        deployInstallers()
393
    }
394 41357 jjdelcerro
}
395
396 41364 jjdelcerro
main()
397
398 40497 jjdelcerro
                    ]]></source>
399
                  </configuration>
400
                </execution>
401 40435 jjdelcerro
              </executions>
402
          </plugin>
403
      </plugins>
404
  </build>
405 40497 jjdelcerro
406 40538 jjdelcerro
</project>