Skip to content

Commit

Permalink
Interpreting Maven commands in the platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Feb 8, 2017
1 parent 176d6fa commit 72589e6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
Expand Up @@ -40,29 +40,33 @@ public static void findAndBuildAndDeploy(String location) {

if (!locations.isEmpty()) {
for (String basedir : locations) {
buildAndDeploy(basedir, "/data/.m2/repository", U.list("-e", "-X", "clean", "org.rapidoid:build:jar"), true);
build(basedir, "/data/.m2/repository", U.list("-e", "-X", "-DskipTests=true", "clean", "org.rapidoid:build:jar"));
}
} else {
Log.warn("Didn't find any pom.xml file!", "location", location);
}
}

public static void buildAndDeploy(String basedir, String mavenRepo, List<String> mvnArgs, boolean skipTests) {
public static int build(String basedir, String mavenRepo, List<String> mvnArgs) {
Log.info("Building Maven project", "location", basedir);

System.setProperty("maven.repo.local", mavenRepo);
System.setProperty("request.baseDirectory", basedir);
System.setProperty("maven.multiModuleProjectDirectory", basedir);
System.setProperty("skipTests", skipTests + "");

// make sure the Maven repository folder exists
new File(mavenRepo).mkdirs();

MavenCli cli = new MavenCli();
String[] args = U.arrayOf(String.class, mvnArgs);

int result = cli.doMain(args, basedir, System.out, System.err);

U.must(result == 0, "The Maven build failed!");
if (result != 0) {
Log.error("The Maven build failed!", "status", result);
}

return result;
}

}
Expand Up @@ -24,6 +24,7 @@
import org.rapidoid.RapidoidThing;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.commons.Arr;
import org.rapidoid.deploy.AppDeployer;
import org.rapidoid.io.IO;
import org.rapidoid.log.Log;
Expand All @@ -45,14 +46,13 @@ public class Platform extends RapidoidThing {
private static AppChangeWatcher appChangeWatcher = new AppChangeWatcher();

static void start(String[] args, @SuppressWarnings("unused") boolean defaults) {
// Rapidoid banner
U.print(IO.load("rapidoid.txt"));

Log.options().prefix("[PLATFORM] ");
Log.options().inferCaller(false);
Log.options().showThread(false);
initializePlatform();

Msc.setPlatform(true);
interceptSpecialCommands(args);

// Rapidoid banner
U.print(IO.load("rapidoid.txt"));

startPlatformAndProcessArgs(args);

Expand All @@ -69,6 +69,23 @@ static void start(String[] args, @SuppressWarnings("unused") boolean defaults) {
openInBrowser();
}

private static void interceptSpecialCommands(String[] args) {
// interpret Maven command
if (U.notEmpty(args) && args[0].equals("mvn")) {
List<String> mvnArgs = U.list(Arr.sub(args, 1, args.length));
int result = MavenUtil.build("/app", "/data/.m2/repository", mvnArgs);
System.exit(result);
}
}

private static void initializePlatform() {
Msc.setPlatform(true);

Log.options().prefix("[PLATFORM] ");
Log.options().inferCaller(false);
Log.options().showThread(false);
}

private static void startPlatformAndProcessArgs(String[] args) {
List<String> normalArgs = U.list();
List<String> appRefs = U.list();
Expand Down

0 comments on commit 72589e6

Please sign in to comment.