View Javadoc

1   package org.apache.maven.plugin.dependency;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.plugins.annotations.Parameter;
23  
24  import java.io.File;
25  
26  /**
27   * Abstract Parent class used by mojos that get Artifact information from the
28   * project dependencies.
29   *
30   * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
31   * @version $Id: AbstractFromDependenciesMojo.java 1357251 2012-07-04 13:28:33Z olamy $
32   */
33  public abstract class AbstractFromDependenciesMojo
34      extends AbstractDependencyFilterMojo
35  {
36  
37      /**
38       * Strip artifact version during copy
39       */
40      @Parameter( property = "mdep.stripVersion", defaultValue = "false" )
41      protected boolean stripVersion = false;
42  
43      /**
44       * Default location used for mojo unless overridden in ArtifactItem
45       *
46       * @since 1.0
47       */
48      @Parameter( property = "outputDirectory", defaultValue = "${project.build.directory}/dependency" )
49      protected File outputDirectory;
50  
51      /**
52       * Place each artifact in the same directory layout as a default repository.
53       * <br/>example: /outputDirectory/junit/junit/3.8.1/junit-3.8.1.jar
54       *
55       * @since 2.0-alpha-2
56       */
57      @Parameter( property = "mdep.useRepositoryLayout", defaultValue = "false" )
58      protected boolean useRepositoryLayout;
59  
60      /**
61       * Also copy the pom of each artifact.
62       *
63       * @since 2.0
64       */
65      @Parameter( property = "mdep.copyPom", defaultValue = "false" )
66      protected boolean copyPom = true;
67  
68      /**
69       * Place each type of file in a separate subdirectory. (example
70       * /outputDirectory/runtime /outputDirectory/provided etc)
71       *
72       * @since 2.2
73       */
74      @Parameter( property = "mdep.useSubDirectoryPerScope", defaultValue = "false" )
75      protected boolean useSubDirectoryPerScope;
76  
77      /**
78       * Place each type of file in a separate subdirectory. (example
79       * /outputDirectory/jars /outputDirectory/wars etc)
80       *
81       * @since 2.0-alpha-1
82       */
83      @Parameter( property = "mdep.useSubDirectoryPerType", defaultValue = "false" )
84      protected boolean useSubDirectoryPerType;
85  
86      /**
87       * Place each file in a separate subdirectory. (example
88       * <code>/outputDirectory/junit-3.8.1-jar</code>)
89       *
90       * @since 2.0-alpha-1
91       */
92      @Parameter( property = "mdep.useSubDirectoryPerArtifact", defaultValue = "false" )
93      protected boolean useSubDirectoryPerArtifact;
94  
95      /**
96       * This only applies if the classifier parameter is used.
97       *
98       * @since 2.0-alpha-2
99       */
100     @Parameter( property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false" )
101     protected boolean failOnMissingClassifierArtifact = true;
102 
103     /**
104      * @return Returns the outputDirectory.
105      */
106     public File getOutputDirectory()
107     {
108         return this.outputDirectory;
109     }
110 
111     /**
112      * @param theOutputDirectory The outputDirectory to set.
113      */
114     public void setOutputDirectory( File theOutputDirectory )
115     {
116         this.outputDirectory = theOutputDirectory;
117     }
118 
119     /**
120      * @return Returns the useSubDirectoryPerArtifact.
121      */
122     public boolean isUseSubDirectoryPerArtifact()
123     {
124         return this.useSubDirectoryPerArtifact;
125     }
126 
127     /**
128      * @param theUseSubDirectoryPerArtifact The useSubDirectoryPerArtifact to set.
129      */
130     public void setUseSubDirectoryPerArtifact( boolean theUseSubDirectoryPerArtifact )
131     {
132         this.useSubDirectoryPerArtifact = theUseSubDirectoryPerArtifact;
133     }
134 
135     /**
136      * @return Returns the useSubDirectoryPerScope
137      */
138     public boolean isUseSubDirectoryPerScope()
139     {
140         return this.useSubDirectoryPerScope;
141     }
142 
143     /**
144      * @param theUseSubDirectoryPerScope The useSubDirectoryPerScope to set.
145      */
146     public void setUseSubDirectoryPerScope( boolean theUseSubDirectoryPerScope )
147     {
148         this.useSubDirectoryPerScope = theUseSubDirectoryPerScope;
149     }
150 
151     /**
152      * @return Returns the useSubDirectoryPerType.
153      */
154     public boolean isUseSubDirectoryPerType()
155     {
156         return this.useSubDirectoryPerType;
157     }
158 
159     /**
160      * @param theUseSubDirectoryPerType The useSubDirectoryPerType to set.
161      */
162     public void setUseSubDirectoryPerType( boolean theUseSubDirectoryPerType )
163     {
164         this.useSubDirectoryPerType = theUseSubDirectoryPerType;
165     }
166 
167     public boolean isFailOnMissingClassifierArtifact()
168     {
169         return failOnMissingClassifierArtifact;
170     }
171 
172     public void setFailOnMissingClassifierArtifact( boolean failOnMissingClassifierArtifact )
173     {
174         this.failOnMissingClassifierArtifact = failOnMissingClassifierArtifact;
175     }
176 
177     public boolean isStripVersion()
178     {
179         return stripVersion;
180     }
181 
182     public void setStripVersion( boolean stripVersion )
183     {
184         this.stripVersion = stripVersion;
185     }
186 
187     /**
188      * @return true, if dependencies must be planted in a repository layout
189      */
190     public boolean isUseRepositoryLayout()
191     {
192         return useRepositoryLayout;
193     }
194 
195     /**
196      * @param useRepositoryLayout -
197      *                            true if dependencies must be planted in a repository layout
198      */
199     public void setUseRepositoryLayout( boolean useRepositoryLayout )
200     {
201         this.useRepositoryLayout = useRepositoryLayout;
202     }
203 
204     /**
205      * @return true, if the pom of each artifact must be copied
206      */
207     public boolean isCopyPom()
208     {
209         return this.copyPom;
210     }
211 
212     /**
213      * @param copyPom - true if the pom of each artifact must be copied
214      */
215     public void setCopyPom( boolean copyPom )
216     {
217         this.copyPom = copyPom;
218     }
219 
220 }