svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.maven / src / main / java / org / gvsig / installer / maven / GeneratePluginPackageIndexMojo.java @ 40560
History | View | Annotate | Download (3.16 KB)
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.installer.maven; |
25 |
|
26 |
import java.io.File; |
27 |
import java.io.OutputStream; |
28 |
import java.net.MalformedURLException; |
29 |
import java.net.URL; |
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 |
|
37 |
/**
|
38 |
* Maven mojo to launch the gvSIG installer to generate a package index of a
|
39 |
* gvSIG plugin.
|
40 |
* <p>
|
41 |
* Look at the <a href="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"
|
42 |
* >gvSIG plugin naming standard</a> for information about installers naming and
|
43 |
* versioning.
|
44 |
* </p>
|
45 |
*
|
46 |
* @see InstallerManager
|
47 |
*
|
48 |
* @author gvSIG Team
|
49 |
* @version $Id$
|
50 |
*
|
51 |
* @goal create-package-index
|
52 |
*/
|
53 |
public class GeneratePluginPackageIndexMojo extends AbstractGeneratePackageMojo { |
54 |
|
55 |
/**
|
56 |
* Remote plugin package base download URL. The base path URL where the
|
57 |
* installation package will be located.
|
58 |
*
|
59 |
* @required
|
60 |
* @parameter
|
61 |
*/
|
62 |
private String baseDownloadURL; |
63 |
|
64 |
@Override
|
65 |
protected void createPackage(MakePluginPackageService makePluginService, |
66 |
PackageInfo info, OutputStream os)
|
67 |
throws MakePluginPackageServiceException {
|
68 |
|
69 |
File pluginFolder = makePluginService.getPluginFolder(info);
|
70 |
|
71 |
PackageInfo infoIndex; |
72 |
try {
|
73 |
infoIndex = (PackageInfo) info.clone(); |
74 |
} catch (CloneNotSupportedException e) { |
75 |
throw new MakePluginPackageServiceException( |
76 |
"Error cloning the package info: " + info, e);
|
77 |
} |
78 |
|
79 |
InstallerManager manager = InstallerLocator.getInstallerManager(); |
80 |
String fullDownloadURL = baseDownloadURL
|
81 |
+ "/"
|
82 |
+ manager.getPackageFileName(info); |
83 |
infoIndex.setDownloadURL(fullDownloadURL); |
84 |
|
85 |
makePluginService.writePackageInfoForIndex(infoIndex, pluginFolder); |
86 |
makePluginService.createPackageIndex(info, os); |
87 |
} |
88 |
|
89 |
@Override
|
90 |
protected String getPackageTypeName() { |
91 |
return "PackageIndex"; |
92 |
} |
93 |
|
94 |
@Override
|
95 |
protected String getPackageFileName(PackageInfo info) { |
96 |
return InstallerLocator.getInstallerManager().getPackageIndexFileName(
|
97 |
info); |
98 |
} |
99 |
} |