[gradle][plugin] checks if GRADLE_METADATA feature is enabled and enable publishing then
This commit is contained in:
committed by
Vasily Levchenko
parent
fec885d260
commit
2e33f5c0bc
@@ -1,5 +1,6 @@
|
|||||||
// NOTE: If a new sample uses only platform libs,
|
// NOTE: If a new sample uses only platform libs,
|
||||||
// please add it into the 'buildSamplesWithPlatfromLibs' task in build.gradle.
|
// please add it into the 'buildSamplesWithPlatfromLibs' task in build.gradle.
|
||||||
|
enableFeaturePreview('GRADLE_METADATA')
|
||||||
include ':csvparser'
|
include ':csvparser'
|
||||||
include ':gitchurn'
|
include ':gitchurn'
|
||||||
include ':globalState'
|
include ':globalState'
|
||||||
|
|||||||
+10
-2
@@ -280,7 +280,8 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
// TODO: Remove them when an API for env vars is provided.
|
// TODO: Remove them when an API for env vars is provided.
|
||||||
KONAN_CONFIGURATION_BUILD_DIR ("konan.configuration.build.dir"),
|
KONAN_CONFIGURATION_BUILD_DIR ("konan.configuration.build.dir"),
|
||||||
KONAN_DEBUGGING_SYMBOLS ("konan.debugging.symbols"),
|
KONAN_DEBUGGING_SYMBOLS ("konan.debugging.symbols"),
|
||||||
KONAN_OPTIMIZATIONS_ENABLE ("konan.optimizations.enable")
|
KONAN_OPTIMIZATIONS_ENABLE ("konan.optimizations.enable"),
|
||||||
|
KONAN_PUBLICATION_ENABLED ("konan.publication.enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -310,6 +311,11 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
project.tasks.create(KONAN_GENERATE_CMAKE_TASK_NAME, KonanGenerateCMakeTask::class.java)
|
project.tasks.create(KONAN_GENERATE_CMAKE_TASK_NAME, KonanGenerateCMakeTask::class.java)
|
||||||
project.extensions.create(KONAN_EXTENSION_NAME, KonanExtension::class.java)
|
project.extensions.create(KONAN_EXTENSION_NAME, KonanExtension::class.java)
|
||||||
val container = project.extensions.create(KonanArtifactContainer::class.java, ARTIFACTS_CONTAINER_NAME, KonanArtifactContainer::class.java, project)
|
val container = project.extensions.create(KonanArtifactContainer::class.java, ARTIFACTS_CONTAINER_NAME, KonanArtifactContainer::class.java, project)
|
||||||
|
val isPublicationEnabled = project.gradle.services.get(FeaturePreviews::class.java).isFeatureEnabled(FeaturePreviews.Feature.GRADLE_METADATA)
|
||||||
|
project.setProperty(ProjectProperty.KONAN_PUBLICATION_ENABLED, isPublicationEnabled)
|
||||||
|
if (!isPublicationEnabled) {
|
||||||
|
project.logger.warn("feature GRADLE_METADATA is not enabled: publication is disabled")
|
||||||
|
}
|
||||||
|
|
||||||
// Set additional project properties like konan.home, konan.build.targets etc.
|
// Set additional project properties like konan.home, konan.build.targets etc.
|
||||||
if (!project.hasProperty(ProjectProperty.KONAN_HOME)) {
|
if (!project.hasProperty(ProjectProperty.KONAN_HOME)) {
|
||||||
@@ -348,10 +354,12 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//project.gradle.experimentalFeatures.enable()
|
//project.gradle.experimentalFeatures.enable()
|
||||||
project.gradle.services.get(FeaturePreviews::class.java).enableFeature(FeaturePreviews.Feature.GRADLE_METADATA)
|
|
||||||
// Enable multiplatform support
|
// Enable multiplatform support
|
||||||
project.pluginManager.apply(KotlinNativePlatformPlugin::class.java)
|
project.pluginManager.apply(KotlinNativePlatformPlugin::class.java)
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
|
if (!isPublicationEnabled)
|
||||||
|
return@afterEvaluate
|
||||||
project.pluginManager.withPlugin("maven-publish") {
|
project.pluginManager.withPlugin("maven-publish") {
|
||||||
container.all {
|
container.all {
|
||||||
val buildingConfig = it
|
val buildingConfig = it
|
||||||
|
|||||||
+2
@@ -98,6 +98,8 @@ abstract class KonanArtifactTask: KonanTargetableTask(), KonanArtifactSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
project.pluginManager.withPlugin("maven-publish") {
|
project.pluginManager.withPlugin("maven-publish") {
|
||||||
|
if (!(project.getProperty(KonanPlugin.ProjectProperty.KONAN_PUBLICATION_ENABLED) as Boolean))
|
||||||
|
return@withPlugin
|
||||||
platformConfiguration.artifacts.add(object: PublishArtifact {
|
platformConfiguration.artifacts.add(object: PublishArtifact {
|
||||||
override fun getName() = "${artifact.name.removeSuffix("$artifactSuffix")}/${target.name}"
|
override fun getName() = "${artifact.name.removeSuffix("$artifactSuffix")}/${target.name}"
|
||||||
override fun getExtension() = if (artifactSuffix.startsWith('.')) artifactSuffix.substring(1) else artifactSuffix
|
override fun getExtension() = if (artifactSuffix.startsWith('.')) artifactSuffix.substring(1) else artifactSuffix
|
||||||
|
|||||||
Reference in New Issue
Block a user