Pill: Do not delete existing artifacts for JPS build

This commit is contained in:
Yan Zhulanow
2021-03-11 21:20:08 +09:00
parent cfd585e221
commit 5fca37fa0f
@@ -61,6 +61,11 @@ class JpsCompatiblePluginTasks(private val rootProject: Project, private val pla
) )
private val LIB_DIRECTORIES = listOf("dependencies", "dist") private val LIB_DIRECTORIES = listOf("dependencies", "dist")
private val ALLOWED_ARTIFACT_PATTERNS = listOf(
Regex.fromLiteral("dist_root.xml"),
Regex("kotlinx_cli_jvm_[\\d_]+_SNAPSHOT\\.xml")
)
} }
private lateinit var projectDir: File private lateinit var projectDir: File
@@ -105,7 +110,7 @@ class JpsCompatiblePluginTasks(private val rootProject: Project, private val pla
removeExistingIdeaLibrariesAndModules() removeExistingIdeaLibrariesAndModules()
removeJpsAndPillRunConfigurations() removeJpsAndPillRunConfigurations()
removeAllArtifactConfigurations() removeArtifactConfigurations()
if (variant.includes.contains(PillExtensionMirror.Variant.BASE)) { if (variant.includes.contains(PillExtensionMirror.Variant.BASE)) {
val artifactDependencyMapper = object : ArtifactDependencyMapper { val artifactDependencyMapper = object : ArtifactDependencyMapper {
@@ -141,7 +146,7 @@ class JpsCompatiblePluginTasks(private val rootProject: Project, private val pla
removeExistingIdeaLibrariesAndModules() removeExistingIdeaLibrariesAndModules()
removeJpsAndPillRunConfigurations() removeJpsAndPillRunConfigurations()
removeAllArtifactConfigurations() removeArtifactConfigurations()
} }
private fun removeExistingIdeaLibrariesAndModules() { private fun removeExistingIdeaLibrariesAndModules() {
@@ -156,10 +161,10 @@ class JpsCompatiblePluginTasks(private val rootProject: Project, private val pla
.forEach { it.delete() } .forEach { it.delete() }
} }
private fun removeAllArtifactConfigurations() { private fun removeArtifactConfigurations() {
File(projectDir, ".idea/artifacts") File(projectDir, ".idea/artifacts")
.walk() .walk()
.filter { it.extension.toLowerCase() == "xml" } .filter { it.extension.toLowerCase() == "xml" && ALLOWED_ARTIFACT_PATTERNS.none { p -> p.matches(it.name) } }
.forEach { it.delete() } .forEach { it.delete() }
} }