Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Gradle build logic #258

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 25 additions & 46 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Build_gradle.MavenPomFile
import kotlinx.html.js.packageJson
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

Expand All @@ -11,19 +9,12 @@ plugins {
kotlin("multiplatform") version "1.9.22"
id("maven-publish")
id("signing")
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
}

group = "org.jetbrains.kotlinx"
version = "0.11.0"

buildscript {
dependencies {
classpath("org.jetbrains.kotlinx:binary-compatibility-validator:0.13.2")
}
}

apply(plugin = "binary-compatibility-validator")

/**
* If "release" profile is used the "-SNAPSHOT" suffix of the version is removed.
*/
Expand Down Expand Up @@ -85,7 +76,7 @@ kotlin {
jvm {
mavenPublication {
groupId = group as String
pom { name by "${project.name}-jvm" }
pom { name = "${project.name}-jvm" }

artifact(emptyJar) {
classifier = "javadoc"
Expand All @@ -104,7 +95,7 @@ kotlin {

mavenPublication {
groupId = group as String
pom { name by "${project.name}-js" }
pom { name = "${project.name}-js" }
}
}
@OptIn(ExperimentalWasmDsl::class)
Expand All @@ -114,7 +105,7 @@ kotlin {

mavenPublication {
groupId = group as String
pom { name by "${project.name}-wasm-js" }
pom { name = "${project.name}-wasm-js" }
}
}

Expand Down Expand Up @@ -151,7 +142,7 @@ kotlin {
groupId = group as String
artifactId = "${project.name}-common"
pom {
name by "${project.name}-common"
name = "${project.name}-common"
}
}
}
Expand All @@ -161,22 +152,15 @@ kotlin {
jvmToolchain(8)

sourceSets {
commonMain {
dependencies {
implementation(kotlin("stdlib"))
}
}

commonTest {
dependencies {
implementation(kotlin("test"))
}
}

}
}

tasks.withType<Jar> {
tasks.withType<Jar>().configureEach {
manifest {
attributes += sortedMapOf(
"Built-By" to System.getProperty("user.name"),
Expand Down Expand Up @@ -221,46 +205,42 @@ typealias MavenPomFile = MavenPom
fun MavenPomFile.config(config: MavenPomFile.() -> Unit = {}) {
config()

url by "https://github.com/Kotlin/kotlinx.html"
name by "kotlinx.html"
description by "A kotlinx.html library provides DSL to build HTML to Writer/Appendable or DOM at JVM and browser (or other JavaScript engine) for better Kotlin programming for Web."
url = "https://github.com/Kotlin/kotlinx.html"
name = "kotlinx.html"
description = "A kotlinx.html library provides DSL to build HTML to Writer/Appendable or DOM at JVM and browser (or other JavaScript engine) for better Kotlin programming for Web."

licenses {
license {
name by "The Apache License, Version 2.0"
url by "https://www.apache.org/licenses/LICENSE-2.0.txt"
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}

scm {
connection by "scm:git:git@github.com:Kotlin/kotlinx.html.git"
url by "https://github.com/Kotlin/kotlinx.html"
tag by "HEAD"
connection = "scm:git:git@github.com:Kotlin/kotlinx.html.git"
url = "https://github.com/Kotlin/kotlinx.html"
tag = "HEAD"
}

developers {
developer {
name by "Sergey Mashkov"
organization by "JetBrains s.r.o."
name = "Sergey Mashkov"
organization = "JetBrains s.r.o."
roles to "developer"
}

developer {
name by "Anton Dmitriev"
organization by "JetBrains s.r.o."
name = "Anton Dmitriev"
organization = "JetBrains s.r.o."
roles to "developer"
}
}
}

tasks.withType<GenerateModuleMetadata> {
tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = true
}

infix fun <T> Property<T>.by(value: T) {
set(value)
}

val signingKey = System.getenv("SIGN_KEY_ID")
val signingKeyPassphrase = System.getenv("SIGN_KEY_PASSPHRASE")

Expand All @@ -274,14 +254,13 @@ if (!signingKey.isNullOrBlank()) {
}
}

rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
val nodeM1Version = "16.13.1"
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = nodeM1Version
}

rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
}

tasks.getByName("jsBrowserTest").dependsOn("wasmJsTestTestDevelopmentExecutableCompileSync")
tasks.getByName("wasmJsBrowserTest").dependsOn("jsTestTestDevelopmentExecutableCompileSync")
tasks.named("jsBrowserTest") {
dependsOn("wasmJsTestTestDevelopmentExecutableCompileSync")
}
tasks.named("wasmJsBrowserTest") {
dependsOn("jsTestTestDevelopmentExecutableCompileSync")
}
5 changes: 2 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
plugins {
kotlin("jvm") version "1.9.21"
`kotlin-dsl`
}

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib"))
implementation("com.sun.xsom:xsom:20140925")
implementation("com.squareup:kotlinpoet:1.15.3")
}
}
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# The following property is required to mitigate issue https://github.com/gradle/gradle/issues/11412.
systemProp.org.gradle.internal.publish.checksums.insecure=true
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Expand Down