1 package org.codehaus.mojo.javascript;
2
3 /*
4 * Copyright 2001-2005 The Apache Software Foundation.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 import java.io.File;
20
21 /**
22 * Goal to be used from a war project, to compress the scripts present in the
23 * webapp packaging folder. Configured to run in the test phase as there is no
24 * way (in maven 2.0) to run between exploded webapp assembly and .war
25 * packaging.
26 *
27 * @goal war-compress
28 * @phase test
29 * @author <a href="mailto:nicolas@apache.org">nicolas De Loof</a>
30 */
31 public class WebappCompressMojo
32 extends AbstractCompressMojo
33 {
34
35 /**
36 * The directory where the webapp is built.
37 *
38 * @parameter expression="${project.build.directory}/${project.build.finalName}"
39 * @required
40 */
41 private File webappDirectory;
42
43 /**
44 * Folder in webapp containing javascripts
45 *
46 * @parameter default-value="scripts"
47 */
48 private String scripts;
49
50 /**
51 * classifier for the compressed artifact. If not set, compressed script
52 * will replace uncompressed ones, and will apply without any change in
53 * HTML/JSP.
54 *
55 * @parameter
56 */
57 private String classifier;
58
59 /**
60 * {@inheritDoc}
61 *
62 * @see org.codehaus.mojo.javascript.AbstractCompressMojo#getExtension()
63 */
64 public String getExtension()
65 {
66 return classifier;
67 }
68
69 /**
70 * {@inheritDoc}
71 *
72 * @see org.codehaus.mojo.javascript.AbstractCompressMojo#getOutputDirectory()
73 */
74 protected File getOutputDirectory()
75 {
76 return getSourceDirectory();
77 }
78
79 /**
80 * {@inheritDoc}
81 *
82 * @see org.codehaus.mojo.javascript.AbstractCompressMojo#getOutputDirectory()
83 */
84 protected File getStrippedDirectory()
85 {
86 return getSourceDirectory();
87 }
88
89 /**
90 * {@inheritDoc}
91 *
92 * @see org.codehaus.mojo.javascript.AbstractCompressMojo#getSourceDirectory()
93 */
94 protected File getSourceDirectory()
95 {
96 return new File( webappDirectory, scripts );
97 }
98
99 }