Revision 33698

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GenerateInstallerMojo.java
55 55
 * @author gvSIG Team
56 56
 * @version $Id$
57 57
 * 
58
 * @goal generate-installer
58
 * @goal create-installer
59 59
 * 
60 60
 * @phase install
61 61
 */
......
103 103
    private String packaging;
104 104

  
105 105
    /**
106
     * Plugin project name.
107
     * 
108
     * @parameter expression="${project.name}"
109
     * @required
110
     */
111
    private String name;
112

  
113
    /**
114
     * Plugin project description.
115
     * 
116
     * @parameter expression="${project.description}"
117
     * @required
118
     */
119
    private String description;
120

  
121
    /**
122
     * Plugin project version.
123
     * 
124
     * @parameter expression="${project.version}"
125
     * @required
126
     */
127
    private String version;
128

  
129
    /**
130
     * Plugin build number.
131
     * 
132
     * @parameter
133
     * @required
134
     */
135
    private int buildNumber;
136

  
137
    /**
138
     * Plugin state.
139
     * One of: devel, pilot, prototype, alpha[num], beta[num], RC[num], final.
140
     * 
141
     * Defaults to "devel".
142
     * 
143
     * @parameter
144
     */
145
    private String state;
146

  
147
    /**
148
     * If the plugin is a gvSIG official one.
149
     * 
150
     * @parameter
151
     * @required
152
     */
153
    private boolean official;
154

  
155
    /**
156
     * The supported operating system.
157
     * Examples: lin (linux), win (windows), osx_10_4, osx_10_5, osx_10_6.
158
     * 
159
     * Defaults to all.
160
     * 
161
     * @parameter
162
     */
163
    private String operatingSystem;
164

  
165
    /**
166
     * The supported architecture.
167
     * Examples: x86 (32 bits), x86_64 (64 bits).
168
     * 
169
     * Defaults to all.
170
     * 
171
     * @parameter
172
     */
173
    private String architecture;
174

  
175
    /**
176
     * Minimum Java VM version supported.
177
     * Example: j1_5, j1_6.
178
     * 
179
     * Defaults to j1_5.
180
     * 
181
     * @parameter
182
     */
183
    private String javaVM;
184

  
185
    /**
186
     * The minimum gvSIG version supported.
187
     * 
188
     * @parameter
189
     * @required
190
     */
191
    private String gvSIGVersion;
192

  
193
    /**
194
     * Installabe type. Only <strong>plugin</strong> is supported.
195
     * 
196
     * @parameter default="${plugin}"
197
     */
198
    private String installableType = "plugin";
199

  
200
    /**
201 106
     * If the mojo execution is disabled. Useful for projects that inherit
202 107
     * the maven plugin configuration but don't generate installer.
203 108
     * 
......
222 127

  
223 128
        log.info("Generating a installable for the plugin: " + artifactId
224 129
            + " with the following information:");
225
        log.info("\tPlugin name: " + name);
226
        log.info("\tPlugin description: " + description);
227
        log.info("\tPlugin version: " + version);
228
        log.info("\tPlugin build number: " + buildNumber);
229
        log.info("\tPlugin state: " + state);
230
        log.info("\tPlugin official: " + official);
231
        log.info("\tPlugin operatingSystem: " + operatingSystem);
232
        log.info("\tPlugin architecture: " + architecture);
233
        log.info("\tPlugin javaVM: " + javaVM);
234
        log.info("\tPlugin gvSIGVersion: " + gvSIGVersion);
235 130
        log.info("\tgvSIG Plugin's folder: " + pluginsFolder);
236 131
        log.info("\tBundle installation file to create: " + bundleFolder);
237 132

  
......
249 144
            PackageInfo info =
250 145
                makePluginService.getPluginPackageInfo(artifactId);
251 146

  
252
            info.setBuild(buildNumber);
253
            // info.setCode(artifactId);
254
            info.setDescription(description);
255
            info.setName(name);
256
            info.setOfficial(official);
257
            info.setState(state);
258
            info.setType(installableType);
259
            info.setVersion(version);
260
            info.setOperatingSystem(operatingSystem);
261
            info.setArchitecture(architecture);
262
            info.setJavaVM(javaVM);
263
            info.setGvSIGVersion(gvSIGVersion);
264

  
265 147
            // Create the package bundle file
266 148
            String packageBundleFileName =
267 149
                bundleFileName == null ? manager.getPackageBundleFileName(info)
branches/v2_0_0_prep/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
 * @phase compile
57
 */
