diff --git a/jps/antLayout/antlayout.iml b/jps/antLayout/antlayout.iml index 8ee35057cef7..1c77fe401738 100644 --- a/jps/antLayout/antlayout.iml +++ b/jps/antLayout/antlayout.iml @@ -1,6 +1,6 @@ - + diff --git a/jps/jps.iml b/jps/jps.iml index 9817a1cde2fb..924ebe0a5ffb 100644 --- a/jps/jps.iml +++ b/jps/jps.iml @@ -1,6 +1,6 @@ - + diff --git a/jps/plugins/appLauncher/testSrc/org/jetbrains/jps/runConf/java/JavaAppLauncherTest.groovy b/jps/plugins/appLauncher/testSrc/org/jetbrains/jps/runConf/java/JavaAppLauncherTest.groovy index e73a5b6bc21e..55ae1464cd25 100644 --- a/jps/plugins/appLauncher/testSrc/org/jetbrains/jps/runConf/java/JavaAppLauncherTest.groovy +++ b/jps/plugins/appLauncher/testSrc/org/jetbrains/jps/runConf/java/JavaAppLauncherTest.groovy @@ -14,16 +14,11 @@ class JavaAppLauncherTest extends JpsBuildTestCase { } public void test_properties() { - JavaAppLauncher launcher = new JavaAppLauncher() { - @Override - Map getSystemProperties(RunConfiguration runConf) { - return ["my.prop1" : "val1", "my.prop2" : "val2"]; - } - } - - runAndAssertOutput("MainClassProperties", launcher, { output -> - assertTrue(output, output.indexOf("val1" + System.getProperty("line.separator")) != -1) - assertTrue(output, output.indexOf("val2") != -1) + runAndAssertOutput("MainClassProperties", {JavaBasedRunConfigurationLauncher launcher -> + launcher.addSystemProperties(["my.prop1" : "val1", "my.prop2" : "val2"]) + }, { output -> + assertTrue(output, output.indexOf("val1" + System.getProperty("line.separator")) != -1) + assertTrue(output, output.indexOf("val2") != -1) }) } @@ -50,7 +45,7 @@ class JavaAppLauncherTest extends JpsBuildTestCase { }) } - private void runAndAssertOutput(String runConfName, JavaBasedRunConfigurationLauncher launcher, Closure assertions) { + private void runAndAssertOutput(String runConfName, Closure launcherInitializer, Closure assertions) { Project project = loadProject("plugins/appLauncher/testData/main-class-run-conf", [:]); RunConfiguration runConf = project.runConfigurations[runConfName]; @@ -61,11 +56,13 @@ class JavaAppLauncherTest extends JpsBuildTestCase { File outFile = createTempFile(); - if (launcher == null) { - launcher = new JavaAppLauncher(); - } + JavaAppLauncher launcher = new JavaAppLauncher(); launcher.setOutputFile(outFile); + if (launcherInitializer != null) { + launcherInitializer(launcher); + } + launcher.start(runConf); String output = FileUtil.loadFileText(outFile); diff --git a/jps/src/org/jetbrains/jps/RunConfiguration.groovy b/jps/src/org/jetbrains/jps/RunConfiguration.groovy index 36f268445336..17ea8363aec4 100644 --- a/jps/src/org/jetbrains/jps/RunConfiguration.groovy +++ b/jps/src/org/jetbrains/jps/RunConfiguration.groovy @@ -17,12 +17,13 @@ public class RunConfiguration { final String workingDir; final Map allOptions; final Map envVars; - final List classPatterns; + final Node node def RunConfiguration(Project project, MacroExpander macroExpander, Node confTag) { this.project = project; this.name = confTag.'@name'; this.type = confTag.'@type'; + this.node = confTag; this.allOptions = [:]; confTag.option.each{ opt -> @@ -56,35 +57,17 @@ public class RunConfiguration { confTag.envs.env.each{ el -> this.envVars[el.'@name'] = el.'@value'; } - - this.classPatterns = []; - confTag.patterns?.pattern.each{ el -> - this.classPatterns.add(el.'@testClass'); - } } private static OwnServiceLoader runConfLauncherServices = OwnServiceLoader.load(RunConfigurationLauncherService.class) - def start() { + def RunConfigurationLauncherService getLauncher() { for (RunConfigurationLauncherService service: runConfLauncherServices.iterator()) { if (service.typeId == type) { - service.startRunConfiguration(this); - return; + return service; } } - throw new RuntimeException("Run configuration \"$name\" of type \"$type\" is not supported."); + return null; } - - // for Java based run configurations returns runtime classpath, required to launch this configuration in JVM -/* - void makeDependencies() { - if (this.module != null) { - this.module.make(); - this.module.makeTests(); - } else { - this.project.makeAll(); - } - } -*/ } \ No newline at end of file diff --git a/jps/src/org/jetbrains/jps/runConf/RunConfigurationLauncherService.groovy b/jps/src/org/jetbrains/jps/runConf/RunConfigurationLauncherService.groovy index 049ed8f2168d..06c7912c0834 100644 --- a/jps/src/org/jetbrains/jps/runConf/RunConfigurationLauncherService.groovy +++ b/jps/src/org/jetbrains/jps/runConf/RunConfigurationLauncherService.groovy @@ -13,14 +13,14 @@ public abstract class RunConfigurationLauncherService { public void afterFinish(RunConfiguration runConf) {}; - public final void startRunConfiguration(RunConfiguration runConf) { + public final void start(RunConfiguration runConf) { beforeStart(runConf); try { - start(runConf); + actualStart(runConf); } finally { afterFinish(runConf); }; }; - public abstract void start(RunConfiguration runConf); + protected abstract void actualStart(RunConfiguration runConf); } diff --git a/jps/src/org/jetbrains/jps/runConf/java/JavaBasedRunConfigurationLauncher.groovy b/jps/src/org/jetbrains/jps/runConf/java/JavaBasedRunConfigurationLauncher.groovy index 8dcf189eeb94..aad3f3a3c479 100644 --- a/jps/src/org/jetbrains/jps/runConf/java/JavaBasedRunConfigurationLauncher.groovy +++ b/jps/src/org/jetbrains/jps/runConf/java/JavaBasedRunConfigurationLauncher.groovy @@ -11,6 +11,7 @@ import org.jetbrains.jps.runConf.RunConfigurationLauncherService public abstract class JavaBasedRunConfigurationLauncher extends RunConfigurationLauncherService { private File myOutputFile; private File myErrorFile; + private Map mySystemProperties = [:]; JavaBasedRunConfigurationLauncher(String typeId) { super(typeId) @@ -36,7 +37,7 @@ public abstract class JavaBasedRunConfigurationLauncher extends RunConfiguration /** * @return system properties (can be specified in JVM arguments too, but this call is more convenient) */ - public Map getSystemProperties(RunConfiguration runConf) { return Collections.emptyMap() }; + public Map getSystemProperties(RunConfiguration runConf) { return mySystemProperties; }; /** * @return classpath required to launch specified main class @@ -57,7 +58,11 @@ public abstract class JavaBasedRunConfigurationLauncher extends RunConfiguration myErrorFile = errFile; } - public final void start(RunConfiguration runConf) { + public void addSystemProperties(Map props) { + mySystemProperties.putAll(props); + } + + final void actualStart(RunConfiguration runConf) { def project = runConf.project; def ant = project.binding.ant;