Java Code Examples for org.apache.tools.ant.types.Commandline#translateCommandline()

The following examples show how to use org.apache.tools.ant.types.Commandline#translateCommandline() . 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: CLIParserTest.java    From bcrypt with Apache License 2.0 4 votes vote down vote up
public static String[] asArgArray(String cmd) {
    return Commandline.translateCommandline(cmd);
}
 
Example 2
Source File: VulasAgentMojo.java    From steady with Apache License 2.0 4 votes vote down vote up
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 3
Source File: CLIParserTest.java    From density-converter with Apache License 2.0 4 votes vote down vote up
public static String[] asArgArray(String cmd) {
    return Commandline.translateCommandline(cmd);
}
 
Example 4
Source File: CLIParserTest.java    From uber-apk-signer with Apache License 2.0 4 votes vote down vote up
public static String[] asArgArray(String cmd) {
    return Commandline.translateCommandline(cmd);
}
 
Example 5
Source File: CLIParserTest.java    From uber-adb-tools with Apache License 2.0 4 votes vote down vote up
public static String[] asArgArray(String cmd) {
    return Commandline.translateCommandline(cmd);
}