int (final String projectPath) { String globalOptionsPath = null; if (configPath != null) { File optionsDir = new File(configPath, "options"); if (!optionsDir.isDirectory()) { System.err.println("'" + configPath + "' is not valid config path: " + optionsDir.getAbsolutePath() + " not found"); return 1; } globalOptionsPath = optionsDir.getAbsolutePath(); } ParameterizedRunnable<JpsModel> initializer = null; String scriptPath = initializationScriptPath; if (scriptPath != null) { File scriptFile = new File(scriptPath); if (!scriptFile.isFile()) { System.err.println("Script '" + scriptPath + "' not found"); return 1; } initializer = new GroovyModelInitializer(scriptFile); } if (modules.length == 0 && artifacts.length == 0 && !allModules && !allArtifacts) { System.err.println("Nothing to compile: at least one of --modules, --artifacts, --all-modules or --all-artifacts parameters must be specified"); return 1; } JpsModelLoaderImpl loader = new JpsModelLoaderImpl(projectPath, globalOptionsPath, false, initializer); Set<String> modulesSet = Set.of(modules); List<String> artifactsList = Arrays.asList(artifacts); File dataStorageRoot; if (cacheDirPath != null) { dataStorageRoot = new File(cacheDirPath); } else { dataStorageRoot = Utils.getDataStorageRoot(projectPath); } ConsoleMessageHandler consoleMessageHandler = new ConsoleMessageHandler(); long start = System.nanoTime(); try { runBuild(loader, dataStorageRoot, !incremental, modulesSet, allModules, artifactsList, allArtifacts, true, consoleMessageHandler); } catch (Throwable t) { System.err.println("Internal error: " + t.getMessage()); t.printStackTrace(); } System.out.println("Build finished in " + Utils.formatDuration(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start))); return consoleMessageHandler.hasErrors() ? 1 : 0; }