1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.Parameter;
27
28
29
30
31
32
33 public class Test implements Executable {
34
35
36
37
38 @Parameter(required = true)
39 private String name = null;
40
41
42
43
44
45
46 @Parameter(defaultValue = "shared")
47 private String link = null;
48
49
50
51
52 @Parameter(defaultValue = "true")
53 private boolean run = true;
54
55
56
57
58
59
60 @Parameter
61 private String type = Library.EXECUTABLE;
62
63
64
65
66
67 @Parameter
68 private List
69
70
71
72
73 @Parameter
74 private List<String> dependencyBindings = new ArrayList<>();
75
76
77 @Override
78 public final List
79 return this.args;
80 }
81
82 public String getBinding(NarArtifact dependency) {
83 for (String dependBind : dependencyBindings ) {
84 String[] pair = dependBind.trim().split( ":", 2 );
85 if( dependency.getArtifactId().equals(pair[0].trim()) ){
86 String result = pair[1].trim();
87 if( !result.isEmpty() )
88 return result;
89 }
90 }
91 return null;
92 }
93
94 public final String getLink( List<Library> libraries ) {
95 if( this.link != null )
96 return this.link;
97
98 String libraryPreferred = null;
99 if(libraries.size() == 1){
100 String type = libraries.get(0).getType();
101 if (Library.SHARED.equals(type)||Library.STATIC.equals(type) )
102 libraryPreferred = type;
103
104 }
105 return libraryPreferred == null ? Library.SHARED : libraryPreferred;
106 }
107
108 public final String getName() throws MojoFailureException {
109 if (this.name == null) {
110 throw new MojoFailureException("NAR: Please specify <Name> as part of <Test>");
111 }
112 return this.name;
113 }
114
115 public String getType() {
116 return this.type;
117 }
118
119 @Override
120 public final boolean shouldRun() {
121 return this.run;
122 }
123 }