Revert "Use KotlinTarget.disambiguationClassifier for task & configuration names"
This commit is contained in:
+12
-19
@@ -30,8 +30,9 @@ import org.gradle.api.tasks.compile.AbstractCompile
|
|||||||
import org.gradle.api.tasks.compile.JavaCompile
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleJavaTargetExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin
|
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin
|
||||||
import org.jetbrains.kotlin.gradle.internal.KaptVariantData
|
import org.jetbrains.kotlin.gradle.internal.KaptVariantData
|
||||||
@@ -42,7 +43,6 @@ import org.jetbrains.kotlin.gradle.model.builder.KotlinModelBuilder
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
import org.jetbrains.kotlin.gradle.utils.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
@@ -398,8 +398,6 @@ internal abstract class AbstractKotlinPlugin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val KOTLIN_TARGET_NAME = "kotlin"
|
|
||||||
|
|
||||||
fun configureProjectGlobalSettings(project: Project, kotlinPluginVersion: String) {
|
fun configureProjectGlobalSettings(project: Project, kotlinPluginVersion: String) {
|
||||||
configureDefaultVersionsResolutionStrategy(project, kotlinPluginVersion)
|
configureDefaultVersionsResolutionStrategy(project, kotlinPluginVersion)
|
||||||
configureClassInspectionForIC(project)
|
configureClassInspectionForIC(project)
|
||||||
@@ -558,19 +556,18 @@ internal fun configureDefaultVersionsResolutionStrategy(project: Project, kotlin
|
|||||||
internal open class KotlinPlugin(
|
internal open class KotlinPlugin(
|
||||||
kotlinPluginVersion: String,
|
kotlinPluginVersion: String,
|
||||||
registry: ToolingModelBuilderRegistry
|
registry: ToolingModelBuilderRegistry
|
||||||
) : AbstractKotlinPlugin(KotlinTasksProvider(targetDisambiguationClassifier), kotlinPluginVersion, registry) {
|
) : AbstractKotlinPlugin(KotlinTasksProvider(targetName), kotlinPluginVersion, registry) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Don't add anything to the task names
|
private const val targetName = "" // use empty suffix for the task names
|
||||||
private const val targetDisambiguationClassifier: String = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildSourceSetProcessor(project: Project, compilation: KotlinCompilation<*>, kotlinPluginVersion: String) =
|
override fun buildSourceSetProcessor(project: Project, compilation: KotlinCompilation<*>, kotlinPluginVersion: String) =
|
||||||
Kotlin2JvmSourceSetProcessor(project, tasksProvider, compilation, kotlinPluginVersion)
|
Kotlin2JvmSourceSetProcessor(project, tasksProvider, compilation, kotlinPluginVersion)
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
val target = KotlinWithJavaTarget<KotlinJvmOptions>(project, KotlinPlatformType.jvm, KOTLIN_TARGET_NAME).apply {
|
val target = KotlinWithJavaTarget<KotlinJvmOptions>(project, KotlinPlatformType.jvm, targetName).apply {
|
||||||
disambiguationClassifier = targetDisambiguationClassifier
|
disambiguationClassifier = null // don't add anything to the task names
|
||||||
}
|
}
|
||||||
(project.kotlinExtension as KotlinJvmProjectExtension).target = target
|
(project.kotlinExtension as KotlinJvmProjectExtension).target = target
|
||||||
|
|
||||||
@@ -583,10 +580,10 @@ internal open class KotlinPlugin(
|
|||||||
internal open class KotlinCommonPlugin(
|
internal open class KotlinCommonPlugin(
|
||||||
kotlinPluginVersion: String,
|
kotlinPluginVersion: String,
|
||||||
registry: ToolingModelBuilderRegistry
|
registry: ToolingModelBuilderRegistry
|
||||||
) : AbstractKotlinPlugin(KotlinTasksProvider(targetDisambiguationClassifier), kotlinPluginVersion, registry) {
|
) : AbstractKotlinPlugin(KotlinTasksProvider(targetName), kotlinPluginVersion, registry) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val targetDisambiguationClassifier = "common"
|
private const val targetName = "common"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildSourceSetProcessor(
|
override fun buildSourceSetProcessor(
|
||||||
@@ -597,9 +594,7 @@ internal open class KotlinCommonPlugin(
|
|||||||
KotlinCommonSourceSetProcessor(project, compilation, tasksProvider, kotlinPluginVersion)
|
KotlinCommonSourceSetProcessor(project, compilation, tasksProvider, kotlinPluginVersion)
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
val target = KotlinWithJavaTarget<KotlinMultiplatformCommonOptions>(project, KotlinPlatformType.common, KOTLIN_TARGET_NAME).apply {
|
val target = KotlinWithJavaTarget<KotlinMultiplatformCommonOptions>(project, KotlinPlatformType.common, targetName)
|
||||||
disambiguationClassifier = targetDisambiguationClassifier
|
|
||||||
}
|
|
||||||
(project.kotlinExtension as KotlinCommonProjectExtension).target = target
|
(project.kotlinExtension as KotlinCommonProjectExtension).target = target
|
||||||
|
|
||||||
super.apply(project)
|
super.apply(project)
|
||||||
@@ -609,10 +604,10 @@ internal open class KotlinCommonPlugin(
|
|||||||
internal open class Kotlin2JsPlugin(
|
internal open class Kotlin2JsPlugin(
|
||||||
kotlinPluginVersion: String,
|
kotlinPluginVersion: String,
|
||||||
registry: ToolingModelBuilderRegistry
|
registry: ToolingModelBuilderRegistry
|
||||||
) : AbstractKotlinPlugin(KotlinTasksProvider(targetDisambiguationClassifier), kotlinPluginVersion, registry) {
|
) : AbstractKotlinPlugin(KotlinTasksProvider(targetName), kotlinPluginVersion, registry) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val targetDisambiguationClassifier = "2Js"
|
private const val targetName = "2Js"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildSourceSetProcessor(
|
override fun buildSourceSetProcessor(
|
||||||
@@ -625,9 +620,7 @@ internal open class Kotlin2JsPlugin(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
val target = KotlinWithJavaTarget<KotlinJsOptions>(project, KotlinPlatformType.js, KOTLIN_TARGET_NAME).apply {
|
val target = KotlinWithJavaTarget<KotlinJsOptions>(project, KotlinPlatformType.js, targetName)
|
||||||
disambiguationClassifier = targetDisambiguationClassifier
|
|
||||||
}
|
|
||||||
|
|
||||||
(project.kotlinExtension as Kotlin2JsProjectExtension).target = target
|
(project.kotlinExtension as Kotlin2JsProjectExtension).target = target
|
||||||
super.apply(project)
|
super.apply(project)
|
||||||
|
|||||||
+3
-3
@@ -33,17 +33,17 @@ internal abstract class TaskToFriendTaskMapper {
|
|||||||
sealed internal class RegexTaskToFriendTaskMapper(
|
sealed internal class RegexTaskToFriendTaskMapper(
|
||||||
private val prefix: String,
|
private val prefix: String,
|
||||||
suffix: String,
|
suffix: String,
|
||||||
private val targetDisambiguationClasssifier: String,
|
private val targetName: String,
|
||||||
private val postfixReplacement: String
|
private val postfixReplacement: String
|
||||||
) : TaskToFriendTaskMapper() {
|
) : TaskToFriendTaskMapper() {
|
||||||
class Default(targetName: String) : RegexTaskToFriendTaskMapper("compile", "TestKotlin", targetName, "Kotlin")
|
class Default(targetName: String) : RegexTaskToFriendTaskMapper("compile", "TestKotlin", targetName, "Kotlin")
|
||||||
class Android(targetName: String) : RegexTaskToFriendTaskMapper("compile", "(Unit|Android)TestKotlin", targetName, "Kotlin")
|
class Android(targetName: String) : RegexTaskToFriendTaskMapper("compile", "(Unit|Android)TestKotlin", targetName, "Kotlin")
|
||||||
|
|
||||||
private val regex = "$prefix(.*)$suffix${targetDisambiguationClasssifier.capitalize()}".toRegex()
|
private val regex = "$prefix(.*)$suffix${targetName.capitalize()}".toRegex()
|
||||||
|
|
||||||
override fun getFriendByName(name: String): String? {
|
override fun getFriendByName(name: String): String? {
|
||||||
val match = regex.matchEntire(name) ?: return null
|
val match = regex.matchEntire(name) ?: return null
|
||||||
val variant = match.groups[1]?.value ?: ""
|
val variant = match.groups[1]?.value ?: ""
|
||||||
return prefix + variant + postfixReplacement + targetDisambiguationClasssifier.capitalize()
|
return prefix + variant + postfixReplacement + targetName.capitalize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-10
@@ -10,8 +10,10 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.defaultSourceSetLanguageSettingsChecker
|
import org.jetbrains.kotlin.gradle.plugin.sources.defaultSourceSetLanguageSettingsChecker
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.getSourceSetHierarchy
|
import org.jetbrains.kotlin.gradle.plugin.sources.getSourceSetHierarchy
|
||||||
@@ -23,19 +25,13 @@ import java.util.concurrent.Callable
|
|||||||
|
|
||||||
internal fun KotlinCompilation<*>.composeName(prefix: String? = null, suffix: String? = null): String {
|
internal fun KotlinCompilation<*>.composeName(prefix: String? = null, suffix: String? = null): String {
|
||||||
val compilationNamePart = compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }
|
val compilationNamePart = compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }
|
||||||
val targetNamePart =
|
val targetNamePart = target.disambiguationClassifier
|
||||||
if (target is KotlinWithJavaTarget<*>)
|
|
||||||
"" // no name disambiguation is needed for single-platform projects
|
|
||||||
else target.disambiguationClassifier
|
|
||||||
|
|
||||||
return lowerCamelCaseName(prefix, targetNamePart, compilationNamePart, suffix)
|
return lowerCamelCaseName(prefix, targetNamePart, compilationNamePart, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val KotlinCompilation<*>.defaultSourceSetName: String
|
internal val KotlinCompilation<*>.defaultSourceSetName: String
|
||||||
get() = when (this) {
|
get() = lowerCamelCaseName(target.disambiguationClassifier, compilationName)
|
||||||
is KotlinWithJavaCompilation<*> -> compilationName // no name disambiguation is needed for single-platform projects
|
|
||||||
else -> lowerCamelCaseName(target.disambiguationClassifier, compilationName)
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
||||||
target: KotlinTarget,
|
target: KotlinTarget,
|
||||||
@@ -151,7 +147,7 @@ abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
|||||||
"compile",
|
"compile",
|
||||||
compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME },
|
compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME },
|
||||||
"Kotlin",
|
"Kotlin",
|
||||||
target.disambiguationClassifier
|
target.targetName
|
||||||
)
|
)
|
||||||
|
|
||||||
override val compileAllTaskName: String
|
override val compileAllTaskName: String
|
||||||
|
|||||||
+1
-1
@@ -239,7 +239,7 @@ abstract class AbstractKotlinTarget(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun KotlinTarget.disambiguateName(simpleName: String) =
|
internal fun KotlinTarget.disambiguateName(simpleName: String) =
|
||||||
lowerCamelCaseName(disambiguationClassifier, simpleName)
|
lowerCamelCaseName(targetName, simpleName)
|
||||||
|
|
||||||
internal fun javaApiUsageForMavenScoping() =
|
internal fun javaApiUsageForMavenScoping() =
|
||||||
if (isGradleVersionAtLeast(5, 3)) {
|
if (isGradleVersionAtLeast(5, 3)) {
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ internal fun <T : Task> registerTask(project: Project, name: String, type: Class
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal open class KotlinTasksProvider(targetDisambiguationClassifier: String) {
|
internal open class KotlinTasksProvider(val targetName: String) {
|
||||||
open fun registerKotlinJVMTask(
|
open fun registerKotlinJVMTask(
|
||||||
project: Project,
|
project: Project,
|
||||||
name: String,
|
name: String,
|
||||||
@@ -109,7 +109,7 @@ internal open class KotlinTasksProvider(targetDisambiguationClassifier: String)
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open val taskToFriendTaskMapper: TaskToFriendTaskMapper =
|
protected open val taskToFriendTaskMapper: TaskToFriendTaskMapper =
|
||||||
RegexTaskToFriendTaskMapper.Default(targetDisambiguationClassifier)
|
RegexTaskToFriendTaskMapper.Default(targetName)
|
||||||
|
|
||||||
private inline fun <reified Task, reified WorkersTask : Task> taskOrWorkersTask(properties: PropertiesProvider): Class<out Task> =
|
private inline fun <reified Task, reified WorkersTask : Task> taskOrWorkersTask(properties: PropertiesProvider): Class<out Task> =
|
||||||
if (properties.parallelTasksInProject != true) Task::class.java else WorkersTask::class.java
|
if (properties.parallelTasksInProject != true) Task::class.java else WorkersTask::class.java
|
||||||
|
|||||||
Reference in New Issue
Block a user