1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.buildcache;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23
24 import org.apache.maven.AbstractMavenLifecycleParticipant;
25 import org.apache.maven.MavenExecutionException;
26 import org.apache.maven.SessionScoped;
27 import org.apache.maven.buildcache.xml.CacheConfig;
28 import org.apache.maven.execution.MavenSession;
29
30 @SessionScoped
31 @Named
32 @SuppressWarnings("unused")
33 public class CacheLifecycleParticipant extends AbstractMavenLifecycleParticipant {
34
35 private final CacheConfig cacheConfig;
36 private final CacheController cacheController;
37
38 @Inject
39 public CacheLifecycleParticipant(CacheConfig cacheConfig, CacheController cacheController) {
40 this.cacheConfig = cacheConfig;
41 this.cacheController = cacheController;
42 }
43
44 @Override
45 public void afterSessionEnd(MavenSession session) throws MavenExecutionException {
46 if (cacheConfig.isEnabled()) {
47 cacheController.saveCacheReport(session);
48 }
49 }
50 }