Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.maven / src / main / java / org / gvsig / installer / maven / GeneratePluginPackageIndexMojo.java @ 37880

History | View | Annotate | Download (3.07 KB)

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
import java.io.OutputStream;
26
import java.net.MalformedURLException;
27
import java.net.URL;
28

    
29
import org.gvsig.installer.lib.api.InstallerLocator;
30
import org.gvsig.installer.lib.api.InstallerManager;
31
import org.gvsig.installer.lib.api.PackageInfo;
32
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
33
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
34

    
35
/**
36
 * Maven mojo to launch the gvSIG installer to generate a package index of a
37
 * gvSIG plugin.
38
 * <p>
39
 * 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"
40
 * >gvSIG plugin naming standard</a> for information about installers naming and
41
 * versioning.
42
 * </p>
43
 * 
44
 * @see InstallerManager
45
 * 
46
 * @author gvSIG Team
47
 * @version $Id$
48
 * 
49
 * @goal create-package-index
50
 */
51
public class GeneratePluginPackageIndexMojo extends AbstractGeneratePackageMojo {
52

    
53
        /**
54
         * Remote plugin package base download URL. The base path URL where the
55
         * installation package will be located.
56
         * 
57
         * @required
58
         * @parameter
59
         */
60
        private String baseDownloadURL;
61

    
62
        @Override
63
        protected void createPackage(MakePluginPackageService makePluginService,
64
                        PackageInfo info, OutputStream os)
65
                        throws MakePluginPackageServiceException {
66

    
67
                File pluginFolder = makePluginService.getPluginFolder(info);
68

    
69
                PackageInfo infoIndex;
70
                try {
71
                        infoIndex = (PackageInfo) info.clone();
72
                } catch (CloneNotSupportedException e) {
73
                        throw new MakePluginPackageServiceException(
74
                                        "Error cloning the package info: " + info, e);
75
                }
76
                String fullDownloadURL = baseDownloadURL
77
                                + "/"
78
                                + InstallerLocator.getInstallerManager().getPackageFileName(
79
                                                info);
80
            infoIndex.setDownloadURL(fullDownloadURL);
81

    
82
                makePluginService.writePackageInfoForIndex(infoIndex, pluginFolder);
83
                makePluginService.createPackageIndex(info, os);
84
        }
85

    
86
        @Override
87
        protected String getPackageTypeName() {
88
                return "PackageIndex";
89
        }
90

    
91
        @Override
92
        protected String getPackageFileName(PackageInfo info) {
93
                return InstallerLocator.getInstallerManager().getPackageIndexFileName(
94
                                info);
95
        }
96
}