I just understood how buildscript works and I've made a basic script that just puts kotlin inside any subproject with
`kotlin-conventions`
My gradle multiproject is setup like this:
project
├─ acq
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
├─ acs
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
├─ acs-client
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
├─ buildSrc
| ├─ src
| | ├─ main
| | | ├─ kotlin
| | | | ├─ containerized-app.gradle.kts
| | | | ├─ kotlin-conventions.gradle.kts
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
├─ core
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
├─ sp
| ├─ build.gradle.kts
| ├─ settings.gradle.kts
project/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
plugins {
kotlin("jvm")
}
repositories {
mavenCentral()
}
dependencies {
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
project/buildScr/build.gradle.kts
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
implementation("com.google.cloud.tools:jib-gradle-plugin:3.3.1")
}
project/acq/build.gradle.kts
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
`kotlin-conventions`
`containerized-app`
}
group = "be.rm.secu.tp2"
version = "0.0.1"
application {
mainClass.set("be.rm.secu.tp2.acq.ApplicationKt")
}
repositories {
mavenCentral()
}
dependencies {
implementation("ch.qos.logback:logback-classic:$logback_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
}
(You can go to the github repository to get the full code, although I cannot promise that the code won't change in the future)
The problem I'm having, is that when I run gradlew from a CLI (WSL 2.0, Java 17.0.5-tem, Gradle 7.4.2), everything is fine and this is the output:
But, when I'm executing the task on IntelliJ, it says that they cannot resolve my buildscript...
I don't really understand why is this happening, I am guessing this is an IntelliJ problem.
I tried searching for a similar case, although I couldn't find anything. I tried invalidating caches, removing caches. Changing environment (CMD, PowerShell, WSL), removing .gradle(s), removing .idea...
I could try working with gradle on CLI and IntelliJ as an IDE, but this is not really efficient, as I will surely rely on the IntelliJ debugger in the future...
Thanks !