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

Minor Gradle tweaks #119

Merged
merged 10 commits into from
Aug 11, 2024
59 changes: 56 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension
import org.jetbrains.intellij.platform.gradle.extensions.intellijPlatform
import org.jetbrains.intellij.platform.gradle.plugins.project.IntelliJPlatformBasePlugin
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin

plugins {
alias(libs.plugins.android.application) apply false
Expand All @@ -15,20 +20,60 @@ allprojects {
group = rootProject.providers.gradleProperty("GROUP").get()
version = rootProject.providers.gradleProperty("VERSION_NAME").get()

plugins.withType<KotlinBasePlugin>().configureEach {
dependencies {
// https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
"compileOnly"(libs.kotlin.stdlib)
}
}

plugins.withId(rootProject.libs.plugins.kotlin.compose.get().pluginId) {
extensions.configure<ComposeCompilerGradlePluginExtension> {
enableStrongSkippingMode = true
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
}

plugins.withType<IntelliJPlatformBasePlugin>().configureEach {
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#configuration.repositories
repositories {
google {
mavenContent {
includeGroupAndSubgroups("androidx")
includeGroupAndSubgroups("com.android")
includeGroupAndSubgroups("com.google")
}
}
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#setting-up-intellij-platform
dependencies {
extensions.configure<IntelliJPlatformDependenciesExtension> {
intellijIdeaCommunity(libs.versions.idea)
instrumentationTools()
// dependency plugin id for https://plugins.jetbrains.com/plugin/6954-kotlin
bundledPlugin(libs.kotlin.stdlib.map(Dependency::getGroup))
}
}
}

plugins.apply(rootProject.libs.plugins.spotless.get().pluginId)
extensions.configure<SpotlessExtension> {
kotlin {
target("src/**/*.kt")
targetExclude("src/test/resources/**")
ktlint(rootProject.libs.ktlint.get().version)
ktlint(libs.ktlint.get().version)
.customRuleSets(
listOf(
rootProject.libs.composeRules.get().toString(),
libs.composeRules.get().toString(),
),
)
}
kotlinGradle {
ktlint(rootProject.libs.ktlint.get().version)
ktlint(libs.ktlint.get().version)
}
}

Expand All @@ -37,4 +82,12 @@ allprojects {
// https://docs.gradle.org/8.9/userguide/performance.html#execute_tests_in_parallel
maxParallelForks = Runtime.getRuntime().availableProcessors()
}

configurations.configureEach {
resolutionStrategy.eachDependency {
if (requested.group == libs.kotlin.stdlib.get().group) {
useVersion(libs.versions.kotlin.get())
}
}
}
}
5 changes: 0 additions & 5 deletions components/extensions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
plugins {
alias(libs.plugins.kotlin.jvm)
}

dependencies {
// https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
compileOnly(libs.kotlin.stdlib)
}
3 changes: 0 additions & 3 deletions components/parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ plugins {
dependencies {
api(projects.components.androidxCompose)

// https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
compileOnly(libs.kotlin.stdlib)

implementation(libs.android.build.tools)

testImplementation(libs.bundles.test)
Expand Down
13 changes: 0 additions & 13 deletions components/psi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ plugins {
alias(libs.plugins.jetbrains.intellij.module)
}

repositories {
mavenCentral()

intellijPlatform {
defaultRepositories()
}
}
dependencies {
implementation(projects.components.extensions)

Expand All @@ -21,12 +14,6 @@ dependencies {
testRuntimeOnly(libs.junit4)

intellijPlatform {
intellijIdeaCommunity(libs.versions.idea)
instrumentationTools()

// dependency plugin id for https://plugins.jetbrains.com/plugin/6954-kotlin
bundledPlugin(libs.kotlin.stdlib.map(Dependency::getGroup))

testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.JUnit5)
}
Expand Down
58 changes: 11 additions & 47 deletions idea-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.jetbrains.intellij)
}

// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#configuration.repositories
repositories {
google {
mavenContent {
includeGroupAndSubgroups("androidx")
includeGroupAndSubgroups("com.android")
includeGroupAndSubgroups("com.google")
}
}
mavenCentral()

intellijPlatform {
defaultRepositories()
}
}

dependencies {
implementation(projects.components.extensions)
implementation(projects.components.generator.iconpack)
Expand All @@ -46,25 +27,15 @@ dependencies {
implementation(libs.tiamat.base)
implementation(libs.tiamat.koin)

// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#setting-up-intellij-platform
intellijPlatform {
intellijIdeaCommunity(libs.versions.idea)
instrumentationTools()
zipSigner()

// dependency plugin id for https://plugins.jetbrains.com/plugin/6954-kotlin
bundledPlugin(libs.kotlin.stdlib.map(Dependency::getGroup))
}
}

compose.resources {
generateResClass = never
}

composeCompiler {
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}

intellijPlatform {
buildSearchableOptions = false
pluginConfiguration.ideaVersion {
Expand All @@ -82,25 +53,18 @@ intellijPlatform {
publishing.token = providers.environmentVariable("PUBLISH_TOKEN")
}

java {
// IDEA 2024.1 requires Java 17.
toolchain.languageVersion = JavaLanguageVersion.of(17)
}

tasks {
run {
// workaround for https://youtrack.jetbrains.com/issue/IDEA-285839/Classpath-clash-when-using-coroutines-in-an-unbundled-IntelliJ-plugin
buildPlugin {
exclude { "coroutines" in it.name }
archiveFileName = "${rootProject.name}-$version.zip"
}
prepareSandbox {
exclude { "coroutines" in it.name }
}
}
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
// workaround for https://youtrack.jetbrains.com/issue/IDEA-285839/Classpath-clash-when-using-coroutines-in-an-unbundled-IntelliJ-plugin
buildPlugin {
exclude { "coroutines" in it.name }
archiveFileName = "valkyrie-$version.zip"
}

withType<KotlinCompile> {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
prepareSandbox {
exclude { "coroutines" in it.name }
}
}