58
public class GeneratePackageInfoMojo extends AbstractMojo {
59

  
60
    /**
61
     * Location of the gvSIG plugins folder.
62
     * 
63
     * @parameter
64
     * @required
65
     */
66
    private File pluginsFolder;
67

  
68
    /**
69
     * Plugin project artifactId or code, used as gvSIG plugin name.
70
     * 
71
     * @parameter expression="${project.artifactId}"
72
     * @required
73
     */
74
    private String artifactId;
75

  
76
    /**
77
     * Plugin project packaging, to check it is of jar type.
78
     * 
79
     * @parameter expression="${project.packaging}"
80
     * @required
81
     */
82
    private String packaging;
83

  
84
    /**
85
     * Plugin project name.
86
     * 
87
     * @parameter expression="${project.name}"
88
     * @required
89
     */
90
    private String name;
91

  
92
    /**
93
     * Plugin project description.
94
     * 
95
     * @parameter expression="${project.description}"
96
     * @required
97
     */
98
    private String description;
99

  
100
    /**
101
     * Plugin project version.
102
     * 
103
     * @parameter expression="${project.version}"
104
     * @required
105
     */
106
    private String version;
107

  
108
    /**
109
     * Plugin build number.
110
     * 
111
     * @parameter
112
     * @required
113
     */
114
    private int buildNumber;
115

  
116
    /**
117
     * Plugin state.
118
     * One of: devel, pilot, prototype, alpha[num], beta[num], RC[num], final.
119
     * 
120
     * Defaults to "devel".
121
     * 
122
     * @parameter
123
     */
124
    private String state;
125

  
126
    /**
127
     * If the plugin is a gvSIG official one.
128
     * 
129
     * @parameter
130
     * @required
131
     */
132
    private boolean official;
133

  
134
    /**
135
     * The supported operating system.
136
     * Examples: lin (linux), win (windows), osx_10_4, osx_10_5, osx_10_6.
137
     * 
138
     * Defaults to all.
139
     * 
140
     * @parameter
141
     */
142
    private String operatingSystem;
143

  
144
    /**
145
     * The supported architecture.
146
     * Examples: x86 (32 bits), x86_64 (64 bits).
147
     * 
148
     * Defaults to all.
149
     * 
150
     * @parameter
151
     */
152
    private String architecture;
153

  
154
    /**
155
     * Minimum Java VM version supported.
156
     * Example: j1_5, j1_6.
157
     * 
158
     * Defaults to j1_5.
159
     * 
160
     * @parameter
161
     */
162
    private String javaVM;
163

  
164
    /**
165
     * The minimum gvSIG version supported.
166
     * 
167
     * @parameter
168
     * @required
169
     */
170
    private String gvSIGVersion;
171

  
172
    /**
173
     * Installabe type. Only <strong>plugin</strong> is supported.
174
     * 
175
     * @parameter default="${plugin}"
176
     */
177
    private String installableType = "plugin";
178

  
179
    /**
180
     * If the mojo execution is disabled. Useful for projects that inherit
181
     * the maven plugin configuration but don't generate installer.
182
     * 
183
     * @parameter
184
     */
185
    private boolean disabled = false;
186

  
187
    /**
188
     * Plugin project folder where to store the package info.
189
     * 
190
     * @parameter expression="${basedir}"
191
     * @required
192
     */
193
    private File packageInfoFolder;
194

  
195
    public void execute() throws MojoExecutionException, MojoFailureException {
196
        Log log = getLog();
197

  
198
        if (disabled) {
199
            log.info("Package info generation disabled.");
200
            return;
201
        }
202

  
203
        if (!"jar".equals(packaging)) {
204
            log.info("Running on a project with packaging of type " + packaging
205
                + ". Do nothing, as we only create installers for projects "
206
                + "with jar packaging");
207
            return;
208
        }
209

  
210
        log.info("Generating the package info for the plugin: " + artifactId
211
            + " with the following information:");
212
        log.info("\tPlugin name: " + name);
213
        log.info("\tPlugin description: " + description);
214
        log.info("\tPlugin version: " + version);
215
        log.info("\tPlugin build number: " + buildNumber);
216
        log.info("\tPlugin state: " + state);
217
        log.info("\tPlugin official: " + official);
218
        log.info("\tPlugin operatingSystem: " + operatingSystem);
219
        log.info("\tPlugin architecture: " + architecture);
220
        log.info("\tPlugin javaVM: " + javaVM);
221
        log.info("\tPlugin gvSIGVersion: " + gvSIGVersion);
222
        log.info("\tgvSIG Plugin's folder: " + pluginsFolder);
223
        log.info("\tPackage info folder: " + packageInfoFolder);
224

  
225
        try {
226
            new DefaultLibrariesInitializer().fullInitialize();
227

  
228
            InstallerManager manager = InstallerLocator.getInstallerManager();
229

  
230
            MakePluginPackageService makePluginService =
231
                manager.getMakePluginPackageService(pluginsFolder);
232

  
233
            // Get and fill the package info data
234
            PackageInfo info =
235
                makePluginService.getPluginPackageInfo(artifactId);
236

  
237
            info.setBuild(buildNumber);
238
            // info.setCode(artifactId);
239
            info.setDescription(description);
240
            info.setName(name);
241
            info.setOfficial(official);
242
            info.setState(state);
243
            info.setType(installableType);
244
            info.setVersion(version);
245
            info.setOperatingSystem(operatingSystem);
246
            info.setArchitecture(architecture);
247
            info.setJavaVM(javaVM);
248
            info.setGvSIGVersion(gvSIGVersion);
249

  
250
            makePluginService.writePackageInfo(info, packageInfoFolder);
251

  
252
        } catch (LocatorException e) {
253
            throw new MojoExecutionException(
254
                "Error getting a reference to the InstallerManager", e);
255
        } catch (MakePluginPackageServiceException e) {
256
            throw new MojoExecutionException(
257
                "Error getting a MakePluginPackageService for the "
258
                    + "plugin folder: " + pluginsFolder, e);
259
        }
260

  
261
        log.info("Package info file created successfully");
262
    }
263
}

Also available in: Unified diff