org.apache.tools.ant.types.CommandlineJava Java Examples
The following examples show how to use
org.apache.tools.ant.types.CommandlineJava.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VulasAgentMojo.java From steady with Apache License 2.0 | 4 votes |
public String prependVMArguments(final String arguments, final File agentJarFile) { CommandlineJava commandlineJava = new CommandlineJava() { @Override public void setVm(String vm) { //do not set "**/java" as the first command } }; //add the javaagent commandlineJava.createVmArgument().setLine(format("-javaagent:%s", agentJarFile)); //remove any javaagent with the same file name from the arguments final String[] args = Commandline.translateCommandline(arguments); // the new javaagent, as used by the prepare-vulas-agent goal final String regexForCurrentVulasAgent = format("-javaagent:(\"?)%s(\"?)", Pattern.quote(agentJarFile.toString())); // the default name of the legacy JAR final String regexForOldVulasAgent = format("-javaagent:(\"?).*%s(\"?)", Pattern.quote("/vulas/lib/vulas-core-latest-jar-with-dependencies.jar")); ArrayList<String> patterns = new ArrayList<>(); patterns.add(regexForCurrentVulasAgent); patterns.add(regexForOldVulasAgent); // go through the arguments to check for existing javaagents argprocess: for (String arg : args) { // check if one of vulas's agents is already defined as an arg // if yes ignore the arg for (String regExExp : patterns) { if (arg.matches(regExExp)) { continue argprocess; } } commandlineJava.createArgument().setLine(arg); } //add my properties for (final String key : this.agentOptions.keySet()) { final String value = this.agentOptions.get(key); if (value != null && !value.isEmpty()) { Environment.Variable variable = new Environment.Variable(); variable.setKey(key); variable.setValue(value); commandlineJava.addSysproperty(variable); } } //add -noverify commandlineJava.createVmArgument().setValue("-noverify"); return commandlineJava.toString(); }
Example #2
Source File: ValidatorTask.java From ironjacamar with Eclipse Public License 1.0 | 2 votes |
/** * Accessor to the command line. * * @return the current command line. */ public CommandlineJava getCommandLine() { return cmdl; }