Pill: Move out Pill tasks from buildSrc

This commit is contained in:
Yan Zhulanow
2020-01-31 03:41:45 +09:00
parent 6f1b3e0f17
commit a2be789d37
31 changed files with 235 additions and 84 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
extra["versions.shadow"] = "5.2.0"
extra["versions.native-platform"] = "0.14"
buildscript {
@@ -98,7 +97,7 @@ dependencies {
implementation("net.rubygrapefruit:native-platform-windows-i386:${property("versions.native-platform")}")
implementation("com.jakewharton.dex:dex-method-list:3.0.0")
implementation("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
implementation("com.github.jengelman.gradle.plugins:shadow:${rootProject.extra["versions.shadow"]}")
implementation("org.jetbrains.intellij.deps:asm-all:7.0.1")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.5")
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.pill
import org.gradle.api.Plugin
import org.gradle.api.Project
@Suppress("unused")
class JpsCompatiblePlugin : Plugin<Project> {
override fun apply(project: Project) {
project.configurations.maybeCreate(EmbeddedComponents.CONFIGURATION_NAME)
project.extensions.create("pill", PillExtension::class.java)
// 'jpsTest' does not require the 'tests-jar' artifact
project.configurations.create("jpsTest")
if (project == project.rootProject) {
project.tasks.create("pill") {
dependsOn(":pill:pill-importer:pill")
if (System.getProperty("pill.android.tests", "false") == "true") {
TaskUtils.useAndroidSdk(this)
TaskUtils.useAndroidJar(this)
}
}
project.tasks.create("unpill") {
dependsOn(":pill:pill-importer:unpill")
}
}
}
}
@@ -42,4 +42,10 @@ open class PillExtension {
fun Project.excludedDirs(vararg dirs: String) {
excludedDirs = excludedDirs + dirs.map { File(projectDir, it) }
}
@Suppress("unused")
fun serialize() = mapOf<String, Any?>(
"variant" to variant.name,
"excludedDirs" to excludedDirs
)
}
+1
View File
@@ -14,3 +14,4 @@ versions.jar.picocontainer=1.2
versions.jar.serviceMessages=2019.1.4
ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+1
View File
@@ -14,3 +14,4 @@ versions.jar.oro=2.0.8
versions.jar.picocontainer=1.2
ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+1
View File
@@ -13,3 +13,4 @@ versions.jar.oro=2.0.8
versions.jar.picocontainer=1.2
ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+1
View File
@@ -14,3 +14,4 @@ versions.jar.picocontainer=1.2
versions.jar.serviceMessages=2019.1.4
ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+1
View File
@@ -17,3 +17,4 @@ ignore.jar.common=true
ignore.jar.lombok-ast=true
versions.jar.asm-all=7.0
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+2 -1
View File
@@ -16,4 +16,5 @@ versions.jar.picocontainer=1.2
ignore.jar.snappy-in-java=true
ignore.jar.common=true
ignore.jar.lombok-ast=true
versions.gradle-api=4.5.1
versions.gradle-api=4.5.1
versions.shadow=5.2.0
+1
View File
@@ -16,5 +16,6 @@ versions.jar.picocontainer=1.2
versions.jar.serviceMessages=2019.1.4
ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1
versions.shadow=5.2.0
ignore.jar.common=true
ignore.jar.lombok-ast=true
@@ -0,0 +1,49 @@
import org.jetbrains.kotlin.pill.PillExtension
import java.lang.reflect.Modifier
import java.net.URLClassLoader
plugins {
kotlin("jvm")
id("jps-compatible")
}
pill {
variant = PillExtension.Variant.FULL
}
dependencies {
compileOnly(kotlin("stdlib", embeddedKotlinVersion))
compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
compileOnly("com.github.jengelman.gradle.plugins:shadow:${rootProject.extra["versions.shadow"]}")
}
sourceSets {
"main" { projectDefault() }
"test" { }
}
fun runPillTask(taskName: String) {
val jarFile = configurations.archives.artifacts.single { it.type == "jar" }.file
val cl = URLClassLoader(arrayOf(jarFile.toURI().toURL()), (object {}).javaClass.classLoader)
val pillImporterClass = Class.forName("org.jetbrains.kotlin.pill.PillImporter", true, cl)
val runMethod = pillImporterClass.declaredMethods.single { it.name == "run" }
require(Modifier.isStatic(runMethod.modifiers))
val platformDir = IntellijRootUtils.getIntellijRootDir(project)
val resourcesDir = File(project.projectDir, "resources")
runMethod.invoke(null, project.rootProject, taskName, platformDir, resourcesDir, EmbeddedComponents.CONFIGURATION_NAME)
}
val jar: Jar by tasks
val pill by tasks.creating {
dependsOn(jar)
doLast { runPillTask("pill") }
}
val unpill by tasks.creating {
dependsOn(jar)
doLast { runPillTask("unpill") }
}
@@ -2,7 +2,7 @@
<configuration default="false" name="[Pill] IDEA" type="Application" factoryName="Application" singleton="true">
<log_file alias="idea.log" path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<module name="idea-runner" />
<module name="idea-runner.main" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=240m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=$PROJECT_DIR$/local/ideaSandbox -Didea.config.path=$PROJECT_DIR$/local/ideaSandbox/config -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin $ADDITIONAL_IDEA_ARGS$" />
<option name="WORKING_DIRECTORY" value="file://$IDEA_HOME_PATH$" />
<RunnerSettings RunnerId="Debug">
@@ -2,7 +2,7 @@
<configuration default="false" name="[Pill] IDEA (No ProcessCanceledException)" type="Application" factoryName="Application" singleton="true">
<log_file alias="idea.log" path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<module name="idea-runner" />
<module name="idea-runner.main" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=240m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=$PROJECT_DIR$/local/ideaSandbox -Didea.config.path=$PROJECT_DIR$/local/ideaSandbox/config -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled $ADDITIONAL_IDEA_ARGS$" />
<option name="WORKING_DIRECTORY" value="file://$IDEA_HOME_PATH$" />
<RunnerSettings RunnerId="Debug">
@@ -2,7 +2,7 @@
<configuration default="false" name="[Pill] IDEA Ultimate" type="Application" factoryName="Application" singleton="true">
<log_file alias="idea.log" path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<module name="kotlin-ultimate.ultimate.ultimate-runner" />
<module name="kotlin-ultimate.ultimate.ultimate-runner.main" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=240m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=$PROJECT_DIR$/local/ideaSandbox -Didea.config.path=$PROJECT_DIR$/local/ideaSandbox/config -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin $ADDITIONAL_IDEA_ARGS$" />
<option name="WORKING_DIRECTORY" value="file://$IDEA_HOME_PATH$" />
<RunnerSettings RunnerId="Debug">
@@ -3,10 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.pill
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePluginConvention
import org.gradle.kotlin.dsl.extra
@@ -18,7 +16,9 @@ import java.io.File
import java.util.*
import kotlin.collections.HashMap
class JpsCompatiblePlugin : Plugin<Project> {
const val EMBEDDED_CONFIGURATION_NAME = "embedded"
class JpsCompatiblePluginTasks(private val rootProject: Project, private val platformDir: File, private val resourcesDir: File) {
companion object {
private val DIST_LIBRARIES = listOf(
":kotlin-annotations-jvm",
@@ -55,33 +55,9 @@ class JpsCompatiblePlugin : Plugin<Project> {
private val LIB_DIRECTORIES = listOf("dependencies", "dist")
}
override fun apply(project: Project) {
project.configurations.maybeCreate(EmbeddedComponents.CONFIGURATION_NAME)
project.extensions.create("pill", PillExtension::class.java)
// 'jpsTest' does not require the 'tests-jar' artifact
project.configurations.create("jpsTest")
if (project == project.rootProject) {
project.tasks.create("pill") {
doLast { pill(project) }
if (System.getProperty("pill.android.tests", "false") == "true") {
TaskUtils.useAndroidSdk(this)
TaskUtils.useAndroidJar(this)
}
}
project.tasks.create("unpill") {
doLast { unpill(project) }
}
}
}
private lateinit var projectDir: File
private lateinit var platformVersion: String
private lateinit var platformBaseNumber: String
private lateinit var platformDir: File
private lateinit var intellijCoreDir: File
private var isAndroidStudioPlatform: Boolean = false
@@ -90,25 +66,24 @@ class JpsCompatiblePlugin : Plugin<Project> {
platformVersion = project.extensions.extraProperties.get("versions.intellijSdk").toString()
platformBaseNumber = platformVersion.substringBefore(".", "").takeIf { it.isNotEmpty() }
?: platformVersion.substringBefore("-", "").takeIf { it.isNotEmpty() }
?: error("Invalid platform version: $platformVersion")
platformDir = IntellijRootUtils.getIntellijRootDir(project)
?: error("Invalid platform version: $platformVersion")
intellijCoreDir = File(platformDir.parentFile.parentFile.parentFile, "intellij-core")
isAndroidStudioPlatform = project.extensions.extraProperties.has("versions.androidStudioRelease")
}
private fun pill(rootProject: Project) {
fun pill() {
initEnvironment(rootProject)
val variantOptionValue = System.getProperty("pill.variant", "base").toUpperCase()
val variant = PillExtension.Variant.values().firstOrNull { it.name == variantOptionValue }
?: run {
rootProject.logger.error("Invalid variant name: $variantOptionValue")
return
}
val variant = PillExtensionMirror.Variant.values().firstOrNull { it.name == variantOptionValue }
?: run {
rootProject.logger.error("Invalid variant name: $variantOptionValue")
return
}
rootProject.logger.lifecycle("Pill: Setting up project for the '${variant.name.toLowerCase()}' variant...")
if (variant == PillExtension.Variant.NONE || variant == PillExtension.Variant.DEFAULT) {
if (variant == PillExtensionMirror.Variant.NONE || variant == PillExtensionMirror.Variant.DEFAULT) {
rootProject.logger.error("'none' and 'default' should not be passed as a Pill variant property value")
return
}
@@ -142,8 +117,8 @@ class JpsCompatiblePlugin : Plugin<Project> {
files.forEach { it.write() }
}
private fun unpill(project: Project) {
initEnvironment(project)
fun unpill() {
initEnvironment(rootProject)
removeExistingIdeaLibrariesAndModules()
removeJpsAndPillRunConfigurations()
@@ -170,7 +145,7 @@ class JpsCompatiblePlugin : Plugin<Project> {
}
private fun copyRunConfigurations() {
val runConfigurationsDir = File(projectDir, "buildSrc/src/main/resources/runConfigurations")
val runConfigurationsDir = File(resourcesDir, "runConfigurations")
val targetDir = File(projectDir, ".idea/runConfigurations")
val platformDirProjectRelative = "\$PROJECT_DIR\$/" + platformDir.toRelativeString(projectDir)
val additionalIdeaArgs = if (isAndroidStudioPlatform) "-Didea.platform.prefix=AndroidStudio" else ""
@@ -296,7 +271,7 @@ class JpsCompatiblePlugin : Plugin<Project> {
workspaceFile.writeText(postProcessedXml)
}
private class DependencyPatcher(private val rootProject: Project): Function2<PProject, PDependency, List<PDependency>> {
private class DependencyPatcher(private val rootProject: Project) : Function2<PProject, PDependency, List<PDependency>> {
private val mappings: Map<String, Optional<PLibrary>> = run {
val distLibDir = File(rootProject.extra["distLibDir"].toString())
val result = HashMap<String, Optional<PLibrary>>()
@@ -3,7 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.pill
import org.gradle.api.Project
@@ -45,7 +44,7 @@ class ProjectContext private constructor(private val projectDir: File) : PathCon
}
}
class ModuleContext(val project: PProject, val module: PModule) : PathContext {
class ModuleContext(private val project: PProject, val module: PModule) : PathContext {
override fun invoke(file: File): String {
if (!file.startsWith(project.rootDirectory)) {
return simplifyUserHomeDirPath(file.absolutePath)
@@ -0,0 +1,51 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.pill
import java.io.File
import org.gradle.api.Project
open class PillExtensionMirror(variant: String, val excludedDirs: List<File>) {
val variant = Variant.valueOf(variant)
enum class Variant {
// Default variant (./gradlew pill)
BASE() {
override val includes = setOf(BASE)
},
// Full variant (./gradlew pill -Dpill.variant=full)
FULL() {
override val includes = setOf(BASE, FULL)
},
// Do not import the project to JPS model, but set some options for it
NONE() {
override val includes = emptySet<Variant>()
},
// 'BASE' if the "jps-compatible" plugin is applied, 'NONE' otherwise
DEFAULT() {
override val includes = emptySet<Variant>()
};
abstract val includes: Set<Variant>
}
}
fun Project.findPillExtensionMirror(): PillExtensionMirror? {
val ext = extensions.findByName("pill") ?: return null
@Suppress("UNCHECKED_CAST")
val serialized = ext::class.java.getMethod("serialize").invoke(ext) as Map<String, Any>
val variant = serialized["variant"] as String
@Suppress("UNCHECKED_CAST")
val excludedDirs = serialized["excludedDirs"] as List<File>
val constructor = PillExtensionMirror::class.java.declaredConstructors.single()
return constructor.newInstance(variant, excludedDirs) as PillExtensionMirror
}
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.pill
import org.gradle.api.Project
import java.io.File
object EmbeddedComponents {
lateinit var CONFIGURATION_NAME: String
}
@Suppress("unused")
object PillImporter {
private val TASKS = mapOf(
"pill" to JpsCompatiblePluginTasks::pill,
"unpill" to JpsCompatiblePluginTasks::unpill
)
@JvmStatic
fun run(rootProject: Project, taskName: String, platformDir: File, resourcesDir: File, embeddedConfigurationName: String) {
EmbeddedComponents.CONFIGURATION_NAME = embeddedConfigurationName
val tasks = JpsCompatiblePluginTasks(rootProject, platformDir, resourcesDir)
val task = TASKS[taskName] ?: error("Unknown task $taskName, available tasks: " + TASKS.keys.joinToString())
task(tasks)
}
}
@@ -3,7 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch", "ClassName")
package org.jetbrains.kotlin.pill
import shadow.org.jdom2.Document
@@ -11,14 +10,12 @@ import shadow.org.jdom2.Element
import shadow.org.jdom2.output.Format
import shadow.org.jdom2.output.XMLOutputter
class xml(val name: String, private vararg val args: Pair<String, Any>, block: xml.() -> Unit = {}) {
private companion object {
fun makeXml(name: String, vararg args: Pair<String, Any>, block: xml.() -> Unit = {}): xml {
return xml(name, *args, block = block)
}
}
fun xml(name: String, vararg args: Pair<String, Any>, block: XmlNode.() -> Unit = {}): XmlNode {
return XmlNode(name, args.asList(), block)
}
private val children = mutableListOf<xml>()
class XmlNode(val name: String, private val args: List<Pair<String, Any>>, block: XmlNode.() -> Unit = {}) {
private val children = mutableListOf<XmlNode>()
private var value: Any? = null
init {
@@ -26,11 +23,11 @@ class xml(val name: String, private vararg val args: Pair<String, Any>, block: x
block()
}
fun xml(name: String, vararg args: Pair<String, Any>, block: xml.() -> Unit = {}) {
children += makeXml(name, *args, block = block)
fun xml(name: String, vararg args: Pair<String, Any>, block: XmlNode.() -> Unit = {}) {
children += XmlNode(name, args.asList(), block = block)
}
fun add(xml: xml) {
fun add(xml: XmlNode) {
children += xml
}
@@ -3,8 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.pill
import org.gradle.api.Project
@@ -31,7 +29,7 @@ interface OpaqueDependencyMapper {
sealed class ArtifactElement {
private val myChildren = mutableListOf<ArtifactElement>()
val children get() = myChildren
private val children get() = myChildren
fun add(child: ArtifactElement) {
myChildren += child
@@ -41,9 +39,9 @@ sealed class ArtifactElement {
myChildren += children
}
abstract fun render(context: PathContext): xml
abstract fun render(context: PathContext): XmlNode
fun renderRecursively(context: PathContext): xml {
fun renderRecursively(context: PathContext): XmlNode {
return render(context).apply {
children.forEach { add(it.renderRecursively(context)) }
}
@@ -66,7 +64,7 @@ sealed class ArtifactElement {
}
data class FileCopy(val source: File, val outputFileName: String? = null) : ArtifactElement() {
override fun render(context: PathContext): xml {
override fun render(context: PathContext): XmlNode {
val args = mutableListOf("id" to "file-copy", "path" to context(source))
if (outputFileName != null) {
args += "output-file-name" to outputFileName
@@ -104,21 +102,21 @@ fun generateKotlinPluginArtifactFile(rootProject: Project, dependencyMapper: Opa
root.add(Directory("lib").apply {
val librariesConfiguration = prepareIdeaPluginProject.configurations.getByName("libraries")
add(getArtifactElements(rootProject, librariesConfiguration, dependencyMapper, false))
add(getArtifactElements(librariesConfiguration, dependencyMapper, false))
add(Directory("jps").apply {
val prepareJpsPluginProject = rootProject.getProject(":kotlin-jps-plugin")
add(Archive(prepareJpsPluginProject.name + ".jar").apply {
val jpsPluginConfiguration = prepareIdeaPluginProject.configurations.getByName("jpsPlugin")
add(getArtifactElements(rootProject, jpsPluginConfiguration, dependencyMapper, true))
add(getArtifactElements(jpsPluginConfiguration, dependencyMapper, true))
})
})
add(Archive("kotlin-plugin.jar").apply {
add(FileCopy(File(rootProject.projectDir, "resources/kotlinManifest.properties")))
val embeddedConfiguration = prepareIdeaPluginProject.configurations.getByName(EmbeddedComponents.CONFIGURATION_NAME)
add(getArtifactElements(rootProject, embeddedConfiguration, dependencyMapper, true))
val embeddedConfiguration = prepareIdeaPluginProject.configurations.getByName(EMBEDDED_CONFIGURATION_NAME)
add(getArtifactElements(embeddedConfiguration, dependencyMapper, true))
})
})
@@ -130,7 +128,6 @@ fun generateKotlinPluginArtifactFile(rootProject: Project, dependencyMapper: Opa
}
private fun getArtifactElements(
rootProject: Project,
configuration: Configuration,
dependencyMapper: OpaqueDependencyMapper,
extractDependencies: Boolean
@@ -155,8 +152,11 @@ private fun getArtifactElements(
is PDependency.Library -> artifacts += ProjectLibrary(dependency.name)
is PDependency.ModuleLibrary -> {
val files = dependency.library.classes
if (extractDependencies) files.mapTo(artifacts) { ExtractedDirectory(it) }
else files.mapTo(artifacts) { FileCopy(it) }
if (extractDependencies) {
files.mapTo(artifacts) { ExtractedDirectory(it) }
} else {
files.mapTo(artifacts) { FileCopy(it) }
}
}
}
}
@@ -3,7 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.pill
import org.gradle.api.Project
@@ -19,7 +18,7 @@ import org.gradle.jvm.tasks.Jar
import org.gradle.language.jvm.tasks.ProcessResources
import org.jetbrains.kotlin.pill.POrderRoot.*
import org.jetbrains.kotlin.pill.PSourceRoot.*
import org.jetbrains.kotlin.pill.PillExtension.*
import org.jetbrains.kotlin.pill.PillExtensionMirror.*
import java.io.File
class ParserContext(val variant: Variant)
@@ -112,13 +111,13 @@ fun parse(project: Project, context: ParserContext): PProject = with(context) {
}
fun Project.matchesSelectedVariant(): Boolean {
val extension = this.extensions.findByType(PillExtension::class.java) ?: return true
val extension = this.findPillExtensionMirror() ?: return true
val projectVariant = extension.variant.takeUnless { it == Variant.DEFAULT } ?: Variant.BASE
return projectVariant in context.variant.includes
}
val (includedProjects, excludedProjects) = project.allprojects
.partition { it.plugins.hasPlugin(JpsCompatiblePlugin::class.java) && it.matchesSelectedVariant() }
.partition { it.plugins.hasPlugin("jps-compatible") && it.matchesSelectedVariant() }
val modules = includedProjects.flatMap { parseModules(it, excludedProjects) }
val artifacts = parseArtifacts(project)
@@ -258,7 +257,7 @@ private fun getExcludedDirs(project: Project, excludedProjects: List<Project>):
fun getJavaExcludedDirs() = project.plugins.findPlugin(IdeaPlugin::class.java)
?.model?.module?.excludeDirs?.toList() ?: emptyList()
fun getPillExcludedDirs() = project.extensions.getByType(PillExtension::class.java).excludedDirs
fun getPillExcludedDirs() = project.findPillExtensionMirror()?.excludedDirs ?: emptyList()
return getPillExcludedDirs() + getJavaExcludedDirs() + project.buildDir +
(if (project == project.rootProject) excludedProjects.map { it.buildDir } else emptyList())
@@ -3,20 +3,19 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("PackageDirectoryMismatch", "FunctionName")
package org.jetbrains.kotlin.pill
import java.io.File
class PFile(val path: File, val text: String) {
class PFile(val path: File, private val text: String) {
constructor(path: File, xml: XmlNode) : this(path, xml.toString())
fun write() {
path.parentFile.mkdirs()
path.writeText(text)
}
}
fun PFile(path: File, xml: xml) = PFile(path, xml.toString())
fun render(project: PProject): List<PFile> {
val files = mutableListOf<PFile>()
@@ -45,7 +44,8 @@ private fun renderModulesFile(project: PProject) = PFile(
private fun renderModule(project: PProject, module: PModule) = PFile(
module.moduleFile,
xml("module",
xml(
"module",
"type" to "JAVA_MODULE",
"version" to 4
) {
@@ -93,7 +93,8 @@ private fun renderModule(project: PProject, module: PModule) = PFile(
}
}
xml("component",
xml(
"component",
"name" to "NewModuleRootManager",
"LANGUAGE_LEVEL" to "JDK_${platformVersion.replace('.', '_')}",
"inherit-compiler-output" to "true"
@@ -179,7 +180,7 @@ private fun renderLibrary(project: PProject, library: PLibrary): PFile {
})
}
private fun renderLibraryToXml(library: PLibrary, pathContext: PathContext, named: Boolean = true): xml {
private fun renderLibraryToXml(library: PLibrary, pathContext: PathContext, named: Boolean = true): XmlNode {
val args = if (named) arrayOf("name" to library.renderName()) else emptyArray()
return xml("library", *args) {
+2
View File
@@ -269,6 +269,7 @@ include ":kotlin-build-common",
":examples:scripting-jvm-maven-deps",
":examples:scripting-jvm-maven-deps-host",
":examples:scripting-jvm-embeddable-host",
":pill:pill-importer",
":pill:generate-all-tests",
":libraries:kotlin-prepush-hook",
":libraries:tools:mutability-annotations-compat",
@@ -475,6 +476,7 @@ project(':examples:scripting-jvm-simple-script-host').projectDir = "$rootDir/lib
project(':examples:scripting-jvm-maven-deps').projectDir = "$rootDir/libraries/examples/scripting/jvm-maven-deps/script" as File
project(':examples:scripting-jvm-maven-deps-host').projectDir = "$rootDir/libraries/examples/scripting/jvm-maven-deps/host" as File
project(':examples:scripting-jvm-embeddable-host').projectDir = "$rootDir/libraries/examples/scripting/jvm-embeddable-host" as File
project(':pill:pill-importer').projectDir = "$rootDir/plugins/pill/pill-importer" as File
project(':pill:generate-all-tests').projectDir = "$rootDir/plugins/pill/generate-all-tests" as File
project(':kotlin-imports-dumper-compiler-plugin').projectDir = "$rootDir/plugins/imports-dumper" as File
project(':libraries:kotlin-prepush-hook').projectDir = "$rootDir/libraries/tools/kotlin-prepush-hook" as File