Exemple #1
0
 /**
  * Puts quotes around a string if it contains any spaces.
  *
  * @param arg
  * @return
  */
 public static String quoteArg(String arg) {
   if (Strings.isValid(arg) && arg.contains(" ")) {
     StringBuilder builder = new StringBuilder().append('"').append(arg).append('"');
     return builder.toString();
   }
   return arg;
 }
Exemple #2
0
 /**
  * Obtains the java executable from the Maven Toolchain.
  *
  * @param session
  * @param toolchainManager
  * @param type The type of tool chain to look for in maven.
  * @param name The name of the executable file that would be called in in the path.
  * @return
  * @throws MojoExecutionException
  */
 public static String getExecutable(
     MavenSession session, ToolchainManager toolchainManager, String type, String name)
     throws MojoExecutionException {
   Toolchain toolchain = toolchainManager.getToolchainFromBuildContext(type, session);
   if (toolchain != null) {
     String tool = toolchain.findTool(name);
     if (Strings.isValid(tool)) {
       return tool;
     } else {
       throw new MojoExecutionException(
           "Unable to find 'java' executable for toolchain: " + toolchain);
     }
   }
   return name;
 }