Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions html/eap/compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

import java.util.Properties

plugins {
kotlin("jvm")
}

val pluginProperties = Properties().apply {
file("plugin.properties").inputStream().use(::load)
}
val kotlinVersion = Properties().apply {
rootProject.file("buildSrc/gradle.properties").inputStream().use(::load)
}.getProperty("kotlin.version")
val eapVersion = providers.gradleProperty("compose.html.eap.version").get()

group = "org.jetbrains.compose.html"
version = pluginProperties.getProperty("version")
version = eapVersion

val compilerPluginPath = path
subprojects {
Expand All @@ -38,7 +31,7 @@ java {

dependencies {
implementation(project(":internal-html-serialization-eap"))
compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
compileOnly(kotlin("compiler-embeddable"))
}

publishing {
Expand Down
70 changes: 58 additions & 12 deletions html/eap/compiler-plugin/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,67 @@
*/

import java.util.Properties
import org.gradle.api.publish.maven.MavenPublication
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm")
`java-gradle-plugin`
`maven-publish`
alias(libs.plugins.buildTimeConfig)
}

val pluginProperties = Properties().apply {
file("../plugin.properties").inputStream().use(::load)
val htmlRootDir = rootProject.projectDir.resolve("../../..").normalize()
val htmlGradleProperties = Properties().apply {
htmlRootDir.resolve("gradle.properties").inputStream().use(::load)
}
val kotlinVersion = Properties().apply {
file("../../../buildSrc/gradle.properties").inputStream().use(::load)
}.getProperty("kotlin.version")
val eapVersion = providers.gradleProperty("compose.html.eap.version").orNull
?: htmlGradleProperties.getProperty("compose.html.eap.version")
?: error("compose.html.eap.version must be set")

group = "org.jetbrains.compose.html"
version = pluginProperties.getProperty("version")
version = eapVersion

repositories {
mavenCentral()
}

val composeRepoUrl = providers.gradleProperty("COMPOSE_REPO_URL").orNull
?: System.getenv("COMPOSE_REPO_URL")
?: "https://packages.jetbrains.team/maven/p/cmp/dev"
val composeRepoUsername = providers.gradleProperty("COMPOSE_REPO_USERNAME").orNull
?: System.getenv("COMPOSE_REPO_USERNAME")
?: ""
val composeRepoKey = providers.gradleProperty("COMPOSE_REPO_KEY").orNull
?: System.getenv("COMPOSE_REPO_KEY")
?: ""

publishing {
publications.withType<MavenPublication>().configureEach {
pom {
name.set("Compose HTML lowering Gradle plugin")
description.set("Gradle plugin for the Compose HTML compiler plugin")
url.set("https://www.jetbrains.com/lp/compose-mpp/")
licenses {
license {
name.set("Apache-2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
repositories {
maven {
name = "internal"
url = uri(composeRepoUrl)
credentials {
username = composeRepoUsername
password = composeRepoKey
}
}
}
}

// The HTML root build targets JVM 11. Gradle requires Java to use the same target.
java {
sourceCompatibility = JavaVersion.VERSION_11
Expand All @@ -38,15 +78,15 @@ kotlin {
}

dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlinVersion")
testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
compileOnly(kotlin("gradle-plugin-api"))
testImplementation(kotlin("gradle-plugin"))
testImplementation(kotlin("test-junit"))
}

gradlePlugin {
plugins {
create("htmlLowering") {
id = pluginProperties.getProperty("id")
id = "org.jetbrains.compose.html.lowering"
implementationClass = "org.jetbrains.compose.html.gradle.HtmlLoweringGradlePlugin"
}
}
Expand All @@ -57,7 +97,13 @@ tasks.test {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
}

// The plugin needs its coordinates after it has been packaged and installed elsewhere.
tasks.processResources {
from("../plugin.properties") { rename { "compose-html-lowering.properties" } }
buildTimeConfig {
config {
packageName.set("org.jetbrains.compose.html.gradle")
objectName.set("BuildTimeConfig")
destination.set(layout.buildDirectory.dir("generated/buildTimeConfig").get().asFile)
configProperties {
val compilerPluginVersion: String by string(eapVersion)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]
build-time-config = "2.3.1"

[plugins]
buildTimeConfig = { id = "dev.limebeck.build-time-config", version.ref = "build-time-config" }
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption

private val pluginProperties = java.util.Properties().apply {
requireNotNull(HtmlLoweringGradlePlugin::class.java.getResourceAsStream("/compose-html-lowering.properties")) {
"Missing Compose HTML lowering plugin metadata"
}.use(::load)
}

/** Adds the HTML compiler plugin and the `htmlLowering` configuration. */
class HtmlLoweringGradlePlugin : KotlinCompilerPluginSupportPlugin {
override fun apply(target: Project) {
Expand All @@ -30,12 +24,12 @@ class HtmlLoweringGradlePlugin : KotlinCompilerPluginSupportPlugin {
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
kotlinCompilation.platformType != KotlinPlatformType.common

override fun getCompilerPluginId() = pluginProperties.getProperty("id")
override fun getCompilerPluginId() = "org.jetbrains.compose.html.lowering"

override fun getPluginArtifact() = SubpluginArtifact(
groupId = "org.jetbrains.compose.html",
artifactId = "compose-html-compiler-plugin",
version = pluginProperties.getProperty("version")
version = BuildTimeConfig.compilerPluginVersion
)

override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
Expand Down
2 changes: 0 additions & 2 deletions html/eap/compiler-plugin/plugin.properties

This file was deleted.

10 changes: 3 additions & 7 deletions html/eap/compiler-plugin/tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)

import java.util.Properties
import org.gradle.api.tasks.bundling.Jar
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest

Expand All @@ -21,9 +20,6 @@ val compilerPluginClasspath = files(compilerJar, compilerProject.configurations.

val composeVersion = providers.gradleProperty("compose.version").get()
val browserVersion = providers.gradleProperty("compose.html.eap.kotlinx-browser-common-subset.version").get()
val kotlinVersion = Properties().apply {
rootProject.file("buildSrc/gradle.properties").inputStream().use(::load)
}.getProperty("kotlin.version")

kotlin {
jvm { compilerOptions { freeCompilerArgs.add("-Xverify-ir=error") } }
Expand All @@ -40,11 +36,11 @@ kotlin {
implementation("org.jetbrains.compose.html:kotlinx-browser-common-subset:$browserVersion")
}
jvmTest.dependencies {
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable:$kotlinVersion")
implementation(kotlin("compiler-embeddable"))
implementation(kotlin("compose-compiler-plugin-embeddable"))
}
val webTest by getting {
dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC") }
dependencies { implementation(libs.kotlinx.coroutines.core) }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion html/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencyResolutionManagement {
}
versionCatalogs {
create("libs") {
library("kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC")
library("kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
library("kotlinx-browser", "org.jetbrains.kotlinx:kotlinx-browser:0.5.0")
}
}
Expand Down
Loading