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

feat: add jpms support with module-info.java #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ target
build
/kotlinx-collections-immutable/dependency-reduced-pom.xml
/benchmarks-runner/benchmarkResults
/benchmarks-runner/localReferenceBenchmarkResults
/benchmarks-runner/localReferenceBenchmarkResults
kotlin-js-store/
.kotlin/
9 changes: 7 additions & 2 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
@file:OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)

import BuildConventions.baseConventions
import kotlinx.benchmark.gradle.JvmBenchmarkTarget
import org.gradle.jvm.tasks.Jar

plugins {
id("kotlin-multiplatform")
`kotlin-multiplatform`
id("org.jetbrains.kotlinx.benchmark") version "0.4.10"
}


evaluationDependsOn(":kotlinx-collections-immutable")

kotlin {
Expand Down Expand Up @@ -105,6 +107,9 @@ benchmark {
}
}

// configure baseline conventions
baseConventions()

val benchmarksJar: Configuration by configurations.creating

afterEvaluate {
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/gradle.lockfile

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions benchmarks/runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation 'org.openjdk.jmh:jmh-core:1.21'
implementation libs.kotlin.stdlib
implementation libs.jmh.core
Comment on lines -6 to +7
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General build cleanup: moved dependencies to a version catalog.


runtimeOnly project(path: ':benchmarks', configuration: 'benchmarksJar')
runtimeOnly project(path: ':kotlinx-collections-immutable')
Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ allprojects {

tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
}

dependencyLocking {
lockAllConfigurations()
}
Comment on lines +50 to +52
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency locking and verification were activated, but kept in lenient mode for now, to account for native dependency shift in CI.

67 changes: 67 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* 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.*
import java.io.FileInputStream

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
mavenLocal()
if (project.hasProperty("kotlin_repo_url")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the nullable findProperty method to check and retrieve property. The properties property performs a copy of the underlying map.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, although this block wasn't supposed to make it in at all; I'll drop

maven(project.properties["kotlin_repo_url"] as String)
}
// kotlin-dev with space redirector
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
}

val kotlinVersion = run {
if (project.hasProperty("build_snapshot_train")) {
val ver = project.properties["kotlin_snapshot_version"] as? String
require(!ver.isNullOrBlank()) {"kotlin_snapshot_version must be present if build_snapshot_train is used" }
return@run ver
}
if (project.hasProperty("kotlin_repo_url")) {
val ver = project.properties["kotlin_version"] as? String
require(!ver.isNullOrBlank()) {"kotlin_version must be present if kotlin_repo_url is used" }
return@run ver
}
val targetProp = if (project.hasProperty("bootstrap")) "kotlin.version.snapshot" else "kotlin.version"
FileInputStream(file("../gradle.properties")).use { propFile ->
val ver = project.findProperty("kotlin.version")?.toString() ?: Properties().apply { load(propFile) }[targetProp]
require(ver is String) { "$targetProp must be string in ../gradle.properties, got $ver instead" }
ver
}
}

dependencyLocking {
lockAllConfigurations()
}

listOf(
Jar::class,
Zip::class,
Tar::class,
).forEach {
tasks.withType(it).configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true

when(this) {
is Zip -> isZip64 = true
}
}
}

dependencies {
implementation(kotlin("gradle-plugin", kotlinVersion))

// fix from the Gradle team: makes version catalog symbols available in build scripts
// see here for more: https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
48 changes: 48 additions & 0 deletions buildSrc/gradle.lockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
org.jetbrains.intellij.deps:trove4j:1.0.20200330=buildScriptClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-android-extensions:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-assignment-compiler-plugin-embeddable:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-build-common:1.9.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-api:1.9.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-api:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-build-tools-impl:1.9.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.20=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-compiler-runner:1.9.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-compiler-runner:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-daemon-client:1.9.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-client:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.20=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.9.20=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-native-utils:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-project-model:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-reflect:1.9.20=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-script-runtime:1.9.20=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-common:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.20=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.22=buildScriptClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.9.20=compileClasspath,compileOnlyDependenciesMetadata,embeddedKotlin,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-tooling-core:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-util-io:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-util-klib:1.9.22=buildScriptClasspath,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=buildScriptClasspath,kotlinBuildToolsApiClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,embeddedKotlin,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor,apiDependenciesMetadata,intransitiveDependenciesMetadata,kotlinCompilerPluginClasspath,kotlinNativeCompilerPluginClasspath,kotlinScriptDef,kotlinScriptDefExtensions,testAnnotationProcessor,testApiDependenciesMetadata,testCompileOnlyDependenciesMetadata,testIntransitiveDependenciesMetadata,testKotlinScriptDef,testKotlinScriptDefExtensions
8 changes: 8 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
58 changes: 58 additions & 0 deletions buildSrc/src/main/kotlin/BuildConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.bundling.Tar
import org.gradle.api.tasks.bundling.Zip
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType

// Static dependency pins.
val pinnedDependencies = mapOf<String, LibrariesForLibs.() -> Provider<String>>(
"org.jetbrains.kotlin:kotlin-stdlib" to { versions.kotlin.sdk },
"org.jetbrains.kotlin:kotlin-stdlib-common" to { versions.kotlin.sdk },
)

object BuildConventions {
fun Project.baseConventions() {
val libs = the<LibrariesForLibs>()

// enable dependency locking
dependencyLocking {
lockAllConfigurations()
}

listOf(
Jar::class,
Zip::class,
Tar::class,
).forEach {
tasks.withType(it).configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true

when(this) {
is Zip -> isZip64 = true
}
}
}

// pin dependencies which are critical transitively
configurations.all {
resolutionStrategy {
eachDependency {
val coordinate = "${requested.module.group}:${requested.module.name}"
pinnedDependencies[coordinate]?.let { pin ->
useVersion(pin.invoke(libs).get())
because("pinned dependency")
}
}
}
}
}
}