diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml
deleted file mode 100644
index 207fc74d..00000000
--- a/.idea/libraries/KotlinJavaRuntime.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt__Compile_.xml b/.idea/libraries/kobalt__Compile_.xml
deleted file mode 100644
index 874c6a9b..00000000
--- a/.idea/libraries/kobalt__Compile_.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt__Test_.xml b/.idea/libraries/kobalt__Test_.xml
deleted file mode 100644
index a93b84bc..00000000
--- a/.idea/libraries/kobalt__Test_.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt_jar.xml b/.idea/libraries/kobalt_jar.xml
index 579a7e3b..d0481ed8 100644
--- a/.idea/libraries/kobalt_jar.xml
+++ b/.idea/libraries/kobalt_jar.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/libraries/kobalt_plugin_api__Compile_.xml b/.idea/libraries/kobalt_plugin_api__Compile_.xml
deleted file mode 100644
index f28f8426..00000000
--- a/.idea/libraries/kobalt_plugin_api__Compile_.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt_plugin_api__Test_.xml b/.idea/libraries/kobalt_plugin_api__Test_.xml
deleted file mode 100644
index 18b8b5ed..00000000
--- a/.idea/libraries/kobalt_plugin_api__Test_.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt_wrapper__Compile_.xml b/.idea/libraries/kobalt_wrapper__Compile_.xml
deleted file mode 100644
index 3c4baa9e..00000000
--- a/.idea/libraries/kobalt_wrapper__Compile_.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/kobalt_wrapper__Test_.xml b/.idea/libraries/kobalt_wrapper__Test_.xml
deleted file mode 100644
index 79d6011e..00000000
--- a/.idea/libraries/kobalt_wrapper__Test_.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4079311b..df7e8eb0 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
\ No newline at end of file
diff --git a/kobalt.iml b/kobalt.iml
index aa615c4b..384e6859 100644
--- a/kobalt.iml
+++ b/kobalt.iml
@@ -1,5 +1,5 @@
-
+
@@ -13,19 +13,10 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -34,7 +25,7 @@
-
+
@@ -43,16 +34,16 @@
-
+
-
-
+
+
-
+
@@ -61,7 +52,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -70,7 +70,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
@@ -88,16 +88,16 @@
-
+
-
+
-
+
@@ -106,7 +106,7 @@
-
+
@@ -115,7 +115,7 @@
-
+
@@ -124,25 +124,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -151,25 +151,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -178,16 +178,16 @@
-
+
-
+
-
+
@@ -196,7 +196,7 @@
-
+
@@ -205,34 +205,34 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -241,7 +241,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -250,16 +259,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -268,16 +268,16 @@
-
+
-
+
-
+
@@ -286,16 +286,16 @@
-
+
-
+
-
+
@@ -304,25 +304,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -331,7 +331,7 @@
-
+
@@ -340,16 +340,16 @@
-
+
-
+
-
+
@@ -358,7 +358,7 @@
-
+
@@ -367,16 +367,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/kobalt/Build.kt.iml b/kobalt/Build.kt.iml
index d3683da5..7bc9dd64 100644
--- a/kobalt/Build.kt.iml
+++ b/kobalt/Build.kt.iml
@@ -7,7 +7,6 @@
-
\ No newline at end of file
diff --git a/modules/kobalt-plugin-api/kobalt-plugin-api.iml b/modules/kobalt-plugin-api/kobalt-plugin-api.iml
index 54fa2296..7e463927 100644
--- a/modules/kobalt-plugin-api/kobalt-plugin-api.iml
+++ b/modules/kobalt-plugin-api/kobalt-plugin-api.iml
@@ -1,5 +1,5 @@
-
+
@@ -11,433 +11,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/wrapper/kobalt-wrapper.iml b/modules/wrapper/kobalt-wrapper.iml
index 1a90945d..edb06d17 100644
--- a/modules/wrapper/kobalt-wrapper.iml
+++ b/modules/wrapper/kobalt-wrapper.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/src/main/kotlin/com/beust/kobalt/app/IdeaFilesTemplate.kt b/src/main/kotlin/com/beust/kobalt/app/IdeaFilesTemplate.kt
deleted file mode 100644
index 884b1188..00000000
--- a/src/main/kotlin/com/beust/kobalt/app/IdeaFilesTemplate.kt
+++ /dev/null
@@ -1,230 +0,0 @@
-package com.beust.kobalt.app
-
-import com.beust.kobalt.Args
-import com.beust.kobalt.Constants
-import com.beust.kobalt.api.ITemplate
-import com.beust.kobalt.api.ITemplateContributor
-import com.beust.kobalt.api.Kobalt
-import com.beust.kobalt.app.remote.DependencyData
-import com.beust.kobalt.misc.KFiles
-import com.beust.kobalt.misc.log
-import com.beust.kobalt.plugin.KobaltPlugin
-import com.google.inject.Inject
-import java.io.File
-import java.io.FileOutputStream
-import java.nio.file.Paths
-
-/**
- * A template that generates IDEA files.
- */
-class IdeaFilesTemplate @Inject constructor() : ITemplate {
- override val templateName = "idea"
- override val templateDescription = "Generate files required by IDEA to build the project"
- override val pluginName = KobaltPlugin.PLUGIN_NAME
-
- override val instructions = "IDEA files generated"
-
- companion object {
- val IDEA_DIR = File(".idea").apply { mkdirs() }
- val KOTLIN_JAVA_RUNTIME = "KotlinJavaRuntime"
- }
-
- override fun generateTemplate(args: Args, classLoader: ClassLoader) {
- val dependencyData = Kobalt.INJECTOR.getInstance(DependencyData::class.java)
- val data = dependencyData.dependenciesDataFor(Constants.BUILD_FILE_PATH, args)
- val outputDir = File(".")// KFiles.makeDir(".")//KFiles.makeDir(homeDir("t/idea"))
- generateLibraries(classLoader, data, outputDir)
- generateModulesXml(data, outputDir)
- generateImlFiles(classLoader, data, outputDir)
- generateMiscXml(classLoader, outputDir)
- }
-
- private fun templatePath(fileName: String) =
- KFiles.joinDir(ITemplateContributor.DIRECTORY_NAME, templateName, fileName)
-
- private fun writeTemplate(classLoader: ClassLoader, outputDir: File, fileName: String) {
- val ins = classLoader.getResource(templatePath(fileName)).openConnection().inputStream
- val outputFile = File(KFiles.joinDir(outputDir.absolutePath, fileName))
- outputFile.parentFile.mkdir()
- FileOutputStream(outputFile).use { fos ->
- KFiles.copy(ins, fos)
- }
- log(2, "Created " + outputFile.path)
- }
-
- private fun generateMiscXml(classLoader: ClassLoader, outputDir: File)
- = writeTemplate(classLoader, Paths.get(outputDir.path, IDEA_DIR.path).normalize().toFile(), "misc.xml")
-
- private fun generateImlFiles(classLoader: ClassLoader, data: DependencyData.GetDependenciesData, outputDir: File) {
- //
- // Build.kt.iml
- //
- writeTemplate(classLoader, File(KFiles.joinDir(outputDir.absolutePath, "kobalt")), "Build.kt.iml")
-
- //
- // iml files for each individual project
- //
- data.projects.forEach { project ->
- val file = File(outputDir.absolutePath, imlName(project))
- file.parentFile.mkdirs()
- with(arrayListOf()) {
- add("""""")
- add("""""")
- add(""" """)
-
- add("""""")
-
- add(" ")
-
- //
- // Source directories
- //
- fun sourceDir(dir: String, isTest: Boolean)
- = " "
-
- project.sourceDirs.filter { File(it).exists() }.forEach { sourceDir ->
- add(sourceDir(sourceDir, false))
- }
- project.testDirs.filter { File(it).exists() }.forEach { sourceDir ->
- add(sourceDir(sourceDir, true))
- }
-
- add(""" """)
-
- //
- // Libraries
- //
- add(""" """)
-
- (project.name + COMPILE_SUFFIX).let {
- add(" ")
- }
- (project.name + TEST_SUFFIX).let {
- add(" ")
- }
- val isKotlin = true
- if (isKotlin) {
- add(" ")
- add(" ")
- }
-
- //
- // Dependent projects
- //
- project.dependentProjects.forEach { dp ->
- add(""" """)
- }
-
- add(" ")
- add("")
-
- writeFile(this, file)
-
- }
- }
- }
-
- private fun imlName(project: DependencyData.ProjectData) =
- Paths.get(KFiles.joinDir(project.directory, project.name + ".iml")).normalize().toString()
-
- private fun generateModulesXml(data: DependencyData.GetDependenciesData, outputDir: File) {
- val modulesXmlFile = File(KFiles.joinDir(IDEA_DIR.path, outputDir.path, "modules.xml"))
- with(arrayListOf()) {
- add("""""")
- add("""""")
- add(""" """)
- add(" ")
-
- fun moduleLine(iml: String)
- = " "
-
- add(moduleLine("kobalt/Build.kt.iml"))
- data.projects.forEach {
- add(moduleLine(imlName(it)))
- }
-
- add(" ")
- add(" ")
- add("")
- writeFile(this, modulesXmlFile)
- }
- }
-
- private val COMPILE_SUFFIX = " (Compile)"
- private val TEST_SUFFIX = " (Test)"
-
- private fun generateLibraries(classLoader: ClassLoader, data: DependencyData.GetDependenciesData, outputDir: File) {
- data.projects.forEach {
- generateLibrary(classLoader, it.name, it.compileDependencies, COMPILE_SUFFIX, outputDir)
- generateLibrary(classLoader, it.name, it.testDependencies, TEST_SUFFIX, outputDir)
- }
- val kobaltDd = DependencyData.DependencyData("kobalt", "compile",
- KFiles.joinDir(KFiles.distributionsDir, Kobalt.version, "kobalt", "wrapper",
- "kobalt-${Kobalt.version}.jar"))
- generateLibrary(classLoader, "kobalt.jar", listOf(kobaltDd), "", outputDir)
- }
-
- private fun generateLibrary(classLoader: ClassLoader, name: String,
- compileDependencies: List,
- suffix: String, outputDir: File) {
- val libraryName = name + suffix
- val librariesOutputDir = KFiles.joinAndMakeDir(IDEA_DIR.path, outputDir.path, "libraries")
- with(arrayListOf()) {
- add("""""")
- add(""" """)
- addAll(generateList(compileDependencies, "CLASSES"))
- addAll(generateList(emptyList(), "JAVADOC"))
- addAll(generateList(emptyList(), "SOURCES"))
- add(" ")
- add("")
- val fileName = libraryName.replace(" ", "_").replace("-", "_").replace("(", "_").replace(")", "_")
- .replace(".", "_")
- writeFile(this, File(librariesOutputDir, fileName + ".xml"))
- }
-
- if (compileDependencies.any { it.id.contains("kotlin") }) {
- generateKotlinJavaRuntime(classLoader, outputDir)
- }
- }
-
- private fun generateList(libraries: List, tag: String) : List {
- if (libraries.isEmpty()){
- return listOf(" <$tag />")
- } else {
- val result = arrayListOf()
- result.add(" <$tag>")
- libraries.forEach {
- val path =
- if (it.path.contains(".kobalt")) {
- val ind = it.path.indexOf(".kobalt")
- "\$USER_HOME$/" + it.path.substring(ind)
- } else {
- it.path
- }
- result.add(" ")
- }
-
- result.add(" $tag>")
-
- return result
- }
- }
-
- private fun generateKotlinJavaRuntime(classLoader: ClassLoader, outputDir: File) {
- writeTemplate(classLoader,
- File(KFiles.joinDir(outputDir.path, IDEA_DIR.path, "libraries")), "KotlinJavaRuntime.xml")
- with(File(outputDir.path, "lib")) {
- mkdirs()
- listOf("reflect", "runtime-sources", "runtime").forEach {
- writeTemplate(classLoader, File(outputDir, path), "kotlin-$it.jar")
- }
- }
- }
-
- private fun writeFile(lines: List, file: File) {
- file.writeText(lines.joinToString("\n"))
- log(2, "Created ${file.absolutePath}")
- }
-}
diff --git a/src/main/kotlin/com/beust/kobalt/app/Templates.kt b/src/main/kotlin/com/beust/kobalt/app/Templates.kt
index 20a1da1e..c034504d 100644
--- a/src/main/kotlin/com/beust/kobalt/app/Templates.kt
+++ b/src/main/kotlin/com/beust/kobalt/app/Templates.kt
@@ -10,7 +10,7 @@ import com.google.common.collect.ArrayListMultimap
import com.google.common.collect.ListMultimap
class Templates : ITemplateContributor {
- override val templates = listOf(JavaTemplateGenerator(), KotlinTemplateGenerator(), IdeaFilesTemplate())
+ override val templates = listOf(JavaTemplateGenerator(), KotlinTemplateGenerator())
fun getTemplates(pluginInfo: PluginInfo): ListMultimap {
val map = ArrayListMultimap.create()
diff --git a/src/main/resources/templates/idea/kobalt.xml b/src/main/resources/templates/idea/kobalt.xml
new file mode 100644
index 00000000..f8f33a67
--- /dev/null
+++ b/src/main/resources/templates/idea/kobalt.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file