-
Notifications
You must be signed in to change notification settings - Fork 20
Enable Gradle Isolated Projects #1680
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
Draft
kaeawc
wants to merge
9
commits into
main
Choose a base branch
from
jp/gradle-isolated-projects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
58d6b33
enabled gradle isolated projects and resolved all issues
kaeawc 5255e83
updated docs mentioning spotless and isolated projects flag
kaeawc 8580fb4
fixing some of the lint warnings
kaeawc 43e06f3
found way to use git rev-parse HEAD and added tests
kaeawc 76c080c
fix how we publish artifacts
kaeawc c045b74
use the correct flag for disabling isolated projects
kaeawc d75cb88
read version catalog instead of hardcoding jvm target
kaeawc 79e6eee
use version catalog for ktfmt version
kaeawc 9a979c8
update code formatting
kaeawc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright (C) 2022 Slack Technologies, LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| plugins { `kotlin-dsl` } | ||
|
|
||
| dependencies { | ||
| // Plugin dependencies - these become available in convention plugins | ||
| implementation(libs.gradlePlugins.spotless) | ||
| implementation(libs.gradlePlugins.kgp) | ||
| implementation(libs.gradlePlugins.detekt) | ||
| implementation(libs.gradlePlugins.sortDependencies) | ||
| // SAM with receiver plugin for Gradle plugin projects | ||
| implementation("org.jetbrains.kotlin:kotlin-sam-with-receiver:${libs.versions.kotlin.get()}") | ||
| // Note: Dokka and MavenPublish are applied via plugins block, not as dependencies | ||
|
|
||
| testImplementation(libs.junit) | ||
| testImplementation(libs.truth) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright (C) 2022 Slack Technologies, LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| rootProject.name = "build-logic" | ||
|
|
||
| dependencyResolutionManagement { | ||
| versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } } | ||
| repositories { | ||
| mavenCentral() | ||
| google() | ||
| gradlePluginPortal() | ||
| } | ||
| } |
83 changes: 83 additions & 0 deletions
83
build-logic/src/main/kotlin/foundry.kotlin-jvm-gradle.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Copyright (C) 2022 Slack Technologies, LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import io.gitlab.arturbosch.detekt.Detekt | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask | ||
| import org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension | ||
|
|
||
| plugins { | ||
| id("org.jetbrains.kotlin.jvm") | ||
| id("org.jetbrains.kotlin.plugin.sam.with.receiver") | ||
| id("com.squareup.sort-dependencies") | ||
| } | ||
|
|
||
| val catalog = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
| val jvmTargetVersion = catalog.findVersion("jvmTarget").get().toString().let { JvmTarget.fromTarget(it) } | ||
| val jdkVersion = catalog.findVersion("jdk").get().toString().toInt() | ||
|
|
||
| extensions.configure<KotlinJvmProjectExtension> { explicitApi() } | ||
|
|
||
| extensions.configure<SamWithReceiverExtension> { | ||
| annotation("org.gradle.api.HasImplicitReceiver") | ||
| } | ||
|
|
||
| extensions.configure<JavaPluginExtension> { | ||
| toolchain { languageVersion.set(JavaLanguageVersion.of(jdkVersion)) } | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile>().configureEach { | ||
| options.release.set(jvmTargetVersion.target.toInt()) | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompilationTask<*>>().configureEach { | ||
| compilerOptions { | ||
| languageVersion.set(KotlinVersion.KOTLIN_2_2) | ||
| apiVersion.set(KotlinVersion.KOTLIN_2_2) | ||
| // Gradle forces older Kotlin, which results in warnings | ||
| allWarningsAsErrors.set(false) | ||
|
|
||
| check(this is KotlinJvmCompilerOptions) | ||
| this.jvmTarget.set(jvmTargetVersion) | ||
| jvmDefault.set(org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode.NO_COMPATIBILITY) | ||
| freeCompilerArgs.addAll( | ||
| // Required due to https://github.com/gradle/gradle/issues/24871 | ||
| "-Xsam-conversions=class", | ||
| "-Xlambdas=class", | ||
| "-Xenhance-type-parameter-types-to-def-not-null", | ||
| "-Xjsr305=strict", | ||
| "-Xassertions=jvm", | ||
| "-Xemit-jvm-type-annotations", | ||
| "-Xtype-enhancement-improvements-strict-mode", | ||
| "-Xjspecify-annotations=strict", | ||
| "-Xannotation-default-target=param-property", | ||
| "-Xjdk-release=${jvmTargetVersion.target}", | ||
| ) | ||
| optIn.addAll( | ||
| "kotlin.contracts.ExperimentalContracts", | ||
| "kotlin.experimental.ExperimentalTypeInference", | ||
| "kotlin.ExperimentalStdlibApi", | ||
| "kotlin.time.ExperimentalTime", | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Configure Detekt jvmTarget when Detekt plugin is applied | ||
| pluginManager.withPlugin("io.gitlab.arturbosch.detekt") { | ||
| tasks.withType<Detekt>().configureEach { jvmTarget = jvmTargetVersion.target } | ||
| } |
74 changes: 74 additions & 0 deletions
74
build-logic/src/main/kotlin/foundry.kotlin-jvm-intellij.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Copyright (C) 2022 Slack Technologies, LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import io.gitlab.arturbosch.detekt.Detekt | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask | ||
|
|
||
| plugins { | ||
| id("org.jetbrains.kotlin.jvm") | ||
| id("com.squareup.sort-dependencies") | ||
| } | ||
|
|
||
| val catalog = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
| val jvmTargetVersion = catalog.findVersion("jvmTargetIdea").get().toString().let { JvmTarget.fromTarget(it) } | ||
| val jdkVersion = catalog.findVersion("jdk").get().toString().toInt() | ||
|
|
||
| // Note: No explicit API for IntelliJ plugins | ||
|
|
||
| extensions.configure<JavaPluginExtension> { | ||
| toolchain { languageVersion.set(JavaLanguageVersion.of(jdkVersion)) } | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile>().configureEach { | ||
| options.release.set(jvmTargetVersion.target.toInt()) | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompilationTask<*>>().configureEach { | ||
| compilerOptions { | ||
| // https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library | ||
| languageVersion.set(KotlinVersion.KOTLIN_2_0) | ||
| apiVersion.set(KotlinVersion.KOTLIN_2_0) | ||
| // IntelliJ forces older Kotlin, which results in warnings | ||
| allWarningsAsErrors.set(false) | ||
|
|
||
| check(this is KotlinJvmCompilerOptions) | ||
| this.jvmTarget.set(jvmTargetVersion) | ||
| jvmDefault.set(org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode.NO_COMPATIBILITY) | ||
| freeCompilerArgs.addAll( | ||
| "-Xenhance-type-parameter-types-to-def-not-null", | ||
| "-Xjsr305=strict", | ||
| "-Xassertions=jvm", | ||
| "-Xemit-jvm-type-annotations", | ||
| "-Xtype-enhancement-improvements-strict-mode", | ||
| "-Xjspecify-annotations=strict", | ||
| "-Xannotation-default-target=param-property", | ||
| "-Xjdk-release=${jvmTargetVersion.target}", | ||
| ) | ||
| optIn.addAll( | ||
| "kotlin.contracts.ExperimentalContracts", | ||
| "kotlin.experimental.ExperimentalTypeInference", | ||
| "kotlin.ExperimentalStdlibApi", | ||
| "kotlin.time.ExperimentalTime", | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Configure Detekt jvmTarget when Detekt plugin is applied | ||
| pluginManager.withPlugin("io.gitlab.arturbosch.detekt") { | ||
| tasks.withType<Detekt>().configureEach { jvmTarget = jvmTargetVersion.target } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Copyright (C) 2022 Slack Technologies, LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import io.gitlab.arturbosch.detekt.Detekt | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask | ||
|
|
||
| plugins { | ||
| id("org.jetbrains.kotlin.jvm") | ||
| id("com.squareup.sort-dependencies") | ||
| } | ||
|
|
||
| val catalog = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
| val jvmTargetVersion = catalog.findVersion("jvmTarget").get().toString().let { JvmTarget.fromTarget(it) } | ||
| val jdkVersion = catalog.findVersion("jdk").get().toString().toInt() | ||
|
|
||
| extensions.configure<KotlinJvmProjectExtension> { explicitApi() } | ||
|
|
||
| extensions.configure<JavaPluginExtension> { | ||
| toolchain { languageVersion.set(JavaLanguageVersion.of(jdkVersion)) } | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile>().configureEach { | ||
| options.release.set(jvmTargetVersion.target.toInt()) | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompilationTask<*>>().configureEach { | ||
| compilerOptions { | ||
| languageVersion.set(KotlinVersion.DEFAULT) | ||
| apiVersion.set(KotlinVersion.DEFAULT) | ||
| allWarningsAsErrors.set(true) | ||
|
|
||
| check(this is KotlinJvmCompilerOptions) | ||
| this.jvmTarget.set(jvmTargetVersion) | ||
| jvmDefault.set(org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode.NO_COMPATIBILITY) | ||
| freeCompilerArgs.addAll( | ||
| "-Xenhance-type-parameter-types-to-def-not-null", | ||
| "-Xjsr305=strict", | ||
| "-Xassertions=jvm", | ||
| "-Xemit-jvm-type-annotations", | ||
| "-Xtype-enhancement-improvements-strict-mode", | ||
| "-Xjspecify-annotations=strict", | ||
| "-Xannotation-default-target=param-property", | ||
| "-Xjdk-release=${jvmTargetVersion.target}", | ||
| ) | ||
| optIn.addAll( | ||
| "kotlin.contracts.ExperimentalContracts", | ||
| "kotlin.experimental.ExperimentalTypeInference", | ||
| "kotlin.ExperimentalStdlibApi", | ||
| "kotlin.time.ExperimentalTime", | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Configure Detekt jvmTarget when Detekt plugin is applied | ||
| pluginManager.withPlugin("io.gitlab.arturbosch.detekt") { | ||
| tasks.withType<Detekt>().configureEach { jvmTarget = jvmTargetVersion.target } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: copyrights are wrong for a lot of these