use of org.apache.tools.ant.RuntimeConfigurable in project groovy by apache.
the class Groovyc method extractJointOptions.
private List<String> extractJointOptions(Path classpath) {
List<String> jointOptions = new ArrayList<String>();
if (!jointCompilation)
return jointOptions;
// extract joint options, some get pushed up...
RuntimeConfigurable rc = javac.getRuntimeConfigurableWrapper();
for (Object o1 : rc.getAttributeMap().entrySet()) {
final Map.Entry e = (Map.Entry) o1;
final String key = e.getKey().toString();
final String value = getProject().replaceProperties(e.getValue().toString());
if (key.contains("debug")) {
String level = "";
if (javac.getDebugLevel() != null) {
level = ":" + javac.getDebugLevel();
}
jointOptions.add("-Fg" + level);
} else if (key.contains("debugLevel")) {
// ignore, taken care of in debug
} else if ((key.contains("nowarn")) || (key.contains("verbose")) || (key.contains("deprecation"))) {
// false is default, so something to do only in true case
if ("on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value))
jointOptions.add("-F" + key);
} else if (key.contains("classpath")) {
classpath.add(javac.getClasspath());
} else if ((key.contains("depend")) || (key.contains("extdirs")) || (key.contains("encoding")) || (key.contains("source")) || (key.contains("target")) || (key.contains("verbose"))) {
// already handling verbose but pass on too
jointOptions.add("-J" + key + "=" + value);
} else {
log.warn("The option " + key + " cannot be set on the contained <javac> element. The option will be ignored");
}
// TODO includes? excludes?
}
// ant's <javac> supports nested <compilerarg value=""> elements (there can be multiple of them)
// for additional options to be passed to javac.
Enumeration children = rc.getChildren();
while (children.hasMoreElements()) {
RuntimeConfigurable childrc = (RuntimeConfigurable) children.nextElement();
if (childrc.getElementTag().equals("compilerarg")) {
for (Object o : childrc.getAttributeMap().entrySet()) {
final Map.Entry e = (Map.Entry) o;
final String key = e.getKey().toString();
if (key.equals("value")) {
final String value = getProject().replaceProperties(e.getValue().toString());
StringTokenizer st = new StringTokenizer(value, " ");
while (st.hasMoreTokens()) {
String optionStr = st.nextToken();
String replaced = optionStr.replace("-X", "-FX");
if (optionStr.equals(replaced)) {
// GROOVY-5063
replaced = optionStr.replace("-W", "-FW");
}
jointOptions.add(replaced);
}
}
}
}
}
return jointOptions;
}
use of org.apache.tools.ant.RuntimeConfigurable in project groovy-core by groovy.
the class Groovyc method extractJointOptions.
private List<String> extractJointOptions(Path classpath) {
List<String> jointOptions = new ArrayList<String>();
if (!jointCompilation)
return jointOptions;
// extract joint options, some get pushed up...
RuntimeConfigurable rc = javac.getRuntimeConfigurableWrapper();
for (Object o1 : rc.getAttributeMap().entrySet()) {
final Map.Entry e = (Map.Entry) o1;
final String key = e.getKey().toString();
final String value = getProject().replaceProperties(e.getValue().toString());
if (key.contains("debug")) {
String level = "";
if (javac.getDebugLevel() != null) {
level = ":" + javac.getDebugLevel();
}
jointOptions.add("-Fg" + level);
} else if (key.contains("debugLevel")) {
// ignore, taken care of in debug
} else if ((key.contains("nowarn")) || (key.contains("verbose")) || (key.contains("deprecation"))) {
// false is default, so something to do only in true case
if ("on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value))
jointOptions.add("-F" + key);
} else if (key.contains("classpath")) {
classpath.add(javac.getClasspath());
} else if ((key.contains("depend")) || (key.contains("extdirs")) || (key.contains("encoding")) || (key.contains("source")) || (key.contains("target")) || (key.contains("verbose"))) {
// already handling verbose but pass on too
jointOptions.add("-J" + key + "=" + value);
} else {
log.warn("The option " + key + " cannot be set on the contained <javac> element. The option will be ignored");
}
// TODO includes? excludes?
}
// ant's <javac> supports nested <compilerarg value=""> elements (there can be multiple of them)
// for additional options to be passed to javac.
Enumeration children = rc.getChildren();
while (children.hasMoreElements()) {
RuntimeConfigurable childrc = (RuntimeConfigurable) children.nextElement();
if (childrc.getElementTag().equals("compilerarg")) {
for (Object o : childrc.getAttributeMap().entrySet()) {
final Map.Entry e = (Map.Entry) o;
final String key = e.getKey().toString();
if (key.equals("value")) {
final String value = getProject().replaceProperties(e.getValue().toString());
StringTokenizer st = new StringTokenizer(value, " ");
while (st.hasMoreTokens()) {
String optionStr = st.nextToken();
String replaced = optionStr.replace("-X", "-FX");
if (optionStr.equals(replaced)) {
// GROOVY-5063
replaced = optionStr.replace("-W", "-FW");
}
jointOptions.add(replaced);
}
}
}
}
}
return jointOptions;
}
Aggregations