0

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: Working output

But, when I'm executing the task on IntelliJ, it says that they cannot resolve my buildscript... Error output

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 !

  • I guess Intellij uses not ./gradlew, since it's for Unix, but ./gradlew.bat or something. Can you try running that with gradlew.bat or with the downloaded graldle.exe directly? It might have something to do with the fact, that Intellij uses Windows version – Vitaly Chura Dec 15 '22 at 15:03
  • Have you configured IntelliJ to delegate Gradle actions to the Gradle wrapper? https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#delegate_build_gradle – aSemy Dec 15 '22 at 15:17
  • @VitalyChura Either gradlew, gradlew.bat nor C:\gradle\...\gradle.bat work... – JetairThePlane Dec 15 '22 at 18:03
  • @aSemy I've tried the three configuration they allow me (use gradle from:) and nothing changes... Even changing JDK doesn't change anything :/ – JetairThePlane Dec 15 '22 at 18:05

0 Answers0