View Javadoc
1   /*
2    * #%L
3    * wcm.io
4    * %%
5    * Copyright (C) 2016 wcm.io
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package io.wcm.devops.conga.tooling.maven.plugin.util;
21  
22  import java.util.List;
23  import java.util.Map;
24  
25  import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
26  import org.apache.maven.execution.MavenSession;
27  import org.apache.maven.plugin.logging.Log;
28  import org.apache.maven.project.MavenProject;
29  import org.eclipse.aether.RepositorySystem;
30  import org.eclipse.aether.RepositorySystemSession;
31  import org.eclipse.aether.repository.RemoteRepository;
32  import org.sonatype.plexus.build.incremental.BuildContext;
33  
34  /**
35   * Contains maven-specific context objects.
36   */
37  public final class MavenContext {
38  
39    private MavenProject project;
40    private MavenSession session;
41    private org.apache.maven.repository.RepositorySystem repositorySystem;
42    private ResolutionErrorHandler resolutionErrorHandler;
43    private BuildContext buildContext;
44    private Log log;
45    private RepositorySystem repoSystem;
46    private RepositorySystemSession repoSession;
47    private List<RemoteRepository> remoteRepos;
48    private Map<String, String> artifactTypeMappings;
49  
50    /**
51     * @return Maven project
52     */
53    public MavenProject getProject() {
54      return this.project;
55    }
56  
57    /**
58     * @param value Maven project
59     * @return this
60     */
61    public MavenContext project(MavenProject value) {
62      this.project = value;
63      return this;
64    }
65  
66    /**
67     * @return Maven Session
68     */
69    public MavenSession getSession() {
70      return this.session;
71    }
72  
73    /**
74     * @param value Maven Session
75     * @return this
76     */
77    public MavenContext session(MavenSession value) {
78      this.session = value;
79      return this;
80    }
81  
82    /**
83     * @return Repository system
84     */
85    public org.apache.maven.repository.RepositorySystem getRepositorySystem() {
86      return this.repositorySystem;
87    }
88  
89    /**
90     * @param value Repository system
91     * @return this
92     */
93    public MavenContext setRepositorySystem(org.apache.maven.repository.RepositorySystem value) {
94      this.repositorySystem = value;
95      return this;
96    }
97  
98    /**
99     * @return Resolution error handler
100    */
101   public ResolutionErrorHandler getResolutionErrorHandler() {
102     return this.resolutionErrorHandler;
103   }
104 
105   /**
106    * @param value Resolution error handler
107    * @return this
108    */
109   public MavenContext resolutionErrorHandler(ResolutionErrorHandler value) {
110     this.resolutionErrorHandler = value;
111     return this;
112   }
113 
114   /**
115    * @return Build context
116    */
117   public BuildContext getBuildContext() {
118     return this.buildContext;
119   }
120 
121   /**
122    * @param value Build context
123    * @return this
124    */
125   public MavenContext buildContext(BuildContext value) {
126     this.buildContext = value;
127     return this;
128   }
129 
130   /**
131    * @return Log
132    */
133   public Log getLog() {
134     return this.log;
135   }
136 
137   /**
138    * @param value Log
139    * @return this
140    */
141   public MavenContext log(Log value) {
142     this.log = value;
143     return this;
144   }
145 
146   /**
147    * @return Repository system
148    */
149   public RepositorySystem getRepoSystem() {
150     return this.repoSystem;
151   }
152 
153   /**
154    * @param value Repository system
155    * @return this
156    */
157   public MavenContext repoSystem(RepositorySystem value) {
158     this.repoSystem = value;
159     return this;
160   }
161 
162   /**
163    * @return Repository session
164    */
165   public RepositorySystemSession getRepoSession() {
166     return this.repoSession;
167   }
168 
169   /**
170    * @param value Repository session
171    * @return this
172    */
173   public MavenContext repoSession(RepositorySystemSession value) {
174     this.repoSession = value;
175     return this;
176   }
177 
178   /**
179    * @return Remote repositories
180    */
181   public List<RemoteRepository> getRemoteRepos() {
182     return this.remoteRepos;
183   }
184 
185   /**
186    * @param value Remote repositories
187    * @return this
188    */
189   public MavenContext remoteRepos(List<RemoteRepository> value) {
190     this.remoteRepos = value;
191     return this;
192   }
193 
194   /**
195    * @return Artifact type mappings
196    */
197   public Map<String, String> getArtifactTypeMappings() {
198     return this.artifactTypeMappings;
199   }
200 
201   /**
202    * @param value Artifact type mappings
203    * @return this
204    */
205   public MavenContext artifactTypeMappings(Map<String, String> value) {
206     this.artifactTypeMappings = value;
207     return this;
208   }
209 
210 }