1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.codehaus.mojo.nbm; |
18 | |
|
19 | |
import java.io.File; |
20 | |
import org.apache.maven.plugin.AbstractMojo; |
21 | |
import org.apache.maven.plugin.MojoExecutionException; |
22 | |
import org.apache.maven.plugin.MojoFailureException; |
23 | |
import org.apache.maven.plugins.annotations.Mojo; |
24 | |
import org.apache.maven.plugins.annotations.Parameter; |
25 | |
import org.apache.maven.project.MavenProject; |
26 | |
import org.codehaus.plexus.archiver.util.DefaultFileSet; |
27 | |
import org.codehaus.plexus.archiver.zip.ZipArchiver; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
@Mojo(name="standalone-zip", requiresProject=true, threadSafe = true) |
36 | 0 | public class CreateStandaloneMojo |
37 | |
extends AbstractMojo |
38 | |
{ |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@Parameter(property="netbeans.branding.token", required=true) |
44 | |
protected String brandingToken; |
45 | |
|
46 | |
|
47 | |
|
48 | |
@Parameter(required=true, defaultValue="${project.build.directory}") |
49 | |
private File outputDirectory; |
50 | |
|
51 | |
|
52 | |
|
53 | |
@Parameter(defaultValue="${project.build.finalName}") |
54 | |
private String finalName; |
55 | |
|
56 | |
|
57 | |
|
58 | |
@Parameter(required=true, readonly=true, property="project") |
59 | |
private MavenProject project; |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public void execute() |
67 | |
throws MojoExecutionException, MojoFailureException |
68 | |
{ |
69 | |
|
70 | |
try |
71 | |
{ |
72 | 0 | File nbmBuildDirFile = new File( outputDirectory, brandingToken ); |
73 | |
|
74 | 0 | ZipArchiver archiver = new ZipArchiver(); |
75 | 0 | DefaultFileSet fs = new DefaultFileSet(); |
76 | 0 | fs.setDirectory( outputDirectory ); |
77 | 0 | fs.setIncludes( new String[] { |
78 | |
brandingToken + "/**", |
79 | |
} ); |
80 | 0 | fs.setExcludes( new String[] { |
81 | |
brandingToken + "/bin/*", |
82 | |
} ); |
83 | 0 | archiver.addFileSet( fs ); |
84 | 0 | File bins = new File( nbmBuildDirFile, "bin" ); |
85 | 0 | for ( File bin : bins.listFiles() ) |
86 | |
{ |
87 | 0 | archiver.addFile( bin, brandingToken + "/bin/" + bin.getName(), 0755 ); |
88 | |
} |
89 | 0 | File zipFile = new File( outputDirectory, finalName + ".zip" ); |
90 | |
|
91 | |
|
92 | 0 | archiver.setDestFile( zipFile ); |
93 | 0 | archiver.setForced( false ); |
94 | 0 | archiver.createArchive(); |
95 | 0 | project.getArtifact().setFile( zipFile ); |
96 | |
|
97 | |
} |
98 | 0 | catch ( Exception ex ) |
99 | |
{ |
100 | 0 | throw new MojoExecutionException( "", ex ); |
101 | 0 | } |
102 | |
|
103 | 0 | } |
104 | |
} |