From 868ef262b87d6c20639e550f734ce4b2667e44c8 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 15 Feb 2018 06:50:39 +0300 Subject: [PATCH] Pill: Add JPS run configurations --- .gitignore | 1 + buildSrc/src/main/kotlin/pill/plugin.kt | 34 +++++++++++++-- .../JPS_All_Compiler_Tests.xml | 8 ++++ .../JPS_All_IDEA_Plugin_Tests.xml | 37 +++++++++++++++++ .../runConfigurations/JPS_Compiler_Tests.xml | 35 ++++++++++++++++ .../pill/runConfigurations/JPS_IDEA.xml | 41 +++++++++++++++++++ .../JPS_JS_Backend_Tests.xml | 28 +++++++++++++ .../runConfigurations/JPS_Java_8_Tests.xml | 26 ++++++++++++ .../JPS_Refresh_JPS_Model.xml | 21 ++++++++++ 9 files changed, 227 insertions(+), 4 deletions(-) create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_Compiler_Tests.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_IDEA_Plugin_Tests.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Compiler_Tests.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_IDEA.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_JS_Backend_Tests.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Java_8_Tests.xml create mode 100644 buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Refresh_JPS_Model.xml diff --git a/.gitignore b/.gitignore index 67ed416a356..b853c5f3658 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ build/ .idea/libraries/Gradle*.xml .idea/libraries/Maven*.xml .idea/modules +.idea/runConfigurations/JPS_*.xml .idea/libraries .idea/modules.xml .idea/gradle.xml diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index b1c87dd30ae..1d547f24bf2 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -79,24 +79,37 @@ class JpsCompatibleRootPlugin : Plugin { } override fun apply(project: Project) { + if (project != project.rootProject) { + error("JpsCompatible root plugin can be applied only to the root project") + } + project.tasks.create("pill") { this.doLast { pill(project) } } } + private lateinit var projectDir: File private lateinit var platformVersion: String private lateinit var platformDir: File private fun pill(project: Project) { - platformVersion = project.rootProject.extensions.extraProperties.get("versions.intellijSdk").toString() - platformDir = File(project.projectDir, "buildSrc/prepare-deps/intellij-sdk/build/repo/kotlin.build.custom.deps/$platformVersion") + projectDir = project.projectDir + platformVersion = project.extensions.extraProperties.get("versions.intellijSdk").toString() + platformDir = File(projectDir, "buildSrc/prepare-deps/intellij-sdk/build/repo/kotlin.build.custom.deps/$platformVersion") val jpsProject = parse(project, ParserContext(dependencyMappers)) .mapLibraries(attachPlatformSources(platformVersion)) val files = render(jpsProject, getProjectLibraries(jpsProject)) - File(project.rootProject.projectDir, ".idea/libraries").deleteRecursively() + File(projectDir, ".idea/libraries").deleteRecursively() + + File(projectDir, ".idea/runConfigurations") + .walk() + .filter { it.name.startsWith("JPS_") && it.extension.toLowerCase() == "xml" } + .forEach { it.delete() } + + copyRunConfigurations() for (file in files) { val stubFile = file.path @@ -105,7 +118,20 @@ class JpsCompatibleRootPlugin : Plugin { } } - fun attachPlatformSources(platformVersion: String) = fun(library: PLibrary): PLibrary { + private fun copyRunConfigurations() { + val runConfigurationsDir = File(projectDir, "buildSrc/src/main/kotlin/pill/runConfigurations") + val targetDir = File(projectDir, ".idea/runConfigurations") + val platformDirProjectRelative = "\$PROJECT_DIR\$/" + platformDir.toRelativeString(projectDir) + + targetDir.mkdirs() + + runConfigurationsDir.listFiles() + .filter { it.extension == "xml" } + .map { it.name to it.readText().replace("\$IDEA_HOME_PATH\$", platformDirProjectRelative) } + .forEach { File(targetDir, it.first).writeText(it.second) } + } + + private fun attachPlatformSources(platformVersion: String) = fun(library: PLibrary): PLibrary { val platformSourcesJar = File(platformDir, "sources/ideaIC-$platformVersion-sources.jar") if (library.classes.any { it.startsWith(platformDir) }) { diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_Compiler_Tests.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_Compiler_Tests.xml new file mode 100644 index 00000000000..e6eb48f501b --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_Compiler_Tests.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_IDEA_Plugin_Tests.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_IDEA_Plugin_Tests.xml new file mode 100644 index 00000000000..abaa4a291c7 --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_All_IDEA_Plugin_Tests.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Compiler_Tests.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Compiler_Tests.xml new file mode 100644 index 00000000000..a68a4c148db --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Compiler_Tests.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_IDEA.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_IDEA.xml new file mode 100644 index 00000000000..a73f26ae3cb --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_IDEA.xml @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_JS_Backend_Tests.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_JS_Backend_Tests.xml new file mode 100644 index 00000000000..8c2654d5284 --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_JS_Backend_Tests.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Java_8_Tests.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Java_8_Tests.xml new file mode 100644 index 00000000000..111d1515996 --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Java_8_Tests.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Refresh_JPS_Model.xml b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Refresh_JPS_Model.xml new file mode 100644 index 00000000000..3fe30c2a636 --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/runConfigurations/JPS_Refresh_JPS_Model.xml @@ -0,0 +1,21 @@ + + + + + + + + + + \ No newline at end of file