18
18
*/
19
19
package org .apache .maven .buildcache ;
20
20
21
- import javax .inject .Inject ;
22
21
import javax .inject .Named ;
23
22
import javax .inject .Singleton ;
24
23
25
24
import java .util .Map ;
26
25
import java .util .concurrent .ConcurrentHashMap ;
27
26
import java .util .concurrent .ConcurrentMap ;
28
27
29
- import org .apache .maven .buildcache .checksum .MavenProjectInput ;
30
- import org .apache .maven .buildcache .xml .CacheConfig ;
31
28
import org .apache .maven .buildcache .xml .CacheState ;
32
29
import org .apache .maven .execution .MojoExecutionEvent ;
33
30
import org .apache .maven .execution .MojoExecutionListener ;
@@ -52,28 +49,18 @@ public class MojoParametersListener implements MojoExecutionListener {
52
49
private final ConcurrentMap <MavenProject , Map <String , MojoExecutionEvent >> projectExecutions =
53
50
new ConcurrentHashMap <>();
54
51
55
- private final CacheConfig cacheConfig ;
56
-
57
- @ Inject
58
- public MojoParametersListener (CacheConfig cacheConfig ) {
59
- this .cacheConfig = cacheConfig ;
60
- }
52
+ private CacheState cacheState = DISABLED ;
61
53
62
54
@ Override
63
55
public void beforeMojoExecution (MojoExecutionEvent event ) {
64
56
final String executionKey = CacheUtils .mojoExecutionKey (event .getExecution ());
65
57
LOGGER .debug (
66
- "Starting mojo execution: {}, class: {}" ,
58
+ "Starting mojo execution: {}, class: {}, cacheState: {} " ,
67
59
executionKey ,
68
- event .getMojo ().getClass ());
69
- final MavenProject project = event .getProject ();
70
- CacheState cacheState = DISABLED ;
71
- boolean cacheIsDisabled = MavenProjectInput .isCacheDisabled (project );
72
- if (!cacheIsDisabled ) {
73
- cacheState = cacheConfig .initialize ();
74
- }
75
- LOGGER .debug ("cacheState: {}" , cacheState );
60
+ event .getMojo ().getClass (),
61
+ cacheState );
76
62
if (cacheState == INITIALIZED ) {
63
+ final MavenProject project = event .getProject ();
77
64
Map <String , MojoExecutionEvent > projectEvents = projectExecutions .get (project );
78
65
if (projectEvents == null ) {
79
66
Map <String , MojoExecutionEvent > candidate = new ConcurrentHashMap <>();
@@ -99,4 +86,8 @@ public void afterExecutionFailure(MojoExecutionEvent event) {
99
86
public Map <String , MojoExecutionEvent > getProjectExecutions (MavenProject project ) {
100
87
return projectExecutions .get (project );
101
88
}
89
+
90
+ public void setCacheState (CacheState cacheState ) {
91
+ this .cacheState = cacheState ;
92
+ }
102
93
}
0 commit comments