Pill: Add 'unpill' task
This commit is contained in:
@@ -96,7 +96,11 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
project.tasks.create("pill") {
|
||||
this.doLast { pill(project) }
|
||||
doLast { pill(project) }
|
||||
}
|
||||
|
||||
project.tasks.create("unpill") {
|
||||
doLast { unpill(project) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,24 +109,24 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
private lateinit var platformBaseNumber: String
|
||||
private lateinit var platformDir: File
|
||||
|
||||
private fun pill(project: Project) {
|
||||
private fun initEnvironment(project: Project) {
|
||||
projectDir = project.projectDir
|
||||
platformVersion = project.extensions.extraProperties.get("versions.intellijSdk").toString()
|
||||
platformBaseNumber = platformVersion.substringBefore(".", "").takeIf { it.isNotEmpty() }
|
||||
?: error("Invalid platform version: $platformVersion")
|
||||
platformDir = File(projectDir, "buildSrc/prepare-deps/intellij-sdk/build/repo/kotlin.build.custom.deps/$platformVersion")
|
||||
}
|
||||
|
||||
private fun pill(project: Project) {
|
||||
initEnvironment(project)
|
||||
|
||||
val jpsProject = parse(project, ParserContext(dependencyMappers))
|
||||
.mapLibraries(this::attachPlatformSources, this::attachAsmSources)
|
||||
|
||||
val files = render(jpsProject, getProjectLibraries(jpsProject))
|
||||
|
||||
File(projectDir, ".idea/libraries").deleteRecursively()
|
||||
|
||||
File(projectDir, ".idea/runConfigurations")
|
||||
.walk()
|
||||
.filter { it.name.startsWith("JPS_") && it.extension.toLowerCase() == "xml" }
|
||||
.forEach { it.delete() }
|
||||
removeExistingIdeaLibraries()
|
||||
removeJpsRunConfigurations()
|
||||
|
||||
copyRunConfigurations()
|
||||
setOptionsForDefaultJunitRunConfiguration(project)
|
||||
@@ -134,6 +138,24 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
private fun unpill(project: Project) {
|
||||
initEnvironment(project)
|
||||
|
||||
removeExistingIdeaLibrariesAndModules()
|
||||
removeJpsRunConfigurations()
|
||||
}
|
||||
|
||||
private fun removeExistingIdeaLibraries() {
|
||||
File(projectDir, ".idea/libraries").deleteRecursively()
|
||||
}
|
||||
|
||||
private fun removeJpsRunConfigurations() {
|
||||
File(projectDir, ".idea/runConfigurations")
|
||||
.walk()
|
||||
.filter { it.name.startsWith("JPS_") && it.extension.toLowerCase() == "xml" }
|
||||
.forEach { it.delete() }
|
||||
}
|
||||
|
||||
private fun copyRunConfigurations() {
|
||||
val runConfigurationsDir = File(projectDir, "buildSrc/src/main/kotlin/pill/runConfigurations")
|
||||
val targetDir = File(projectDir, ".idea/runConfigurations")
|
||||
|
||||
Reference in New Issue
Block a user