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