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
<?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

    
74
// To deploy package use:
75
//    mvn -Ddeploy-installers -Dusername=USER -Dpassword=PASSWORD install
76
//      
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
        }
98
        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
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
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
    source = getProjectBasePath() + source
170
    target = getProjectBasePath() + target
171
    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
        if( project.properties["username"] == null ) {
183
            print("Enter user name: ");
184
            user = System.console().readLine().toString()
185
            if( user != "" ) {
186
                project.properties.setProperty("username",user);
187
            }
188
        }
189
        if( project.properties["password"] == null ) {                                
190
            print("Enter password for user '" + project.properties["username"] + "': ");
191
            password = System.console().readPassword().toString()  
192
            if( password != "" ) {
193
                project.properties.setProperty("password",password);
194
            }
195
        }
196
        WebDAVClient session = new WebDAVClient(log);
197
        if( project.properties["username"] == null || project.properties["password"] == null ) {                                
198
            log.info("[WEBDAV] creating non authenticated session.");
199
            log.info("[WEBDAV] Use -Dusername=USER -Dpassword=PASSWORD to create a authenticated session.");
200
            session.login();
201
        } else {
202
            session.login(project.properties["username"], project.properties["password"]);
203
        }
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
        sourcefolder  = getProjectTargetPath()
211
                        
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
    target = getProjectTargetPath() + jre_pkg_name
237
    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
        } else {
242
          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
          log.info("Downloading windows jre plugin")
250
          ant.get(src: url, dest: target)
251
      } else {
252
          log.info("Copy windows jre plugin")
253
          ant.copy(file:source, todir:getProjectTargetPath() + "/")
254
      }      
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

    
264
def checkInstallJammerStatus() {
265
    logfile = getProjectTargetPath() + "/installjammer.log"
266
    s = new File(logfile).text
267
    if( s.contains("build completed with errors") ) {
268
        throw new RuntimeException("Can't builds installers, see installjammer.log")
269
    }
270
}
271

    
272
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

    
277
    log.info("Base path=" + getProjectBasePath())                     
278

    
279
    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

    
284
    gvsig_product_folder_path = project.properties["gvsig.product.folder.path"]
285

    
286

    
287
    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

    
293

    
294
    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

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

    
310
    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

    
322
    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

    
327
    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

    
332
    download_jre()
333

    
334
    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

    
337
    // 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

    
341
    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

    
347
    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

    
355
    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

    
363
    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

    
371

    
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
}
395

    
396
main()                        
397

    
398
                    ]]></source>
399
                  </configuration>
400
                </execution>
401
              </executions>
402
          </plugin>
403
      </plugins>
404
  </build>
405

    
406
</project>