Relax publishing rules. Add a way to regulate publishing targets from parameters
This commit is contained in:
parent
4106fe27a9
commit
2886b7b200
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
- All publishing is enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module.
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
@ -211,7 +211,6 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
|
@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
tools = "0.14.4-kotlin-1.8.20-RC"
|
||||
tools = "0.14.5-kotlin-1.8.20-RC"
|
||||
kotlin = "1.8.20-RC"
|
||||
atomicfu = "0.19.0"
|
||||
binary-compatibility-validator = "0.12.1"
|
||||
|
@ -24,6 +24,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask
|
||||
import space.kscience.gradle.internal.defaultKotlinJvmArgs
|
||||
import space.kscience.gradle.internal.fromJsDependencies
|
||||
import space.kscience.gradle.internal.requestPropertyOrNull
|
||||
import space.kscience.gradle.internal.useCommonDependency
|
||||
|
||||
public enum class DependencyConfiguration {
|
||||
@ -292,14 +293,30 @@ public data class KScienceNativeTarget(
|
||||
}
|
||||
}
|
||||
|
||||
public class KScienceNativeConfiguration {
|
||||
public class KScienceNativeConfiguration(private val project: Project) {
|
||||
|
||||
|
||||
internal companion object {
|
||||
private fun defaultNativeTargets(): Map<KotlinNativePreset, KScienceNativeTarget> {
|
||||
|
||||
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> {
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
val targets = project.requestPropertyOrNull("publishing.targets")
|
||||
|
||||
return when {
|
||||
targets == "all" -> listOf(
|
||||
KScienceNativeTarget.linuxX64,
|
||||
KScienceNativeTarget.mingwX64,
|
||||
KScienceNativeTarget.macosX64,
|
||||
KScienceNativeTarget.macosArm64,
|
||||
KScienceNativeTarget.iosX64,
|
||||
KScienceNativeTarget.iosArm64,
|
||||
KScienceNativeTarget.iosSimulatorArm64,
|
||||
)
|
||||
|
||||
targets != null -> {
|
||||
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) }
|
||||
}
|
||||
|
||||
hostOs.startsWith("Windows") -> listOf(
|
||||
KScienceNativeTarget.linuxX64,
|
||||
KScienceNativeTarget.mingwX64
|
||||
@ -314,6 +331,7 @@ public class KScienceNativeConfiguration {
|
||||
)
|
||||
|
||||
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
|
||||
|
||||
else -> {
|
||||
emptyList()
|
||||
}
|
||||
@ -322,7 +340,7 @@ public class KScienceNativeConfiguration {
|
||||
}
|
||||
|
||||
|
||||
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets()
|
||||
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project)
|
||||
|
||||
|
||||
/**
|
||||
@ -459,7 +477,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
|
||||
* Enable all supported native targets
|
||||
*/
|
||||
public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) {
|
||||
val nativeConfiguration = KScienceNativeConfiguration().apply(block)
|
||||
val nativeConfiguration = KScienceNativeConfiguration(this).apply(block)
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
val nativeTargets: List<KotlinNativeTarget> =
|
||||
|
@ -116,22 +116,18 @@ internal fun Project.addGithubPublishing(
|
||||
githubOrg: String,
|
||||
githubProject: String,
|
||||
) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.github") != "false") {
|
||||
logger.info("Skipping github publishing because `publishing.github != true`")
|
||||
return
|
||||
}
|
||||
val githubUser: String? = requestPropertyOrNull("publishing.github.user")
|
||||
val githubToken: String? = requestPropertyOrNull("publishing.github.token")
|
||||
|
||||
val githubUser: String = requestProperty("publishing.github.user")
|
||||
val githubToken: String = requestProperty("publishing.github.token")
|
||||
if (githubUser == null || githubToken == null) {
|
||||
logger.info("Skipping Github publishing because Github credentials are not defined")
|
||||
return
|
||||
}
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
logger.info("Adding github publishing to project [${project.name}]")
|
||||
logger.info("Adding Github publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "github"
|
||||
@ -148,23 +144,18 @@ internal fun Project.addGithubPublishing(
|
||||
}
|
||||
|
||||
internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping space publishing because publishing is disabled")
|
||||
val spaceUser: String? = requestPropertyOrNull("publishing.space.user")
|
||||
val spaceToken: String? = requestPropertyOrNull("publishing.space.token")
|
||||
|
||||
if (spaceUser == null || spaceToken == null) {
|
||||
logger.info("Skipping Space publishing because Space credentials are not defined")
|
||||
return
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.space") == "false") {
|
||||
logger.info("Skipping space publishing because `publishing.space == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val spaceUser: String = requestProperty("publishing.space.user")
|
||||
val spaceToken: String = requestProperty("publishing.space.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
project.logger.info("Adding SPC Space publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
@ -181,24 +172,19 @@ internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||
}
|
||||
|
||||
internal fun Project.addSonatypePublishing() {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping sonatype publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
if (isInDevelopment) {
|
||||
logger.info("Sonatype publishing skipped for development version")
|
||||
return
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.sonatype") == "false") {
|
||||
logger.info("Skipping sonatype publishing because `publishing.sonatype == false`")
|
||||
val sonatypeUser: String? = requestPropertyOrNull("publishing.sonatype.user")
|
||||
val sonatypePassword: String? = requestPropertyOrNull("publishing.sonatype.password")
|
||||
|
||||
if (sonatypeUser == null || sonatypePassword == null) {
|
||||
logger.info("Skipping Sonatype publishing because Sonatype credentials are not defined")
|
||||
return
|
||||
}
|
||||
|
||||
val sonatypeUser: String = requestProperty("publishing.sonatype.user")
|
||||
val sonatypePassword: String = requestProperty("publishing.sonatype.password")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
|
Loading…
Reference in New Issue
Block a user