Skip to content

Commit

Permalink
shell - trying to fallback to ivy dependency resolution from pom.xml …
Browse files Browse the repository at this point in the history
…if we detect mvn is not installed on current machine
  • Loading branch information
fcamblor committed Sep 9, 2017
1 parent 85539e4 commit 6b1334d
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
@Component
public class DepsShellCommand extends StdShellCommand {
private static final String MVN_COMMAND = "mvn";

public DepsShellCommand() {
super(ImmutableList.of("deps"), "deps related commands: install / update / manage app dependencies");
}
Expand Down Expand Up @@ -154,16 +156,25 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx

// Then copying dependencies through copy-dependencies plugin
ProcessBuilder mavenCmd = new ProcessBuilder(
"mvn", "org.apache.maven.plugins:maven-dependency-plugin:3.0.1:copy-dependencies",
MVN_COMMAND, "org.apache.maven.plugins:maven-dependency-plugin:3.0.1:copy-dependencies",
"-DoutputDirectory=" + dependenciesDir.toAbsolutePath(), "-DincludeScope=runtime"
);

shell.println("Executing `"+mavenCmd+"` ...");
mavenCmd.redirectErrorStream(true)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.directory(shell.currentLocation().toFile().getAbsoluteFile())
.start()
.waitFor();
try {
mavenCmd.redirectErrorStream(true)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.directory(shell.currentLocation().toFile().getAbsoluteFile())
.start()
.waitFor();
} catch(IOException e) {
if(e.getMessage().startsWith(String.format("Cannot run program \"%s\"", MVN_COMMAND))) {
shell.println("Looks like mvn is not installed here ... trying to fallback installing pom.xml file with Ivy...");
installDepsFromIvyDescriptor(shell, pomFile);
} else {
Throwables.propagate(e);
}
}
}

private static void storeModuleDescriptorMD5File(RestxShell shell, ModuleDescriptorType mdType) throws IOException {
Expand Down

0 comments on commit 6b1334d

Please sign in to comment.