File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
enforcer-api/src/custom-rule-sample
src/main/java/org/example/custom/rule Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 34
34
<properties >
35
35
<api .version>${project.version} </api .version>
36
36
<mavenVersion >${mavenVersion}</mavenVersion >
37
- <!-- use JDK 1.8 or 11 -- >
38
- <maven .compiler.source>1. 8</maven .compiler.source >
39
- <maven .compiler.target>1. 8</maven .compiler.target >
37
+ <maven .compiler.source>8</ maven .compiler.source >
38
+ <maven .compiler.target> 8</maven .compiler.target >
39
+ <maven .compiler.release> 8</maven .compiler.release >
40
40
</properties >
41
41
42
42
<dependencies >
66
66
<!-- generate index of project components -->
67
67
<groupId >org.eclipse.sisu</groupId >
68
68
<artifactId >sisu-maven-plugin</artifactId >
69
- <version >0.9.0.M1 </version >
69
+ <version >${version.sisu-maven-plugin} </version >
70
70
<executions >
71
71
<execution >
72
72
<goals >
Original file line number Diff line number Diff line change 24
24
import javax .inject .Named ;
25
25
26
26
import java .util .List ;
27
+ import java .util .Objects ;
27
28
28
29
import org .apache .maven .enforcer .rule .api .AbstractEnforcerRule ;
29
30
import org .apache .maven .enforcer .rule .api .EnforcerRuleException ;
@@ -49,14 +50,18 @@ public class MyCustomRule extends AbstractEnforcerRule {
49
50
50
51
// Inject needed Maven components
51
52
52
- @ Inject
53
- private MavenProject project ;
53
+ private final MavenProject project ;
54
54
55
- @ Inject
56
- private MavenSession session ;
55
+ private final MavenSession session ;
56
+
57
+ private final RuntimeInformation runtimeInformation ;
57
58
58
59
@ Inject
59
- private RuntimeInformation runtimeInformation ;
60
+ public MyCustomRule (MavenProject project , MavenSession session , RuntimeInformation runtimeInformation ) {
61
+ this .project = Objects .requireNonNull (project );
62
+ this .session = Objects .requireNonNull (session );
63
+ this .runtimeInformation = Objects .requireNonNull (runtimeInformation );
64
+ }
60
65
61
66
public void execute () throws EnforcerRuleException {
62
67
You can’t perform that action at this time.
0 commit comments