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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle/
.kotlin/
.theia/
.yarn/
.yarnrc
Expand Down
11 changes: 2 additions & 9 deletions build-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ plugins {
dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))

implementation(kotlin("gradle-plugin", embeddedKotlinVersion))
implementation(libs.plugin.kotlin)
implementation(libs.plugin.git.hooks)
implementation(libs.plugin.detekt)
implementation(libs.plugin.versions)
implementation(libs.plugin.versions.update)
implementation(libs.plugin.container.tasks)
}

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
}
14 changes: 8 additions & 6 deletions build-conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
plugins {
id("com.gradle.enterprise") version "+"
id("com.gradle.develocity") version "+"
}

develocity {
buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
repositories {
mavenLocal()
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion build-conventions/src/main/kotlin/util/global.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ infix fun <T> Property<T>.by(value: Provider<T>) = set(value)

object Git {
val headCommitHash by lazy {
val child = Runtime.getRuntime().exec("git rev-parse --verify HEAD")
val child = Runtime.getRuntime().exec(arrayOf("git","rev-parse", "--verify","HEAD"))
child.waitFor()
child.inputStream.readAllBytes().toString(Charset.defaultCharset()).trim()
}
Expand Down
7 changes: 0 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ nexusPublishing {
}
}
}

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
detekt = "1.23.4"
dokka = "1.9.10"
detekt = "1.23.6"
dokka = "1.9.20"
java = "11"
junit-jupiter = "5.10.1"
kotest = "5.8.0"
junit-jupiter = "5.10.2"
kotest = "5.9.1"
kotlin = "2.0.0"

[libraries]
Expand All @@ -16,7 +16,7 @@ plugin-container-tasks = "dev.petuska:container-tasks-gradle-plugin:0.0.4"
plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
plugin-git-hooks = "com.github.jakemarsden:git-hooks-gradle-plugin:0.0.2"
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
plugin-node-gradle = "com.github.node-gradle:gradle-node-plugin:7.0.1"
plugin-node-gradle = "com.github.node-gradle:gradle-node-plugin:7.0.2"
plugin-versions = "com.github.ben-manes:gradle-versions-plugin:0.47.0"
plugin-versions-update = "nl.littlerobots.vcu:plugin:0.8.1"

Expand All @@ -28,5 +28,5 @@ kotest-assertions = [

[plugins]
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
nexus-publish = "io.github.gradle-nexus.publish-plugin:1.3.0"
nexus-publish = "io.github.gradle-nexus.publish-plugin:2.0.0"
plugin-publish = "com.gradle.plugin-publish:1.2.1"
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 6 additions & 6 deletions npm-publish-docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ plugins {

tasks {
val src = projectDir.resolve("src")
val mkdocsDir = buildDir.resolve("mkdocs")
val outDir = mkdocsDir.resolve("site")
val mkdocsDir = layout.buildDirectory.dir("mkdocs")
val outDir = mkdocsDir.map { it.dir("site") }
val dokkaHtml = getByPath(":npm-publish-gradle-plugin:dokkaHtml")
val docsAssemble = register("docsAssemble", Copy::class) {
dependsOn(dokkaHtml)
outputs.upToDateWhen { false }
destinationDir = mkdocsDir.resolve("source").also(outputs::dir)
destinationDir = mkdocsDir.map { it.dir("source") }.get().asFile.also(outputs::dir)
val readme = rootDir.resolve("README.md").also(inputs::file)
val license = rootDir.resolve("LICENSE").also(inputs::file)
val changelog = rootDir.resolve("CHANGELOG.md").also(inputs::file)
Expand Down Expand Up @@ -47,7 +47,7 @@ tasks {
mapOf(
"srcDir" to srcDir.absolutePath,
"themeDir" to themeDir.absolutePath,
"outDir" to outDir.absolutePath,
"outDir" to outDir.get().asFile.absolutePath,
)
)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ tasks {
register("mkdocsBuild", MkDocsExec.Build::class) {
dependsOn(docsAssemble)
workingDir.set(layout.dir(docsAssemble.map { it.destinationDir }))
containerVolumes.put(outDir, outDir)
containerVolumes.put(outDir.get().asFile, outDir.get().asFile)
outputs.dir(outDir)
}
register("mikeList", MikeExec.List::class) {
Expand Down Expand Up @@ -114,6 +114,6 @@ tasks {
workingDir.set(layout.dir(docsAssemble.map { it.destinationDir }))
}
register("clean", Delete::class) {
delete(buildDir)
delete(layout.buildDirectory)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,21 @@ internal fun Project.configure(target: KotlinJsTargetDsl): Unit = with(PluginLog
}

null -> null
!is JsIrBinary -> error(
"Legacy binaries are no longer supported. " +
"Please consider switching to the new Kotlin/JS IR compiler backend"
)

else -> error("Unrecognised Kotlin/JS binary type: ${it::class.java.name}")
}
}
val compileKotlinTask = binary.flatMap<Kotlin2JsCompile>(JsIrBinary::linkTask)
val publicPackageJsonTask = binary.flatMap {
tasks.named<PublicPackageJsonTask>(it.compilation.npmProject.publicPackageJsonTaskName)
}
val processResourcesTask = target.compilations.named("main").flatMap {
val mainCompilation = target.compilations.named("main")
val processResourcesTask = mainCompilation.flatMap {
tasks.named<Copy>(it.processResourcesTaskName)
}
val outputFile = compileKotlinTask.flatMap(Kotlin2JsCompile::destinationDirectory)
.zip(compileKotlinTask.flatMap(Kotlin2JsCompile::moduleName)) { dir, file -> dir.file(file).asFile }

val outputFile = binary.flatMap(JsIrBinary::mainFile)
val typesFile = outputFile.map {
it.parentFile.resolve("${it.nameWithoutExtension}.d.ts")
it.asFile.parentFile.resolve("${it.asFile.nameWithoutExtension}.d.ts")
}

tasks.named(assembleTaskName(pkg.name), NpmAssembleTask::class.java) {
Expand All @@ -84,7 +80,7 @@ internal fun Project.configure(target: KotlinJsTargetDsl): Unit = with(PluginLog
pkg.main.convention(
sysProjectEnvPropertyConvention(
pkg.prefix + "main",
outputFile.map { it.name }.orElse(pkg.packageJson.flatMap(PackageJson::main))
outputFile.map { it.asFile.name }.orElse(pkg.packageJson.flatMap(PackageJson::main))
)
)
pkg.types.convention(
Expand All @@ -96,7 +92,7 @@ internal fun Project.configure(target: KotlinJsTargetDsl): Unit = with(PluginLog
)
pkg.dependencies.addAllLater(resolveDependencies(target.name, binary))
pkg.files { files ->
files.from(outputFile.map(File::getParentFile))
files.from(outputFile.map { it.asFile.getParentFile() })
files.from(processResourcesTask.map(Copy::getDestinationDir))
}
}
Expand All @@ -117,24 +113,30 @@ private fun Project.resolveDependencies(
targetName: String,
binary: Provider<JsIrBinary>
): Provider<List<NpmDependency>> = binary.map { bin ->
bin.compilation.relatedConfigurationNames().flatMap { conf ->
listOf(
conf,
"${targetName}Main${conf.substringAfter("${targetName}Compilation").capitalized()}",
conf.substringAfter("compilation").toCamelCase(true),
).mapNotNull(configurations::findByName).flatMap(Configuration::getDependencies)
.filterIsInstance<KJsNpmDependency>().distinct().map { dependency ->
objects.newInstance(NpmDependency::class.java, dependency.name).apply {
type.set(
when (dependency.scope) {
NORMAL -> NpmDependency.Type.NORMAL
DEV -> NpmDependency.Type.DEV
OPTIONAL -> NpmDependency.Type.OPTIONAL
PEER -> NpmDependency.Type.PEER
}
)
version.set(dependency.version)
}
}
}
bin.compilation
.relatedConfigurationNames()
.flatMap { conf ->
sequenceOf(
conf,
"${targetName}Main${conf.substringAfter("${targetName}Compilation").capitalized()}",
conf.substringAfter("compilation").toCamelCase(true),
)
.mapNotNull(configurations::findByName)
.flatMap(Configuration::getDependencies)
.filterIsInstance<KJsNpmDependency>()
.distinct()
.map { dependency ->
objects.newInstance(NpmDependency::class.java, dependency.name).apply {
type.set(
when (dependency.scope) {
NORMAL -> NpmDependency.Type.NORMAL
DEV -> NpmDependency.Type.DEV
OPTIONAL -> NpmDependency.Type.OPTIONAL
PEER -> NpmDependency.Type.PEER
}
)
version.set(dependency.version)
}
}.toList()
}
}
8 changes: 1 addition & 7 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
plugins {
id("convention.base")
id("convention.versions")
}

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
9 changes: 8 additions & 1 deletion samples/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
plugins {
id("com.gradle.enterprise") version "+"
id("com.gradle.develocity") version "+"
}

develocity {
buildScan{
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
}
}

@Suppress("UnstableApiUsage")
Expand Down
7 changes: 0 additions & 7 deletions sandbox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
plugins {
id("convention.base")
}

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
1 change: 1 addition & 0 deletions sandbox/empty/src/jsMain/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import sandbox.greet
@JsModule("is-odd")
external object IsOdd

@OptIn(ExperimentalJsExport::class)
@JsExport
fun empty() = greet(object : GreetingArgs {
override val name: String = "Joe"
Expand Down
9 changes: 8 additions & 1 deletion sandbox/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
plugins {
id("com.gradle.enterprise") version "+"
id("com.gradle.develocity") version "+"
}

develocity {
buildScan{
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
}
}

@Suppress("UnstableApiUsage")
Expand Down
9 changes: 8 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
plugins {
id("com.gradle.enterprise") version "+"
id("com.gradle.develocity") version "+"
}

develocity {
buildScan{
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
}
}

@Suppress("UnstableApiUsage")
Expand Down