Statistics
| Revision:

svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.78 / org.gvsig.desktop.installer / pom.xml @ 44114

History | View | Annotate | Download (15.2 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 41357 jjdelcerro
// To deploy package use:
74 41367 jjdelcerro
//    mvn -Ddeploy-installers -Dusername=USER -Dpassword=PASSWORD install
75 41357 jjdelcerro
//
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 41355 jjdelcerro
        }
97 41357 jjdelcerro
        this.user = user;
98
        this.password = password;
99
        this.sardine = SardineFactory.begin(this.user,this.password);
100 41476 jjdelcerro
        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 41357 jjdelcerro
    }
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 41364 jjdelcerro
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 41357 jjdelcerro
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 41364 jjdelcerro
    source = getProjectBasePath() + source
173
    target = getProjectBasePath() + target
174 41357 jjdelcerro
    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 41364 jjdelcerro
        if( project.properties["username"] == null ) {
186 41357 jjdelcerro
            print("Enter user name: ");
187
            user = System.console().readLine().toString()
188
            if( user != "" ) {
189 41364 jjdelcerro
                project.properties.setProperty("username",user);
190 41357 jjdelcerro
            }
191
        }
192
        if( project.properties["password"] == null ) {
193 41364 jjdelcerro
            print("Enter password for user '" + project.properties["username"] + "': ");
194 41357 jjdelcerro
            password = System.console().readPassword().toString()
195
            if( password != "" ) {
196
                project.properties.setProperty("password",password);
197
            }
198
        }
199
        WebDAVClient session = new WebDAVClient(log);
200 41366 jjdelcerro
        if( project.properties["username"] == null || project.properties["password"] == null ) {
201 41357 jjdelcerro
            log.info("[WEBDAV] creating non authenticated session.");
202 41367 jjdelcerro
            log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session.");
203 41357 jjdelcerro
            session.login();
204 41355 jjdelcerro
        } else {
205 41366 jjdelcerro
            session.login(project.properties["username"], project.properties["password"]);
206 41357 jjdelcerro
        }
207 41433 jjdelcerro
        // addonsRepo = "https://devel.gvsig.org/download/gvsig-desktop-testing"
208 41453 jjdelcerro
        addonsRepo = "https://downloads.gvsig.org/download/gvsig-desktop"
209 41357 jjdelcerro
        targetfolder = addonsRepo +
210
            "/dists/" +
211
            getVersionWithoutBuildNumber(pakageinfo) +
212
            "/builds/" +
213
            pakageinfo.getProperty("buildNumber")
214 41364 jjdelcerro
        sourcefolder  = getProjectTargetPath()
215 41357 jjdelcerro
216
        session.makedirs(targetfolder);
217
218
        base_fname = "gvSIG-desktop-" +
219
          getVersionWithBuildNumber(pakageinfo) +
220
          "-" +
221
          pakageinfo.getProperty("state")
222
223
        fname = base_fname + "-all-x86-online.zip"
224
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
225
226
        fname = base_fname + "-lin-x86-online.run"
227
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
228
229
        fname = base_fname + "-win-x86-online.exe"
230
        session.put(sourcefolder + "/" + fname, targetfolder + "/" + fname);
231
232
        session.makedirs(targetfolder+"/misc");
233
        fname = base_fname + "-all-all-pool.zip"
234
        session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname);
235 41433 jjdelcerro
236
        session.makedirs(targetfolder+"/misc");
237
        fname = base_fname + "-all-all.gvspks"
238
        session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname);
239 41357 jjdelcerro
}
240
241
def download_jre() {
242 41905 jjdelcerro
    jre_pkg_name = "gvSIG-desktop-2.1.0-jre_7_windows_i586-1.7.72-0-devel-win-x86-j1_7.gvspkg"
243 41740 jjdelcerro
    url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_7_windows_i586/" + jre_pkg_name
244 41447 jjdelcerro
    target = getProjectTargetPath() + "/" + jre_pkg_name
245 41944 jjdelcerro
    jre_path = System.getenv()["jre_gvspkg_path"]
246 41357 jjdelcerro
    if(! new File(target).exists() ) {
247 41944 jjdelcerro
      if( jre_path!=null ) {
248
        if( jre_path.endsWith(".gvspkg") ) {
249
          source = jre_path
250 41355 jjdelcerro
        } else {
251 41944 jjdelcerro
          source = jre_path + "/" + jre_pkg_name
252 41357 jjdelcerro
        }
253 41944 jjdelcerro
        if (source.startsWith("~" + File.separator)) {
254
            source = System.getenv().get("HOME") + source.substring(1);
255
        }
256 41357 jjdelcerro
        if( ! new File(source).exists() ) {
257 41944 jjdelcerro
          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 41944 jjdelcerro
        } else {
261 41357 jjdelcerro
          log.info("Copy windows jre plugin")
262 41364 jjdelcerro
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
263 41944 jjdelcerro
        }
264 41357 jjdelcerro
      } 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 41954 jjdelcerro
    // createLauncher("/src/main/launch4j/gvsig-desktop-devel.xml", "/target/product/gvsig-desktop/gvsig-desktop-devel.xml")
338 41364 jjdelcerro
    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
    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 40538 jjdelcerro
352 41364 jjdelcerro
    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 40538 jjdelcerro
360 41364 jjdelcerro
    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 41357 jjdelcerro
368 41364 jjdelcerro
    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 41357 jjdelcerro
376 41364 jjdelcerro
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 41357 jjdelcerro
}
400
401 41364 jjdelcerro
main()
402
403 40497 jjdelcerro
                    ]]></source>
404
                  </configuration>
405
                </execution>
406 40435 jjdelcerro
              </executions>
407
          </plugin>
408
      </plugins>
409
  </build>
410 40497 jjdelcerro
411 40538 jjdelcerro
</project>