1 | |
package org.apache.maven.execution; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
23 | |
import org.apache.maven.monitor.event.EventDispatcher; |
24 | |
import org.apache.maven.plugin.descriptor.PluginDescriptor; |
25 | |
import org.apache.maven.project.DefaultProjectBuilderConfiguration; |
26 | |
import org.apache.maven.project.MavenProject; |
27 | |
import org.apache.maven.project.ProjectBuilderConfiguration; |
28 | |
import org.apache.maven.settings.Settings; |
29 | |
import org.codehaus.plexus.PlexusContainer; |
30 | |
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; |
31 | |
|
32 | |
import java.util.Date; |
33 | |
import java.util.List; |
34 | |
import java.util.Map; |
35 | |
import java.util.Properties; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public class MavenSession |
42 | |
{ |
43 | |
private PlexusContainer container; |
44 | |
|
45 | |
private ArtifactRepository localRepository; |
46 | |
|
47 | |
private List goals; |
48 | |
|
49 | |
private EventDispatcher eventDispatcher; |
50 | |
|
51 | |
|
52 | |
private final Settings settings; |
53 | |
|
54 | |
private ReactorManager reactorManager; |
55 | |
|
56 | |
private final String executionRootDir; |
57 | |
|
58 | 11 | private boolean usingPOMsFromFilesystem = true; |
59 | |
|
60 | |
private final Properties executionProperties; |
61 | |
|
62 | |
private Properties userProperties; |
63 | |
|
64 | |
private final Date startTime; |
65 | |
|
66 | |
private MavenProject currentProject; |
67 | |
|
68 | |
public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, |
69 | |
EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals, |
70 | |
String executionRootDir, Properties executionProperties, Date startTime ) |
71 | |
{ |
72 | 11 | this( container, settings, localRepository, eventDispatcher, reactorManager, goals, executionRootDir, executionProperties, null, startTime ); |
73 | 11 | } |
74 | |
|
75 | |
public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, |
76 | |
EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals, |
77 | |
String executionRootDir, Properties executionProperties, Properties userProperties, Date startTime ) |
78 | 11 | { |
79 | 11 | this.container = container; |
80 | |
|
81 | 11 | this.settings = settings; |
82 | |
|
83 | 11 | this.localRepository = localRepository; |
84 | |
|
85 | 11 | this.eventDispatcher = eventDispatcher; |
86 | |
|
87 | 11 | this.reactorManager = reactorManager; |
88 | |
|
89 | 11 | this.goals = goals; |
90 | |
|
91 | 11 | this.executionRootDir = executionRootDir; |
92 | |
|
93 | 11 | this.executionProperties = executionProperties; |
94 | |
|
95 | 11 | this.userProperties = userProperties; |
96 | |
|
97 | 11 | this.startTime = startTime; |
98 | 11 | } |
99 | |
|
100 | |
public Map getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project ) |
101 | |
{ |
102 | 0 | return reactorManager.getPluginContext( pluginDescriptor, project ); |
103 | |
} |
104 | |
|
105 | |
public PlexusContainer getContainer() |
106 | |
{ |
107 | 0 | return container; |
108 | |
} |
109 | |
|
110 | |
public ArtifactRepository getLocalRepository() |
111 | |
{ |
112 | 1 | return localRepository; |
113 | |
} |
114 | |
|
115 | |
public List getGoals() |
116 | |
{ |
117 | 0 | return goals; |
118 | |
} |
119 | |
|
120 | |
public Properties getExecutionProperties() |
121 | |
{ |
122 | 0 | return executionProperties; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public Object lookup( String role ) |
130 | |
throws ComponentLookupException |
131 | |
{ |
132 | 0 | return container.lookup( role ); |
133 | |
} |
134 | |
|
135 | |
public Object lookup( String role, String roleHint ) |
136 | |
throws ComponentLookupException |
137 | |
{ |
138 | 0 | return container.lookup( role, roleHint ); |
139 | |
} |
140 | |
|
141 | |
public List lookupList( String role ) |
142 | |
throws ComponentLookupException |
143 | |
{ |
144 | 0 | return container.lookupList( role ); |
145 | |
} |
146 | |
|
147 | |
public Map lookupMap( String role ) |
148 | |
throws ComponentLookupException |
149 | |
{ |
150 | 0 | return container.lookupMap( role ); |
151 | |
} |
152 | |
|
153 | |
public EventDispatcher getEventDispatcher() |
154 | |
{ |
155 | 0 | return eventDispatcher; |
156 | |
} |
157 | |
|
158 | |
public Settings getSettings() |
159 | |
{ |
160 | 0 | return settings; |
161 | |
} |
162 | |
|
163 | |
public List getSortedProjects() |
164 | |
{ |
165 | 0 | return reactorManager.getSortedProjects(); |
166 | |
} |
167 | |
|
168 | |
public String getExecutionRootDirectory() |
169 | |
{ |
170 | 0 | return executionRootDir; |
171 | |
} |
172 | |
|
173 | |
public void setUsingPOMsFromFilesystem( boolean usingPOMsFromFilesystem ) |
174 | |
{ |
175 | 0 | this.usingPOMsFromFilesystem = usingPOMsFromFilesystem; |
176 | 0 | } |
177 | |
|
178 | |
public boolean isUsingPOMsFromFilesystem() |
179 | |
{ |
180 | 0 | return usingPOMsFromFilesystem; |
181 | |
} |
182 | |
|
183 | |
public Date getStartTime() |
184 | |
{ |
185 | 0 | return startTime; |
186 | |
} |
187 | |
|
188 | |
public void setCurrentProject( MavenProject currentProject ) |
189 | |
{ |
190 | 0 | this.currentProject = currentProject; |
191 | 0 | } |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
public MavenProject getCurrentProject() |
197 | |
{ |
198 | 0 | return currentProject; |
199 | |
} |
200 | |
|
201 | |
|
202 | |
public Properties getUserProperties() |
203 | |
{ |
204 | 0 | return userProperties; |
205 | |
} |
206 | |
|
207 | |
public void setUserProperties( Properties userProperties ) |
208 | |
{ |
209 | 0 | this.userProperties = userProperties; |
210 | 0 | } |
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public ProjectBuilderConfiguration getProjectBuilderConfiguration() |
217 | |
{ |
218 | 0 | ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); |
219 | 0 | config.setLocalRepository( getLocalRepository() ) |
220 | |
.setExecutionProperties( getExecutionProperties() ) |
221 | |
.setUserProperties( getUserProperties() ) |
222 | |
.setBuildStartTime( getStartTime() ); |
223 | |
|
224 | 0 | return config; |
225 | |
} |
226 | |
} |