-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the nullable There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
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") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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.