Revision 42794

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/gvSIG.sh
248 248
PJH4=
249 249
PJH5=
250 250
PJH6=
251
if [ -d "$GVSIG_INSTALL_FOLDER/gvSIG/extensiones/jre_7_windows_i586/jre" ] ; then
252
    PJH5="$GVSIG_INSTALL_FOLDER/gvSIG/extensiones/jre_7_windows_i586/jre"
251
if [ -d "$GVSIG_INSTALL_FOLDER/gvSIG/extensiones/jre" ] ; then
252
    PJH5="$GVSIG_INSTALL_FOLDER/gvSIG/extensiones/jre"
253 253
fi
254 254
if [ -d /usr/lib/jvm ] ; then
255 255
    PJH6=$(find /usr/lib/jvm -maxdepth 1 ! -name "jvm" -name "[a-zA-Z]*" ! -type l -print)
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.win.x86_64/src/main/scripts/prepare_win.groovy
16 16
    log.info("Copy org.gvsig.desktop.installer.izpack.extractpackages.jar")
17 17
    helper.copy_extractpackages_jar(target)
18 18

  
19
    log.info("Copy org.gvsig.desktop.installer.izpack.copyjre.jar")
20
    helper.copy_copyjre_jar(target)
21

  
19 22
    log.info("Download busybox.exe")
20 23
    helper.ant.get(
21 24
      src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/x86/busybox.exe",
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.copyjre/src/main/java/org/gvsig/desktop/installer/izpack/CopyJRE.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.desktop.installer.izpack;
25

  
26
import java.io.File;
27
import java.io.FileOutputStream;
28
import java.io.IOException;
29
import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
30
import java.io.Closeable;
31
import java.io.FileInputStream;
32
import java.nio.channels.FileChannel;
33

  
34
/*
35
 * Based on portions of code from clases IOUtils and FileUtils 
36
 * of the project org.apache.commons.io of the Apache Software Foundation (ASF)
37
 *
38
 * http://svn.apache.org/viewvc/commons/proper/io/tags/commons-io-2.5/src/main/java/org/apache/commons/io/FileUtils.java?view=markup
39
 * http://svn.apache.org/viewvc/commons/proper/io/tags/commons-io-2.5/src/main/java/org/apache/commons/io/IOUtils.java?view=markup
40
 */
41
public class CopyJRE {
42

  
43
    public boolean run(AbstractUIProcessHandler handler, String[] args) {
44
        File java_home = new File(System.getProperties().getProperty("java.home"));
45
        File f = new File(java_home, "package.info");
46
        if (!f.exists()) {
47
            // Solo copiamos la JRE si es la de un plugin de gvSIG.
48
            return true;
49
        }
50

  
51
        handler.logOutput("Installing JRE plugin (This may take a while)...", false);
52
        try {
53
            File installation_folder = new File(args[0]);
54
            File target = getFile(installation_folder,"gvSIG", "extensiones","jre");
55
            doCopyDirectory(java_home,target,true);
56
            File java_bin = getFile(installation_folder,"gvSIG", "extensiones","jre","bin","java");
57
            java_bin.setExecutable(true, false);
58
        } catch (Exception ex) {
59
            handler.logOutput("Can't install JRE plugin. " + ex.toString(), false);
60
            return false;
61
        }
62

  
63
        handler.logOutput("JRE plugin installed.", false);
64
        return true;
65
    }
66

  
67
    public static final long ONE_KB = 1024;
68
    public static final long ONE_MB = ONE_KB * ONE_KB;
69
    private static final long FILE_COPY_BUFFER_SIZE = ONE_MB * 30;
70

  
71
    public static File getFile(final File directory, final String... names) {
72
        if (directory == null) {
73
            throw new NullPointerException("directory must not be null");
74
        }
75
        if (names == null) {
76
            throw new NullPointerException("names must not be null");
77
        }
78
        File file = directory;
79
        for (final String name : names) {
80
            file = new File(file, name);
81
        }
82
        return file;
83
    }
84

  
85
    private static void doCopyDirectory(final File srcDir, final File destDir,
86
            final boolean preserveFileDate)
87
            throws IOException {
88
        // recurse
89
        final File[] srcFiles = srcDir.listFiles();
90
        if (srcFiles == null) { // null if abstract pathname does not denote a directory, or if an I/O error occurs
91
            throw new IOException("Failed to list contents of " + srcDir);
92
        }
93
        if (destDir.exists()) {
94
            if (destDir.isDirectory() == false) {
95
                throw new IOException("Destination '" + destDir + "' exists but is not a directory");
96
            }
97
        } else {
98
            if (!destDir.mkdirs() && !destDir.isDirectory()) {
99
                throw new IOException("Destination '" + destDir + "' directory cannot be created");
100
            }
101
        }
102
        if (destDir.canWrite() == false) {
103
            throw new IOException("Destination '" + destDir + "' cannot be written to");
104
        }
105
        for (final File srcFile : srcFiles) {
106
            final File dstFile = new File(destDir, srcFile.getName());
107
            if (srcFile.isDirectory()) {
108
                doCopyDirectory(srcFile, dstFile, preserveFileDate);
109
            } else {
110
                doCopyFile(srcFile, dstFile, preserveFileDate);
111
            }
112
        }
113

  
114
        // Do this last, as the above has probably affected directory metadata
115
        if (preserveFileDate) {
116
            destDir.setLastModified(srcDir.lastModified());
117
        }
118
    }
119

  
120
    private static void doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate)
121
            throws IOException {
122
        if (destFile.exists() && destFile.isDirectory()) {
123
            throw new IOException("Destination '" + destFile + "' exists but is a directory");
124
        }
125

  
126
        FileInputStream fis = null;
127
        FileOutputStream fos = null;
128
        FileChannel input = null;
129
        FileChannel output = null;
130
        try {
131
            fis = new FileInputStream(srcFile);
132
            fos = new FileOutputStream(destFile);
133
            input = fis.getChannel();
134
            output = fos.getChannel();
135
            final long size = input.size(); // TODO See IO-386
136
            long pos = 0;
137
            long count = 0;
138
            while (pos < size) {
139
                final long remain = size - pos;
140
                count = remain > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : remain;
141
                final long bytesCopied = output.transferFrom(input, pos, count);
142
                if (bytesCopied == 0) { // IO-385 - can happen if file is truncated after caching the size
143
                    break; // ensure we don't loop forever
144
                }
145
                pos += bytesCopied;
146
            }
147
        } finally {
148
            closeQuietly(output, fos, input, fis);
149
        }
150

  
151
        final long srcLen = srcFile.length(); // TODO See IO-386
152
        final long dstLen = destFile.length(); // TODO See IO-386
153
        if (srcLen != dstLen) {
154
            throw new IOException("Failed to copy full contents from '"
155
                    + srcFile + "' to '" + destFile + "' Expected length: " + srcLen + " Actual: " + dstLen);
156
        }
157
        if (preserveFileDate) {
158
            destFile.setLastModified(srcFile.lastModified());
159
        }
160
    }
161

  
162
    public static void closeQuietly(final Closeable closeable) {
163
        try {
164
            if (closeable != null) {
165
                closeable.close();
166
            }
167
        } catch (final IOException ioe) {
168
            // ignore
169
        }
170
    }
171

  
172
    public static void closeQuietly(final Closeable... closeables) {
173
        if (closeables == null) {
174
            return;
175
        }
176
        for (final Closeable closeable : closeables) {
177
            closeQuietly(closeable);
178
        }
179
    }
180

  
181
}
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.copyjre/pom.xml
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
  <artifactId>org.gvsig.desktop.installer.izpack.copyjre</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
    <groupId>org.gvsig</groupId>
