Revision 33974
tags/v2_0_0_Build_2020/extensions/org.gvsig.installer/org.gvsig.installer.maven/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" |
|
4 |
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.installer.maven</artifactId> |
|
7 |
<packaging>maven-plugin</packaging> |
|
8 |
<name>org.gvsig.installer.maven</name> |
|
9 |
<parent> |
|
10 |
<artifactId>org.gvsig.installer</artifactId> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<version>1.0.0-SNAPSHOT</version> |
|
13 |
</parent> |
|
14 |
<build> |
|
15 |
<plugins> |
|
16 |
<plugin> |
|
17 |
<artifactId>maven-plugin-plugin</artifactId> |
|
18 |
<!--version>2.5.1</version--> |
|
19 |
<executions> |
|
20 |
<execution> |
|
21 |
<id>generated-helpmojo</id> |
|
22 |
<goals> |
|
23 |
<goal>helpmojo</goal> |
|
24 |
</goals> |
|
25 |
</execution> |
|
26 |
</executions> |
|
27 |
<configuration> |
|
28 |
<goalPrefix>org.gvsig.installer.maven</goalPrefix> |
|
29 |
</configuration> |
|
30 |
</plugin> |
|
31 |
</plugins> |
|
32 |
</build> |
|
33 |
<dependencies> |
|
34 |
<dependency> |
|
35 |
<groupId>org.apache.maven</groupId> |
|
36 |
<artifactId>maven-plugin-api</artifactId> |
|
37 |
<version>2.0</version> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId>org.gvsig.installer.lib.api</artifactId> |
|
42 |
<version>1.0.0-SNAPSHOT</version> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.installer.lib.spi</artifactId> |
|
47 |
<version>1.0.0-SNAPSHOT</version> |
|
48 |
<scope>runtime</scope> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.installer.lib.impl</artifactId> |
|
53 |
<version>1.0.0-SNAPSHOT</version> |
|
54 |
<scope>runtime</scope> |
|
55 |
</dependency> |
|
56 |
<dependency> |
|
57 |
<groupId>org.gvsig</groupId> |
|
58 |
<artifactId>org.gvsig.installer.prov.plugin</artifactId> |
|
59 |
<version>1.0.0-SNAPSHOT</version> |
|
60 |
<scope>runtime</scope> |
|
61 |
</dependency> |
|
62 |
</dependencies> |
|
63 |
<properties> |
|
64 |
<build-dir>${basedir}/../../build</build-dir> |
|
65 |
</properties> |
|
66 |
</project> |
tags/v2_0_0_Build_2020/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GeneratePackageInfoMojo.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.installer.maven; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import org.apache.maven.plugin.AbstractMojo; |
|
27 |
import org.apache.maven.plugin.MojoExecutionException; |
|
28 |
import org.apache.maven.plugin.MojoFailureException; |
|
29 |
import org.apache.maven.plugin.logging.Log; |
|
30 |
|
|
31 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
32 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
33 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
34 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
|
35 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
|
36 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
37 |
import org.gvsig.tools.locator.LocatorException; |
|
38 |
|
|
39 |
/** |
|
40 |
* Maven mojo to launch the gvSIG installer to generate a file with the |
|
41 |
* package info. |
|
42 |
* <p> |
|
43 |
* Look at the <a href= |
|
44 |
* "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig" |
|
45 |
* >gvSIG plugin naming standard</a> for information about installers naming and |
|
46 |
* versioning. |
|
47 |
* </p> |
|
48 |
* |
|
49 |
* @see InstallerManager |
|
50 |
* |
|
51 |
* @author gvSIG Team |
|
52 |
* @version $Id$ |
|
53 |
* |
|
54 |
* @goal write-info |
|
55 |
*/ |
|
56 |
public class GeneratePackageInfoMojo extends AbstractMojo { |
|
57 |
|
|
58 |
/** |
|
59 |
* Location of the gvSIG plugins folder. |
|
60 |
* |
|
61 |
* @parameter |
|
62 |
* @required |
|
63 |
*/ |
|
64 |
private File pluginsFolder; |
|
65 |
|
|
66 |
/** |
|
67 |
* Plugin project artifactId or code, used as gvSIG plugin name. |
|
68 |
* |
|
69 |
* @parameter expression="${project.artifactId}" |
|
70 |
* @required |
|
71 |
*/ |
|
72 |
private String artifactId; |
|
73 |
|
|
74 |
/** |
|
75 |
* Plugin project packaging, to check it is of jar type. |
|
76 |
* |
|
77 |
* @parameter expression="${project.packaging}" |
|
78 |
* @required |
|
79 |
*/ |
|
80 |
private String packaging; |
|
81 |
|
|
82 |
/** |
|
83 |
* Plugin project name. |
|
84 |
* |
|
85 |
* @parameter expression="${project.name}" |
|
86 |
* @required |
|
87 |
*/ |
|
88 |
private String name; |
|
89 |
|
|
90 |
/** |
|
91 |
* Plugin project description. |
|
92 |
* |
|
93 |
* @parameter expression="${project.description}" |
|
94 |
* @required |
|
95 |
*/ |
|
96 |
private String description; |
|
97 |
|
|
98 |
/** |
|
99 |
* Plugin project version. |
|
100 |
* |
|
101 |
* @parameter expression="${project.version}" |
|
102 |
* @required |
|
103 |
*/ |
|
104 |
private String version; |
|
105 |
|
|
106 |
/** |
|
107 |
* Plugin build number. |
|
108 |
* |
|
109 |
* @parameter |
|
110 |
* @required |
|
111 |
*/ |
|
112 |
private int buildNumber; |
|
113 |
|
|
114 |
/** |
|
115 |
* Plugin state. |
|
116 |
* One of: devel, pilot, prototype, alpha[num], beta[num], RC[num], final. |
|
117 |
* |
|
118 |
* Defaults to "devel". |
|
119 |
* |
|
120 |
* @parameter |
|
121 |
*/ |
|
122 |
private String state; |
|
123 |
|
|
124 |
/** |
|
125 |
* If the plugin is a gvSIG official one. |
|
126 |
* |
|
127 |
* @parameter |
|
128 |
* @required |
|
129 |
*/ |
|
130 |
private boolean official; |
|
131 |
|
|
132 |
/** |
|
133 |
* The supported operating system. |
|
134 |
* Examples: lin (linux), win (windows), osx_10_4, osx_10_5, osx_10_6. |
|
135 |
* |
|
136 |
* Defaults to all. |
|
137 |
* |
|
138 |
* @parameter |
|
139 |
*/ |
|
140 |
private String operatingSystem; |
|
141 |
|
|
142 |
/** |
|
143 |
* The supported architecture. |
|
144 |
* Examples: x86 (32 bits), x86_64 (64 bits). |
|
145 |
* |
|
146 |
* Defaults to all. |
|
147 |
* |
|
148 |
* @parameter |
|
149 |
*/ |
|
150 |
private String architecture; |
|
151 |
|
|
152 |
/** |
|
153 |
* Minimum Java VM version supported. |
|
154 |
* Example: j1_5, j1_6. |
|
155 |
* |
|
156 |
* Defaults to j1_5. |
|
157 |
* |
|
158 |
* @parameter |
|
159 |
*/ |
|
160 |
private String javaVM; |
|
161 |
|
|
162 |
/** |
|
163 |
* The minimum gvSIG version supported. |
|
164 |
* |
|
165 |
* @parameter |
|
166 |
* @required |
|
167 |
*/ |
|
168 |
private String gvSIGVersion; |
|
169 |
|
|
170 |
/** |
|
171 |
* Installabe type. Only <strong>plugin</strong> is supported. |
|
172 |
* |
|
173 |
* @parameter default="${plugin}" |
|
174 |
*/ |
|
175 |
private String installableType = "plugin"; |
|
176 |
|
|
177 |
/** |
|
178 |
* If the mojo execution is disabled. Useful for projects that inherit |
|
179 |
* the maven plugin configuration but don't generate installer. |
|
180 |
* |
|
181 |
* @parameter |
|
182 |
*/ |
|
183 |
private boolean disabled = false; |
|
184 |
|
|
185 |
/** |
|
186 |
* Plugin project folder where to store the package info. |
|
187 |
* |
|
188 |
* @parameter expression="${basedir}" |
|
189 |
* @required |
|
190 |
*/ |
|
191 |
private File packageInfoFolder; |
|
192 |
|
|
193 |
public void execute() throws MojoExecutionException, MojoFailureException { |
|
194 |
Log log = getLog(); |
|
195 |
|
|
196 |
if (disabled) { |
|
197 |
log.info("Package info generation disabled."); |
|
198 |
return; |
|
199 |
} |
|
200 |
|
|
201 |
if (!"jar".equals(packaging)) { |
|
202 |
log.info("Running on a project with packaging of type " + packaging |
|
203 |
+ ". Do nothing, as we only create installers for projects " |
|
204 |
+ "with jar packaging"); |
|
205 |
return; |
|
206 |
} |
|
207 |
|
|
208 |
log.info("Generating the package info for the plugin: " + artifactId |
|
209 |
+ " with the following information:"); |
|
210 |
log.info("\tPlugin name: " + name); |
|
211 |
log.info("\tPlugin description: " + description); |
|
212 |
log.info("\tPlugin version: " + version); |
|
213 |
log.info("\tPlugin build number: " + buildNumber); |
|
214 |
log.info("\tPlugin state: " + state); |
|
215 |
log.info("\tPlugin official: " + official); |
|
216 |
log.info("\tPlugin operatingSystem: " + operatingSystem); |
|
217 |
log.info("\tPlugin architecture: " + architecture); |
|
218 |
log.info("\tPlugin javaVM: " + javaVM); |
|
219 |
log.info("\tPlugin gvSIGVersion: " + gvSIGVersion); |
|
220 |
log.info("\tgvSIG Plugin's folder: " + pluginsFolder); |
|
221 |
log.info("\tPackage info folder: " + packageInfoFolder); |
|
222 |
|
|
223 |
try { |
|
224 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
225 |
|
|
226 |
InstallerManager manager = InstallerLocator.getInstallerManager(); |
|
227 |
|
|
228 |
MakePluginPackageService makePluginService = |
|
229 |
manager.getMakePluginPackageService(pluginsFolder); |
|
230 |
|
|
231 |
// Get and fill the package info data |
|
232 |
PackageInfo info = |
|
233 |
makePluginService.getPluginPackageInfo(artifactId); |
|
234 |
|
|
235 |
info.setBuild(buildNumber); |
|
236 |
// info.setCode(artifactId); |
|
237 |
info.setDescription(description); |
|
238 |
info.setName(name); |
|
239 |
info.setOfficial(official); |
|
240 |
info.setState(state); |
|
241 |
info.setType(installableType); |
|
242 |
info.setVersion(version); |
|
243 |
info.setOperatingSystem(operatingSystem); |
|
244 |
info.setArchitecture(architecture); |
|
245 |
info.setJavaVM(javaVM); |
|
246 |
info.setGvSIGVersion(gvSIGVersion); |
|
247 |
|
|
248 |
makePluginService.writePackageInfo(info, packageInfoFolder); |
|
249 |
|
|
250 |
} catch (LocatorException e) { |
|
251 |
throw new MojoExecutionException( |
|
252 |
"Error getting a reference to the InstallerManager", e); |
|
253 |
} catch (MakePluginPackageServiceException e) { |
|
254 |
throw new MojoExecutionException( |
|
255 |
"Error getting a MakePluginPackageService for the " |
|
256 |
+ "plugin folder: " + pluginsFolder, e); |
|
257 |
} |
|
258 |
|
|
259 |
log.info("Package info file created successfully"); |
|
260 |
} |
|
261 |
} |
tags/v2_0_0_Build_2020/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GenerateInstallerMojo.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.installer.maven; |
|
23 |
|
|
24 |
import java.io.BufferedOutputStream; |
|
25 |
import java.io.File; |
|
26 |
import java.io.FileNotFoundException; |
|
27 |
import java.io.FileOutputStream; |
|
28 |
import java.io.IOException; |
|
29 |
|
|
30 |
import org.apache.maven.plugin.AbstractMojo; |
|
31 |
import org.apache.maven.plugin.MojoExecutionException; |
|
32 |
import org.apache.maven.plugin.MojoFailureException; |
|
33 |
import org.apache.maven.plugin.logging.Log; |
|
34 |
|
|
35 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
36 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
37 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
38 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
|
39 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
|
40 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
41 |
import org.gvsig.tools.locator.LocatorException; |
|
42 |
|
|
43 |
/** |
|
44 |
* Maven mojo to launch the gvSIG installer to generate a installation |
|
45 |
* bundle of a gvSIG plugin. |
|
46 |
* <p> |
|
47 |
* Look at the <a href= |
|
48 |
* "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig" |
|
49 |
* >gvSIG plugin naming standard</a> for information about installers naming and |
|
50 |
* versioning. |
|
51 |
* </p> |
|
52 |
* |
|
53 |
* @see InstallerManager |
|
54 |
* |
|
55 |
* @author gvSIG Team |
|
56 |
* @version $Id$ |
|
57 |
* |
|
58 |
* @goal create-installer |
|
59 |
*/ |
|
60 |
public class GenerateInstallerMojo extends AbstractMojo { |
|
61 |
|
|
62 |
/** |
|
63 |
* Location of the gvSIG plugins folder. |
|
64 |
* |
|
65 |
* @parameter |
|
66 |
* @required |
|
67 |
*/ |
|
68 |
private File pluginsFolder; |
|
69 |
|
|
70 |
/** |
|
71 |
* Location of the folder where to create the package bundle file. |
|
72 |
* |
|
73 |
* @parameter |
|
74 |
* @required |
|
75 |
*/ |
|
76 |
private File bundleFolder; |
|
77 |
|
|
78 |
/** |
|
79 |
* Name of the package bundle file. If not provided, the |
|
80 |
* official gvSIG name will be used, as provided by |
|
81 |
* the org.gvsig.installer.lib.api.InstallerManager. |
|
82 |
* |
|
83 |
* @parameter |
|
84 |
*/ |
|
85 |
private String bundleFileName; |
|
86 |
|
|
87 |
/** |
|
88 |
* Plugin project artifactId or code, used as gvSIG plugin name. |
|
89 |
* |
|
90 |
* @parameter expression="${project.artifactId}" |
|
91 |
* @required |
|
92 |
*/ |
|
93 |
private String artifactId; |
|
94 |
|
|
95 |
/** |
|
96 |
* Plugin project packaging, to check it is of jar type. |
|
97 |
* |
|
98 |
* @parameter expression="${project.packaging}" |
|
99 |
* @required |
|
100 |
*/ |
|
101 |
private String packaging; |
|
102 |
|
|
103 |
/** |
|
104 |
* If the mojo execution is disabled. Useful for projects that inherit |
|
105 |
* the maven plugin configuration but don't generate installer. |
|
106 |
* |
|
107 |
* @parameter |
|
108 |
*/ |
|
109 |
private boolean disabled = false; |
|
110 |
|
|
111 |
public void execute() throws MojoExecutionException, MojoFailureException { |
|
112 |
Log log = getLog(); |
|
113 |
|
|
114 |
if (disabled) { |
|
115 |
log.info("Installer generation disabled."); |
|
116 |
return; |
|
117 |
} |
|
118 |
|
|
119 |
if (!"jar".equals(packaging)) { |
|
120 |
log.info("Running on a project with packaging of type " + packaging |
|
121 |
+ ". Do nothing, as we only create installers for projects " |
|
122 |
+ "with jar packaging"); |
|
123 |
return; |
|
124 |
} |
|
125 |
|
|
126 |
log.info("Generating a installable for the plugin: " + artifactId |
|
127 |
+ " with the following information:"); |
|
128 |
log.info("\tgvSIG Plugin's folder: " + pluginsFolder); |
|
129 |
log.info("\tBundle installation file to create: " + bundleFolder); |
|
130 |
|
|
131 |
File packageBundleFile = null; |
|
132 |
|
|
133 |
try { |
|
134 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
135 |
|
|
136 |
InstallerManager manager = InstallerLocator.getInstallerManager(); |
|
137 |
|
|
138 |
MakePluginPackageService makePluginService = |
|
139 |
manager.getMakePluginPackageService(pluginsFolder); |
|
140 |
|
|
141 |
// Get and fill the package info data |
|
142 |
PackageInfo info = |
|
143 |
makePluginService.getPluginPackageInfo(artifactId); |
|
144 |
|
|
145 |
// Create the package bundle file |
|
146 |
String packageBundleFileName = |
|
147 |
bundleFileName == null ? manager.getPackageBundleFileName(info) |
|
148 |
: bundleFileName; |
|
149 |
|
|
150 |
if (!bundleFolder.exists()) { |
|
151 |
bundleFolder.mkdirs(); |
|
152 |
} |
|
153 |
packageBundleFile = new File(bundleFolder, packageBundleFileName); |
|
154 |
|
|
155 |
FileOutputStream fos = new FileOutputStream(packageBundleFile); |
|
156 |
BufferedOutputStream bos = new BufferedOutputStream(fos); |
|
157 |
|
|
158 |
makePluginService.createPluginPackage(info, bos); |
|
159 |
|
|
160 |
bos.flush(); |
|
161 |
bos.close(); |
|
162 |
fos.close(); |
|
163 |
} catch (LocatorException e) { |
|
164 |
throw new MojoExecutionException( |
|
165 |
"Error getting a reference to the InstallerManager", e); |
|
166 |
} catch (MakePluginPackageServiceException e) { |
|
167 |
throw new MojoExecutionException( |
|
168 |
"Error getting a MakePluginPackageService for the " |
|
169 |
+ "plugin folder: " + pluginsFolder, e); |
|
170 |
} catch (FileNotFoundException e) { |
|
171 |
throw new MojoExecutionException( |
|
172 |
"Error creating the bundle installation file: " |
|
173 |
+ packageBundleFile, e); |
|
174 |
} catch (IOException e) { |
|
175 |
throw new MojoExecutionException( |
|
176 |
"I/O error writing the bundle installation file: " |
|
177 |
+ packageBundleFile, e); |
|
178 |
} |
|
179 |
|
|
180 |
log.info("Bundle installation file created successfully"); |
|
181 |
} |
|
182 |
} |
|
0 | 183 |
Also available in: Unified diff