1818 */
1919package org .apache .maven .buildcache ;
2020
21- import javax .inject .Inject ;
2221import javax .inject .Named ;
2322import javax .inject .Singleton ;
2423
2524import java .util .Map ;
2625import java .util .concurrent .ConcurrentHashMap ;
2726import java .util .concurrent .ConcurrentMap ;
2827
29- import org .apache .maven .buildcache .checksum .MavenProjectInput ;
30- import org .apache .maven .buildcache .xml .CacheConfig ;
3128import org .apache .maven .buildcache .xml .CacheState ;
3229import org .apache .maven .execution .MojoExecutionEvent ;
3330import org .apache .maven .execution .MojoExecutionListener ;
@@ -52,28 +49,18 @@ public class MojoParametersListener implements MojoExecutionListener {
5249 private final ConcurrentMap <MavenProject , Map <String , MojoExecutionEvent >> projectExecutions =
5350 new ConcurrentHashMap <>();
5451
55- private final CacheConfig cacheConfig ;
56-
57- @ Inject
58- public MojoParametersListener (CacheConfig cacheConfig ) {
59- this .cacheConfig = cacheConfig ;
60- }
52+ private CacheState cacheState = DISABLED ;
6153
6254 @ Override
6355 public void beforeMojoExecution (MojoExecutionEvent event ) {
6456 final String executionKey = CacheUtils .mojoExecutionKey (event .getExecution ());
6557 LOGGER .debug (
66- "Starting mojo execution: {}, class: {}" ,
58+ "Starting mojo execution: {}, class: {}, cacheState: {} " ,
6759 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 );
7662 if (cacheState == INITIALIZED ) {
63+ final MavenProject project = event .getProject ();
7764 Map <String , MojoExecutionEvent > projectEvents = projectExecutions .get (project );
7865 if (projectEvents == null ) {
7966 Map <String , MojoExecutionEvent > candidate = new ConcurrentHashMap <>();
@@ -99,4 +86,8 @@ public void afterExecutionFailure(MojoExecutionEvent event) {
9986 public Map <String , MojoExecutionEvent > getProjectExecutions (MavenProject project ) {
10087 return projectExecutions .get (project );
10188 }
89+
90+ public void setCacheState (CacheState cacheState ) {
91+ this .cacheState = cacheState ;
92+ }
10293}
0 commit comments