10
    <artifactId>org.gvsig.desktop.installer.izpack</artifactId>
11
    <version>1.1.0</version>
12
  </parent>
13

  
14
  <properties>
15
      <maven.javadoc.skip>true</maven.javadoc.skip>
16
  </properties>
17

  
18
  <dependencies>
19

  
20
  <dependency>
21
      <groupId>org.codehaus.izpack</groupId>
22
      <artifactId>izpack-core</artifactId>
23
      <scope>compile</scope>
24
  </dependency>
25
  <dependency>
26
      <groupId>org.codehaus.izpack</groupId>
27
      <artifactId>izpack-panel</artifactId>
28
      <scope>compile</scope>
29
  </dependency>
30

  
31
  </dependencies>
32

  
33

  
34
  <build>
35
    <plugins>
36

  
37
      <plugin>
38
        <!-- Skip compilation tests -->
39
        <groupId>org.apache.maven.plugins</groupId>
40
        <artifactId>maven-compiler-plugin</artifactId>
41
        <executions>
42
          <execution>
43
            <id>default-testCompile</id>
44
            <phase>process-test-sources</phase>
45
            <goals>
46
              <goal>testCompile</goal>
47
            </goals>
48
            <configuration>
49
              <skip>true</skip>
50
            </configuration>
51
          </execution>
52
        </executions>
53
      </plugin>
54

  
55
      <plugin>
56
        <!-- Skip test execution -->
57
        <groupId>org.apache.maven.plugins</groupId>
58
        <artifactId>maven-surefire-plugin</artifactId>
