1 package org.apache.maven.plugins.rar.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import javax.inject.Named;
23 import javax.inject.Provider;
24 import javax.inject.Singleton;
25
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31 import org.apache.maven.lifecycle.mapping.Lifecycle;
32 import org.apache.maven.lifecycle.mapping.LifecycleMapping;
33 import org.apache.maven.lifecycle.mapping.LifecyclePhase;
34
35
36
37
38 @Singleton
39 @Named( "rar" )
40 public final class RarLifecycleMappingProvider
41 implements Provider<LifecycleMapping>
42 {
43
44
45
46
47 @SuppressWarnings( "checkstyle:linelength" )
48 private static final String[] BINDINGS =
49 {
50 "process-resources", "org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources",
51 "compile", "org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile",
52 "process-test-resources", "org.apache.maven.plugins:maven-resources-plugin:3.2.0:testResources",
53 "test-compile", "org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile",
54 "test", "org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test",
55 "package", "org.apache.maven.plugins:maven-rar-plugin:rar",
56 "install", "org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install",
57 "deploy", "org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy"
58 };
59
60 private final Lifecycle defaultLifecycle;
61 private final LifecycleMapping lifecycleMapping;
62
63 public RarLifecycleMappingProvider()
64 {
65 HashMap<String, LifecyclePhase> bindings = new HashMap<>();
66 for ( int i = 0; i < BINDINGS.length; i = i + 2 )
67 {
68 bindings.put( BINDINGS[i], new LifecyclePhase( BINDINGS[i + 1] ) );
69 }
70 this.defaultLifecycle = new Lifecycle();
71 this.defaultLifecycle.setId( "default" );
72 this.defaultLifecycle.setLifecyclePhases( bindings );
73
74
75 this.lifecycleMapping = new LifecycleMapping()
76 {
77 @Override
78 public Map<String, Lifecycle> getLifecycles()
79 {
80 return Collections.singletonMap( "default", defaultLifecycle );
81 }
82
83 @Override
84 public List<String> getOptionalMojos( String lifecycle )
85 {
86 return null;
87 }
88
89 @Override
90 public Map<String, String> getPhases( String lifecycle )
91 {
92 if ( "default".equals( lifecycle ) )
93 {
94 return defaultLifecycle.getPhases();
95 }
96 else
97 {
98 return null;
99 }
100 }
101 };
102 }
103
104 @Override
105 public LifecycleMapping get()
106 {
107 return lifecycleMapping;
108 }
109 }