View Javadoc
1   package org.apache.maven.plugin.javadoc.resolver;
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.artifact.factory.ArtifactFactory;
23  import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
24  import org.apache.maven.artifact.repository.ArtifactRepository;
25  import org.apache.maven.artifact.resolver.ArtifactResolver;
26  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
27  import org.apache.maven.plugin.logging.Log;
28  import org.apache.maven.project.MavenProject;
29  import org.codehaus.plexus.archiver.manager.ArchiverManager;
30  
31  import java.io.File;
32  import java.util.List;
33  
34  /**
35   * 
36   */
37  public class SourceResolverConfig
38  {
39  
40      private final MavenProject project;
41  
42      private ArtifactFilter filter;
43  
44      private List<MavenProject> reactorProjects;
45  
46      private final File outputBasedir;
47  
48      private boolean compileSourceIncluded;
49  
50      private boolean testSourceIncluded;
51  
52      private final ArtifactRepository localRepository;
53  
54      private final ArtifactResolver artifactResolver;
55  
56      private final ArtifactMetadataSource artifactMetadataSource;
57  
58      private final ArchiverManager archiverManager;
59  
60      private final ArtifactFactory artifactFactory;
61  
62      private final Log log;
63  
64      /**
65       * @param log {@link Log}
66       * @param project {@link MavenProject}
67       * @param localRepository {@link ArtifactRepository}
68       * @param outputBasedir The output base directory.
69       * @param artifactResolver {@link ArtifactResolver}
70       * @param artifactFactory {@link ArtifactFactory}
71       * @param artifactMetadataSource {@link ArtifactMetadataSource}
72       * @param archiverManager {@link ArchiverManager}
73       */
74      public SourceResolverConfig( final Log log, final MavenProject project, final ArtifactRepository localRepository,
75                                   final File outputBasedir, final ArtifactResolver artifactResolver,
76                                   final ArtifactFactory artifactFactory,
77                                   final ArtifactMetadataSource artifactMetadataSource,
78                                   final ArchiverManager archiverManager )
79      {
80          this.log = log;
81          this.project = project;
82          this.localRepository = localRepository;
83          this.outputBasedir = outputBasedir;
84          this.artifactResolver = artifactResolver;
85          this.artifactFactory = artifactFactory;
86          this.artifactMetadataSource = artifactMetadataSource;
87          this.archiverManager = archiverManager;
88      }
89  
90      /**
91       * @param filter {@link ArtifactFilter}
92       * @return {@link SourceResolverConfig}
93       */
94      public SourceResolverConfig withFilter( final ArtifactFilter filter )
95      {
96          this.filter = filter;
97          return this;
98      }
99  
100     /**
101      * @param reactorProjects The list of reactor projects.
102      * @return {@link SourceResolverConfig}
103      */
104     public SourceResolverConfig withReactorProjects( final List<MavenProject> reactorProjects )
105     {
106         this.reactorProjects = reactorProjects;
107         return this;
108     }
109 
110     /**
111      * @return {@link SourceResolverConfig}
112      */
113     public SourceResolverConfig withCompileSources()
114     {
115         compileSourceIncluded = true;
116         return this;
117     }
118 
119     /**
120      * @return {@link SourceResolverConfig}
121      */
122     public SourceResolverConfig withoutCompileSources()
123     {
124         compileSourceIncluded = false;
125         return this;
126     }
127 
128     /**
129      * @return {@link SourceResolverConfig}
130      */
131     public SourceResolverConfig withTestSources()
132     {
133         testSourceIncluded = true;
134         return this;
135     }
136 
137     /**
138      * @return {@link SourceResolverConfig}
139      */
140     public SourceResolverConfig withoutTestSources()
141     {
142         testSourceIncluded = false;
143         return this;
144     }
145 
146     /**
147      * @return {@link MavenProject}
148      */
149     public MavenProject project()
150     {
151         return project;
152     }
153 
154     /**
155      * @return {@link ArtifactRepository}
156      */
157     public ArtifactRepository localRepository()
158     {
159         return localRepository;
160     }
161 
162     /**
163      * @return {@link ArtifactFilter}
164      */
165     public ArtifactFilter filter()
166     {
167         return filter;
168     }
169 
170     /**
171      * @return list of {@link MavenProject}
172      */
173     public List<MavenProject> reactorProjects()
174     {
175         return reactorProjects;
176     }
177 
178     /**
179      * @return {@link #outputBasedir}
180      */
181     public File outputBasedir()
182     {
183         return outputBasedir;
184     }
185 
186     /**
187      * @return {@link #compileSourceIncluded}
188      */
189     public boolean includeCompileSources()
190     {
191         return compileSourceIncluded;
192     }
193 
194     /**
195      * @return {@link #testSourceIncluded}
196      */
197     public boolean includeTestSources()
198     {
199         return testSourceIncluded;
200     }
201 
202     /**
203      * @return {@link #artifactResolver}
204      */
205     public ArtifactResolver artifactResolver()
206     {
207         return artifactResolver;
208     }
209 
210     /**
211      * @return {@link #artifactMetadataSource}
212      */
213     public ArtifactMetadataSource artifactMetadataSource()
214     {
215         return artifactMetadataSource;
216     }
217 
218     /**
219      * @return {@link #archiverManager}
220      */
221     public ArchiverManager archiverManager()
222     {
223         return archiverManager;
224     }
225 
226     /**
227      * @return {@link #artifactFactory}
228      */
229     public ArtifactFactory artifactFactory()
230     {
231         return artifactFactory;
232     }
233     
234     /**
235      * @return {@link #log}
236      */
237     public Log log()
238     {
239         return log;
240     }
241 
242 }