@@ -24,8 +24,8 @@ public class Config {
24
24
public static final String INCLUDED_FILES_FILE = INCLUDED_FILES + "File" ;
25
25
26
26
private static final List <String > requiredProperties = new ArrayList <>();
27
- private static final List <String > requiredPropertiesHelp = new ArrayList <>();
28
- private static final List <String > optionalPropertiesHelp = new ArrayList <>();
27
+ private static final Map <String , String > alternativeProperties = new HashMap <>();
28
+ private static final List <String > propertiesHelp = new ArrayList <>();
29
29
private static final Map <Integer , String > bytecodeVersionNames = new HashMap <>();
30
30
31
31
static {
@@ -51,13 +51,26 @@ public boolean isFullyConfigured() {
51
51
52
52
private boolean hasAllRequiredProperties () {
53
53
for (String requiredParameter : requiredProperties ) {
54
- if (p . getProperty (requiredParameter ) == null ) {
54
+ if (! isConfigured (requiredParameter )) {
55
55
return false ;
56
56
}
57
57
}
58
58
return true ;
59
59
}
60
60
61
+ private boolean isConfigured (String parameter ) {
62
+ if (p .getProperty (parameter ) != null ) {
63
+ return true ;
64
+ }
65
+ for (Map .Entry <String , String > alt : alternativeProperties .entrySet ()) {
66
+ if (alt .getValue ().equals (parameter ) &&
67
+ p .getProperty (alt .getKey ()) != null ) {
68
+ return true ;
69
+ }
70
+ }
71
+ return false ;
72
+ }
73
+
61
74
62
75
// bytecode version
63
76
@@ -133,7 +146,7 @@ public Path getOutputDir() {
133
146
requiredParameterHelp (CLASSPATH ,
134
147
"Classpath containing the original class files and their dependencies." ,
135
148
"Uses ; or : as the path separator, see java.io.File#pathSeparatorChar" );
136
- optionalParameterHelp (CLASSPATH_FILE ,
149
+ alternativeParameterHelp (CLASSPATH_FILE , CLASSPATH ,
137
150
"File listing the classpath entries." ,
138
151
"Alternative to " + CLASSPATH + " for avoiding the command line" ,
139
152
"length limit. The file must list one file per line with UTF-8 encoding." );
@@ -177,7 +190,7 @@ private static List<Path> readPathList(Path file) {
177
190
"List of files to process, instead of processing all files." ,
178
191
"This is useful for a build tool to support incremental compilation." ,
179
192
"Uses ; or : as the path separator, see java.io.File#pathSeparatorChar" );
180
- optionalParameterHelp (INCLUDED_FILES_FILE ,
193
+ alternativeParameterHelp (INCLUDED_FILES_FILE , INCLUDED_FILES ,
181
194
"File listing the files to process, instead of processing all files." ,
182
195
"Alternative to " + INCLUDED_FILES + " for avoiding the command line" ,
183
196
"length limit. The file must list one file per line with UTF-8 encoding." );
@@ -213,13 +226,9 @@ public String getHelp() {
213
226
"This software is released under the Apache License 2.0.\n " +
214
227
"The license text is at http://www.apache.org/licenses/LICENSE-2.0\n " +
215
228
"\n " +
216
- "Required system properties:\n " +
229
+ "Configurable system properties:\n " +
217
230
"\n " +
218
- requiredPropertiesHelp .stream ().reduce ((a , b ) -> a + "\n " + b ).get () +
219
- "\n " +
220
- "Optional system properties:\n " +
221
- "\n " +
222
- optionalPropertiesHelp .stream ().reduce ((a , b ) -> a + "\n " + b ).get () +
231
+ propertiesHelp .stream ().reduce ((a , b ) -> a + "\n " + b ).get () +
223
232
"\n " +
224
233
"If the Java agent is used, then Retrolambda will use it to capture the\n " +
225
234
"lambda classes generated by Java. Otherwise Retrolambda will hook into\n " +
@@ -229,18 +238,24 @@ public String getHelp() {
229
238
230
239
private static void requiredParameterHelp (String key , String ... lines ) {
231
240
requiredProperties .add (key );
232
- requiredPropertiesHelp .add (formatPropertyHelp (key , lines ));
241
+ propertiesHelp .add (formatPropertyHelp (key , "required" , lines ));
242
+ }
243
+
244
+ private static void alternativeParameterHelp (String key , String replaces , String ... lines ) {
245
+ alternativeProperties .put (key , replaces );
246
+ propertiesHelp .add (formatPropertyHelp (key , "alternative" , lines ));
233
247
}
234
248
235
249
private static void optionalParameterHelp (String key , String ... lines ) {
236
- optionalPropertiesHelp .add (formatPropertyHelp (key , lines ));
250
+ propertiesHelp .add (formatPropertyHelp (key , "" , lines ));
237
251
}
238
252
239
- private static String formatPropertyHelp (String key , String ... lines ) {
240
- String s = " " + key + "\n " ;
253
+ private static String formatPropertyHelp (String key , String tag , String ... lines ) {
254
+ tag = tag .isEmpty () ? "" : " (" + tag + ")" ;
255
+ String help = " " + key + tag + "\n " ;
241
256
for (String line : lines ) {
242
- s += " " + line + "\n " ;
257
+ help += " " + line + "\n " ;
243
258
}
244
- return s ;
259
+ return help ;
245
260
}
246
261
}
0 commit comments