59
        <configuration>
60
          <skipTests>true</skipTests>
61
        </configuration>
62
      </plugin>
63

  
64
      <plugin>
65
	<groupId>org.codehaus.gmaven</groupId>
66
	<artifactId>gmaven-plugin</artifactId>
67
	<configuration>
68
	  <skip>true</skip>
69
	</configuration>
70
	<executions>
71
	  <execution>
72
	    <id>prepare-gvsig-product-and-packages</id>
73
	    <phase>None</phase>
74
	  </execution>
75

  
76
	  <execution>
77
	    <id>deploy-gvsig-packages</id>
78
	    <phase>None</phase>
79
	  </execution>
80
	</executions>
81
      </plugin>
82

  
83
    </plugins>
84
  </build>
85

  
86
</project>
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.lin.x86_64/src/main/scripts/prepare_lin.groovy
16 16
    log.info("Copy org.gvsig.desktop.installer.izpack.extractpackages.jar")
17 17
    helper.copy_extractpackages_jar(target)
18 18

  
19
    log.info("Copy org.gvsig.desktop.installer.izpack.copyjre.jar")
20
    helper.copy_copyjre_jar(target)
21

  
19 22
    helper.prepare_portable()
20 23
    helper.pack_portable()
21 24
}
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/src/main/scripts/Helper.groovy
264 264

  
265 265
  }
266 266

  
267
  def copy_copyjre_jar(targetdir) {
268
    def org_gvsig_desktop_installer_izpack_copyjre_jar = new FileNameFinder().getFileNames(
269
      getProjectBaseFolder("org.gvsig.desktop.installer.izpack.copyjre","target").getAbsolutePath(),
270
      "org.gvsig.desktop.installer.izpack.copyjre-*.jar",
271
      "*-sources.jar"
272
    )[0]
273

  
274
    copyFileToFile(
275
      org_gvsig_desktop_installer_izpack_copyjre_jar,
276
      new File(targetdir, "org.gvsig.desktop.installer.izpack.copyjre.jar")
277
    )
278

  
279
  }
280

  
267 281
  def expand(s) {
268 282

  
269 283
    def t = "target/portable/gvSIG-desktop-"+this.getVersionWithoutBuildNumber()
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/src/main/izpack/include/jars.xml
1 1
  <jar src="org.gvsig.desktop.installer.izpack.extractpackages.jar" stage="install"/>
2
  <jar src="org.gvsig.desktop.installer.izpack.copyjre.jar" stage="install"/>
2 3
 
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/src/main/izpack/include/job_extract_packages.xml
1
 
1

  
2 2
  <job name="Checking packages file">
3
    <executeclass name="org.gvsig.desktop.installer.izpack.CopyJRE">
4
        <arg>$INSTALL_PATH</arg>
5
    </executeclass>
3 6
    <executeclass name="org.gvsig.desktop.installer.izpack.ExtractPackages">
4 7
        <arg>$INSTALL_PATH</arg>
5 8
    </executeclass>
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.win.x86/src/main/scripts/prepare_win.groovy
16 16
    log.info("Copy org.gvsig.desktop.installer.izpack.extractpackages.jar")
17 17
    helper.copy_extractpackages_jar(target)
18 18

  
19
    log.info("Copy org.gvsig.desktop.installer.izpack.copyjre.jar")
20
    helper.copy_copyjre_jar(target)
21

  
19 22
    log.info("Download busybox.exe")
20 23
    helper.ant.get(
21 24
      src: "http://downloads.gvsig.org/download/gvsig-desktop/runtimes/winutils/x86/busybox.exe",
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/pom.xml
96 96

  
97 97
  <modules>
98 98
    <module>org.gvsig.desktop.installer.izpack.extractpackages</module>
99
    <module>org.gvsig.desktop.installer.izpack.copyjre</module>
99 100
    <module>org.gvsig.desktop.installer.izpack.lin.x86</module>
100 101
    <module>org.gvsig.desktop.installer.izpack.lin.x86_64</module>
101 102
    <module>org.gvsig.desktop.installer.izpack.win.x86</module>
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.installer.izpack/org.gvsig.desktop.installer.izpack.lin.x86/src/main/scripts/prepare_lin.groovy
16 16
    log.info("Copy org.gvsig.desktop.installer.izpack.extractpackages.jar")
17 17
    helper.copy_extractpackages_jar(target)
18 18

  
19
    log.info("Copy org.gvsig.desktop.installer.izpack.copyjre.jar")
20
    helper.copy_copyjre_jar(target)
21

  
19 22
    helper.prepare_portable()
20 23
    helper.pack_portable()
21 24
}

Also available in: Unified diff