mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
api improvements
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
|
||||
+11
-14
@@ -14,16 +14,11 @@ class JavaAppLauncherTest extends JpsBuildTestCase {
|
||||
}
|
||||
|
||||
public void test_properties() {
|
||||
JavaAppLauncher launcher = new JavaAppLauncher() {
|
||||
@Override
|
||||
Map<String, String> 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);
|
||||
|
||||
@@ -17,12 +17,13 @@ public class RunConfiguration {
|
||||
final String workingDir;
|
||||
final Map<String, String> allOptions;
|
||||
final Map<String, String> envVars;
|
||||
final List<String> 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<RunConfigurationLauncherService> 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();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.jps.runConf.RunConfigurationLauncherService
|
||||
public abstract class JavaBasedRunConfigurationLauncher extends RunConfigurationLauncherService {
|
||||
private File myOutputFile;
|
||||
private File myErrorFile;
|
||||
private Map<String, String> 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<String, String> getSystemProperties(RunConfiguration runConf) { return Collections.emptyMap() };
|
||||
public Map<String, String> 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<String, String> props) {
|
||||
mySystemProperties.putAll(props);
|
||||
}
|
||||
|
||||
final void actualStart(RunConfiguration runConf) {
|
||||
def project = runConf.project;
|
||||
|
||||
def ant = project.binding.ant;
|
||||
|
||||
Reference in New Issue
Block a user