Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.installer / pom.xml @ 41944

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
// 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"
209
        targetfolder = addonsRepo + 
210
            "/dists/" + 
211
            getVersionWithoutBuildNumber(pakageinfo) + 
212
            "/builds/" + 
213
            pakageinfo.getProperty("buildNumber")
214
        sourcefolder  = getProjectTargetPath()
215
                        
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
                        
236
        session.makedirs(targetfolder+"/misc");
237
        fname = base_fname + "-all-all.gvspks" 
238
        session.put(sourcefolder + "/" + fname, targetfolder+"/misc/" + fname);
239
}
240

    
241
def download_jre() {
242
    jre_pkg_name = "gvSIG-desktop-2.1.0-jre_7_windows_i586-1.7.72-0-devel-win-x86-j1_7.gvspkg"
243
    url = "http://downloads.gvsig.org/download/gvsig-desktop/pool/jre_7_windows_i586/" + jre_pkg_name
244
    target = getProjectTargetPath() + "/" + jre_pkg_name
245
    jre_path = System.getenv()["jre_gvspkg_path"]
246
    if(! new File(target).exists() ) {
247
      if( jre_path!=null ) {
248
        if( jre_path.endsWith(".gvspkg") ) {
249
          source = jre_path
250
        } else {
251
          source = 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
          log.info("Downloading windows jre plugin")
259
          ant.get(src: url, dest: target)
260
        } else {
261
          log.info("Copy windows jre plugin")
262
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
263
        }      
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

    
273
def checkInstallJammerStatus() {
274
    logfile = getProjectTargetPath() + "/installjammer.log"
275
    s = new File(logfile).text
276
    if( s.contains("build completed with errors") ) {
277
        throw new RuntimeException("Can't builds installers, see installjammer.log")
278
    }
279
}
280

    
281
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

    
286
    log.info("Base path=" + getProjectBasePath())                     
287

    
288
    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

    
293
    gvsig_product_folder_path = project.properties["gvsig.product.folder.path"]
294

    
295

    
296
    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

    
302

    
303
    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

    
309
    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
    ant.copy(file: getProjectBasePath()+"/src/main/config/defaultPackages", todir:gvspks_folder.getAbsolutePath())
318

    
319
    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

    
331
    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

    
336
    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

    
341
    download_jre()
342

    
343
    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

    
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>