Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would not recommend to use <code>MAVEN CLI</code> because it works differently comparing to command line alternative. For example: </p> <p>With CLI, I want to reproduce <code>"mvn dependency:resolve validate"</code></p> <pre><code>cli.doMain( new String[]{ "dependency:resolve", // download deps if needed "validate"}, // just validates, no need even to compile projectPath ... </code></pre> <p>But actually it will go all over the folders (recursively) and will try to validate all projects there even if I don't want it. If if something wrong - <strong>it fails</strong>.</p> <p>If, though, you try to do the same just with command line - it will invoke only pom.xm and will <strong>finish successfully</strong> (even if some project inside 'projectPath' is not resolvable.</p> <p>With <code>CLI</code> I could NOT manage to use <strong>"-f "</strong> flag to specify particular <code>pom.xml</code>!</p> <p>This is quite good for me:</p> <pre><code>private int resolveAsCommandLine() { try { String command = "mvn " + "-f " + projectPath + "\\pom.xml " + "-Dmaven.repo.local=" + localRepoPath + "\\repository " + "-Dmaven.test.skip=true " + // ignore tests "dependency:resolve " + // download deps if needed "validate"; System.out.println("%&gt; Executing command: '" + command + "'..."); Process p = Runtime.getRuntime().exec( // "cmd - for windows only" "cmd /c " + command ); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream()) ); String line = ""; while ((line = in.readLine()) != null) { System.out.println(line); if(line.contains("[ERROR]")) return ERROR_STATUS; if(line.contains("BUILD FAILURE")) return ERROR_STATUS; if(line.contains("BUILD SUCCESS")) return OK_STATUS; } in.close(); } catch (IOException e) { e.printStackTrace(); return ERROR_STATUS; } return ERROR_STATUS; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload