Permalink
Browse files

Generate default run configuration to run server with current applica…

…tion
  • Loading branch information...
1 parent 1da2de3 commit 4b55db3271b98f60402083d12072c41e1e54aeda @shafirov shafirov committed Jan 25, 2013
Showing with 71 additions and 4 deletions.
  1. +71 −4 src/KaraExec/src/generators/templates/IDEATemplates.kt
View
75 src/KaraExec/src/generators/templates/IDEATemplates.kt
@@ -5,13 +5,21 @@ import java.util.UUID
fun Generator.createIDEAFiles() {
ensureDir(".idea")
- ensureDir(".idea/libraries")
renderTemplate(nameTemplate(), ".idea/.name")
renderTemplate(modulesTemplate(), ".idea/modules.xml")
renderTemplate(misc(), ".idea/misc.xml")
- renderTemplate(libraryKaraTemplate(), ".idea/libraries/KaraLib.xml")
+
+ ensureDir(".idea/libraries")
+ renderTemplate(libraryKaraLib(), ".idea/libraries/KaraLib.xml")
renderTemplate(libraryKotlinRuntime(), ".idea/libraries/KotlinRuntime.xml")
+ renderTemplate(libraryKaraExec(), ".idea/libraries/KaraExec.xml")
renderTemplate(moduleImlTemplate(), "${appConfig.appPackage}.iml")
+
+ ensureDir("Launcher")
+ renderTemplate(launcherModuleTemplate(), "Launcher/Launcher.iml")
+
+ ensureDir(".idea/runConfigurations")
+ renderTemplate(launcherConfiguration(), ".idea/runConfigurations/Server.xml")
}
fun Generator.modulesTemplate(): String {
@@ -21,6 +29,7 @@ fun Generator.modulesTemplate(): String {
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/${appPackage}.iml" filepath="$PROJECT_DIR$/${appPackage}.iml" />
+ <module fileurl="file://$PROJECT_DIR$/Launcher/Launcher.iml" filepath="$PROJECT_DIR$/Launcher/Launcher.iml" />
</modules>
</component>
</project>
@@ -31,7 +40,7 @@ fun Generator.nameTemplate(): String {
return """${projectName}"""
}
-fun Generator.libraryKaraTemplate(): String {
+fun Generator.libraryKaraLib(): String {
val KARA_HOME = "\$KARA_HOME"
return """<component name="libraryTable">
<library name="KaraLib">
@@ -56,8 +65,26 @@ fun Generator.libraryKotlinRuntime() : String {
</CLASSES>
<JAVADOC />
<SOURCES>
- <root url="jar://$KARA_HOME/lib/kotlin-runtime.jar!/src" />
+ <root url="jar://$KARA_HOME$/lib/kotlin-runtime.jar!/src" />
+ </SOURCES>
+ </library>
+</component>
+"""
+}
+
+fun Generator.libraryKaraExec() : String {
+ val KARA_HOME = "\$KARA_HOME"
+ return """<component name="libraryTable">
+ <library name="KaraExec">
+ <CLASSES>
+ <root url="file://$KARA_HOME$/lib" />
+ <root url="jar://$KARA_HOME$/modules/KaraExec.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$KARA_HOME$/modules/KaraExec-sources.zip!/" />
</SOURCES>
+ <jarDirectory url="file://$KARA_HOME$/lib" recursive="false" />
</library>
</component>
"""
@@ -90,3 +117,43 @@ fun Generator.moduleImlTemplate() : String {
</module>
"""
}
+
+fun Generator.launcherModuleTemplate() : String {
+ val MODULE_DIR = "\$MODULE_DIR"
+ return """<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="KotlinRuntime" level="project" />
+ <orderEntry type="library" name="KaraExec" level="project" />
+ <orderEntry type="library" name="KaraLib" level="project" />
+ <orderEntry type="module" module-name="${appPackage}" scope="PROVIDED" />
+ </component>
+</module>
+"""
+}
+
+fun Generator.launcherConfiguration() : String {
+ val PROJECT_DIR="\$PROJECT_DIR"
+ return """<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="Server" type="Application" factoryName="Application">
+ <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+ <option name="MAIN_CLASS_NAME" value="kara.KaraPackage" />
+ <option name="VM_PARAMETERS" value="" />
+ <option name="PROGRAM_PARAMETERS" value="s" />
+ <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+ <option name="ALTERNATIVE_JRE_PATH" value="" />
+ <option name="ENABLE_SWING_INSPECTOR" value="false" />
+ <option name="ENV_VARIABLES" />
+ <option name="PASS_PARENT_ENVS" value="true" />
+ <module name="Launcher" />
+ <envs />
+ <method />
+ </configuration>
+</component>
+"""
+}

0 comments on commit 4b55db3

Please sign in to comment.