Add some API interfaces for Gradle PM20 entities in the API module
This commit is contained in:
@@ -16,6 +16,7 @@ dependencies {
|
||||
|
||||
compileOnly(gradleApi())
|
||||
compileOnly("com.android.tools.build:gradle:3.4.0")
|
||||
compileOnly(project(":kotlin-project-model"))
|
||||
}
|
||||
|
||||
pill {
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.gradle.plugin.mpp.pm20
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
|
||||
interface KotlinCompilationData<T : KotlinCommonOptions> {
|
||||
val project: Project
|
||||
val owner: Any?
|
||||
|
||||
val compilationPurpose: String
|
||||
val compilationClassifier: String?
|
||||
|
||||
val kotlinSourceDirectoriesByFragmentName: Map<String, SourceDirectorySet>
|
||||
val compileKotlinTaskName: String
|
||||
val compileAllTaskName: String
|
||||
|
||||
val compileDependencyFiles: FileCollection
|
||||
val output: KotlinCompilationOutput
|
||||
|
||||
val languageSettings: LanguageSettingsBuilder
|
||||
val platformType: KotlinPlatformType
|
||||
|
||||
val moduleName: String
|
||||
val ownModuleName: String
|
||||
|
||||
val kotlinOptions: T
|
||||
|
||||
val friendPaths: Iterable<FileCollection>
|
||||
}
|
||||
|
||||
interface KotlinVariantCompilationData<T : KotlinCommonOptions> : KotlinCompilationData<T> {
|
||||
override val owner: KotlinGradleVariant
|
||||
|
||||
override val project: Project get() = owner.containingModule.project
|
||||
|
||||
override val compilationPurpose: String
|
||||
get() = owner.containingModule.name
|
||||
|
||||
override val compilationClassifier: String
|
||||
get() = owner.name
|
||||
|
||||
override val output: KotlinCompilationOutput
|
||||
get() = owner.compilationOutputs
|
||||
|
||||
override val compileKotlinTaskName: String
|
||||
|
||||
override val compileAllTaskName: String
|
||||
|
||||
override val kotlinSourceDirectoriesByFragmentName: Map<String, SourceDirectorySet>
|
||||
|
||||
override val compileDependencyFiles: FileCollection
|
||||
get() = owner.compileDependencyFiles
|
||||
|
||||
override val languageSettings: LanguageSettingsBuilder
|
||||
get() = owner.languageSettings
|
||||
|
||||
override val platformType: KotlinPlatformType
|
||||
get() = owner.platformType
|
||||
|
||||
override val ownModuleName: String
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.gradle.plugin.mpp.pm20
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.NamedDomainObjectProvider
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.HasKotlinDependencies
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
import org.jetbrains.kotlin.project.model.KotlinModuleFragment
|
||||
|
||||
interface KotlinGradleFragment : KotlinModuleFragment, HasKotlinDependencies, Named {
|
||||
override val kotlinSourceRoots: SourceDirectorySet
|
||||
|
||||
override val containingModule: KotlinGradleModule
|
||||
|
||||
override fun getName(): String = fragmentName
|
||||
|
||||
// TODO pull up to KotlinModuleFragment
|
||||
// FIXME apply to compilation
|
||||
// FIXME check for consistency
|
||||
val languageSettings: LanguageSettingsBuilder
|
||||
|
||||
val project: Project
|
||||
get() = containingModule.project
|
||||
|
||||
fun refines(other: KotlinGradleFragment)
|
||||
|
||||
fun refines(other: NamedDomainObjectProvider<KotlinGradleFragment>)
|
||||
|
||||
override fun dependencies(configureClosure: Closure<Any?>) =
|
||||
dependencies f@{ ConfigureUtil.configure(configureClosure, this@f) }
|
||||
|
||||
companion object {
|
||||
const val COMMON_FRAGMENT_NAME = "common"
|
||||
}
|
||||
|
||||
/** This configuration includes the dependencies from the refines-parents */
|
||||
val transitiveApiConfigurationName: String
|
||||
|
||||
/** This configuration includes the dependencies from the refines-parents */
|
||||
val transitiveImplementationConfigurationName: String
|
||||
|
||||
override val relatedConfigurationNames: List<String>
|
||||
get() = super.relatedConfigurationNames +
|
||||
// TODO: resolvable metadata configurations?
|
||||
listOf(transitiveApiConfigurationName, transitiveImplementationConfigurationName)
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.gradle.plugin.mpp.pm20
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.ExtensiblePolymorphicDomainObjectContainer
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.NamedDomainObjectSet
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.HasKotlinDependencies
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||
import org.jetbrains.kotlin.project.model.KotlinModule
|
||||
|
||||
interface KotlinGradleModule : KotlinModule, Named, HasKotlinDependencies {
|
||||
val project: Project
|
||||
val moduleClassifier: String?
|
||||
|
||||
override val fragments: ExtensiblePolymorphicDomainObjectContainer<KotlinGradleFragment>
|
||||
|
||||
// TODO DSL & build script model: find a way to create a flexible typed view on fragments?
|
||||
override val variants: NamedDomainObjectSet<KotlinGradleVariant>
|
||||
|
||||
val isPublic: Boolean
|
||||
|
||||
fun ifMadePublic(action: () -> Unit)
|
||||
|
||||
fun makePublic()
|
||||
|
||||
companion object {
|
||||
const val MAIN_MODULE_NAME = "main"
|
||||
const val TEST_MODULE_NAME = "test"
|
||||
}
|
||||
|
||||
override fun getName(): String = when (val classifier = moduleClassifier) {
|
||||
null -> MAIN_MODULE_NAME
|
||||
else -> classifier
|
||||
}
|
||||
|
||||
// DSL
|
||||
|
||||
val common: KotlinGradleFragment
|
||||
get() = fragments.getByName(KotlinGradleFragment.COMMON_FRAGMENT_NAME)
|
||||
|
||||
fun common(configure: KotlinGradleFragment.() -> Unit) =
|
||||
common.configure()
|
||||
|
||||
override fun dependencies(configure: KotlinDependencyHandler.() -> Unit) =
|
||||
common.dependencies(configure)
|
||||
|
||||
override fun dependencies(configureClosure: Closure<Any?>) =
|
||||
common.dependencies(configureClosure)
|
||||
|
||||
override val apiConfigurationName: String
|
||||
get() = common.apiConfigurationName
|
||||
|
||||
override val implementationConfigurationName: String
|
||||
get() = common.implementationConfigurationName
|
||||
|
||||
override val compileOnlyConfigurationName: String
|
||||
get() = common.compileOnlyConfigurationName
|
||||
|
||||
override val runtimeOnlyConfigurationName: String
|
||||
get() = common.runtimeOnlyConfigurationName
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.gradle.plugin.mpp.pm20
|
||||
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.project.model.KotlinModuleVariant
|
||||
|
||||
interface KotlinGradleVariant : KotlinGradleFragment, KotlinModuleVariant {
|
||||
val platformType: KotlinPlatformType
|
||||
|
||||
// TODO generalize with KotlinCompilation?
|
||||
val compileDependencyConfigurationName: String
|
||||
|
||||
var compileDependencyFiles: FileCollection
|
||||
|
||||
// TODO rewrite using our own artifacts API?
|
||||
val compilationOutputs: KotlinCompilationOutput
|
||||
|
||||
// TODO rewrite using our own artifacts API
|
||||
val sourceArchiveTask: TaskProvider<AbstractArchiveTask>
|
||||
|
||||
// TODO generalize exposing outputs: what if a variant has more than one such configurations or none?
|
||||
val apiElementsConfigurationName: String
|
||||
|
||||
val gradleVariantNames: Set<String>
|
||||
}
|
||||
|
||||
interface KotlinGradleVariantWithRuntime : KotlinGradleVariant {
|
||||
// TODO deduplicate with KotlinCompilation?
|
||||
val runtimeDependencyConfigurationName: String
|
||||
|
||||
var runtimeDependencyFiles: FileCollection
|
||||
|
||||
val runtimeFiles: ConfigurableFileCollection
|
||||
|
||||
// TODO generalize exposing outputs: what if a variant has more than one such configurations or none?
|
||||
val runtimeElementsConfigurationName: String
|
||||
}
|
||||
|
||||
interface KotlinNativeVariant : KotlinGradleVariant {
|
||||
override val platformType: KotlinPlatformType
|
||||
get() = KotlinPlatformType.native
|
||||
|
||||
var enableEndorsedLibraries: Boolean
|
||||
}
|
||||
|
||||
interface SingleMavenPublicationHolder {
|
||||
fun assignMavenPublication(publication: MavenPublication)
|
||||
val defaultPublishedModuleSuffix: String?
|
||||
val publishedMavenModuleCoordinates: PublishedModuleCoordinatesProvider
|
||||
}
|
||||
|
||||
interface PublishedModuleCoordinatesProvider {
|
||||
val group: String
|
||||
val name: String
|
||||
val version: String
|
||||
val capabilities: Iterable<String>
|
||||
}
|
||||
Reference in New Issue
Block a user