1 package org.apache.maven.plugins.site;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugins.annotations.Mojo;
26 import org.apache.maven.plugins.annotations.Parameter;
27 import org.apache.maven.plugins.annotations.ResolutionScope;
28
29
30
31
32
33
34
35
36
37
38
39
40
41 @Mojo( name = "stage", requiresDependencyResolution = ResolutionScope.TEST )
42 public class SiteStageMojo
43 extends AbstractDeployMojo
44 {
45
46
47
48
49
50
51 @Parameter( property = "stagingDirectory" )
52 private File stagingDirectory;
53
54
55
56
57
58
59 @Parameter( property = "maven.site.skip", defaultValue = "false" )
60 private boolean skip;
61
62 @Override
63 protected String getDeployRepositoryID()
64 throws MojoExecutionException
65 {
66 return "stagingLocal";
67 }
68
69 @Override
70 protected String getDeployRepositoryURL()
71 throws MojoExecutionException
72 {
73 final String stageDir = ( stagingDirectory == null ) ? null : stagingDirectory.getAbsolutePath();
74 final String outputDir = getStagingDirectory( stageDir );
75
76 getLog().info( "Using this base directory for staging: " + outputDir );
77
78 final File outputDirectory = new File( outputDir );
79
80 if ( !outputDirectory.exists() )
81 {
82 outputDirectory.mkdirs();
83 }
84
85 return "file://" + outputDirectory.getAbsolutePath();
86 }
87
88 public void execute()
89 throws MojoExecutionException
90 {
91 if ( skip )
92 {
93 getLog().info( "maven.site.skip = true: Skipping site staging" );
94 return;
95 }
96
97 super.execute();
98 }
99
100 protected boolean isDeploy()
101 {
102
103 return false;
104 }
105
106
107
108
109
110
111
112
113 private String getStagingDirectory( String usersStagingDirectory )
114 {
115 String topLevelURL = null;
116
117 if ( usersStagingDirectory != null )
118 {
119
120 getLog().debug( "stagingDirectory specified by the user: " + usersStagingDirectory );
121 topLevelURL = usersStagingDirectory;
122 }
123 else
124 {
125
126 topLevelURL =
127 getTopLevelBuildDirectory().getAbsolutePath() + "/" + DEFAULT_STAGING_DIRECTORY;
128 getLog().debug( "stagingDirectory NOT specified, using the top level project: " + topLevelURL );
129 }
130
131
132
133
134
135 return topLevelURL;
136 }
137 }