This message was deleted.
# community-support
s
This message was deleted.
๐Ÿงต 1
v
Please do not split topics across several threads. This makes following the conversation in the threads view very hard as the context of the other messages is missing. If you have additional information either edit the original message or post to its thread. Regarding the problem, as you can see in the IntelliJ screenshot,
src/main/kotlin
is not a source directory. You have neither a settings script (which is bad practice and enforced in all other builds) nor a build script in your
buildSrc
project. So the default is used, which only sets up Groovy compilation. Add a build script and configure it properly, for example by applying the
kotlin-dsl
plugin.
โœ… 1
a
Why is this aint working?
Copy code
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
val koin_ktor: String = "3.5.1"
val mapStructVersion = "latest.release"


plugins {
    java
    checkstyle
    id("com.github.spotbugs")

    //LEAD TO FAIL
    kotlin("jvm") 
    kotlin("kapt") 
    id("io.ktor.plugin") 
    id("org.jetbrains.kotlin.plugin.serialization")
}


group = "com.example"
version = "1.0"

tasks.test {
    useJUnitPlatform()
}

repositories {
    mavenCentral()
}


dependencies {
    implementation( "com.github.javafaker:javafaker:1.0.2")
    testImplementation("junit:junit:4.13")
//
//    //mapstruct
//    implementation("org.mapstruct:mapstruct:$mapStructVersion")
//    "kapt"("org.mapstruct:mapstruct-processor:$mapStructVersion")
//
//    //CORS
//    implementation("io.ktor:ktor-server-cors:$ktor_version")
...
}
I am getting:
Copy code
FAILURE: Build failed with an exception.

* Where:
Precompiled script plugin 'C:\Users\zwo7a\IdeaProjects\FreshNearMe\buildSrc\src\main\kotlin\myproject.java-conventions.gradle.kts' line: 1

* What went wrong:
Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
Some of my dependencies (like mapstruct), need extra plugins (kapt for example) where should i add it? Adding this is convention plugins leads to failure. When i add this is buildSrc/build.gradle.kts then this happen...
v
Do you have a dependency on that in
buildSrc/build.gradle.kts
?
a
this is buildSrc
Copy code
plugins {
//    //LEAD TO FAIL
//    kotlin("jvm")
//    kotlin("kapt")
//    id("io.ktor.plugin")
//    id("org.jetbrains.kotlin.plugin.serialization")
//
    `kotlin-dsl`
}

group = "com.example"
version = "0.0.1"

repositories {
    mavenCentral()
    gradlePluginPortal()
}

dependencies {
    implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.1")
    testImplementation("org.jetbrains.kotlin:kotlin-test")
}

tasks.test {
    useJUnitPlatform()
}
kotlin {
    jvmToolchain(11)
}
v
Yeah, you see, you do not have the dependency. Plugins you want to apply in your convention scripts should be dependencies of the plugin project.
a
Sorry, but I am lost, what do you mean by this? Like this?:
Copy code
dependencies {
    kotlin("jvm")
    kotlin("kapt")
    id("io.ktor.plugin")
    id("org.jetbrains.kotlin.plugin.serialization")

    implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.1")
    testImplementation("org.jetbrains.kotlin:kotlin-test")
}
v
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.22")
โœ… 1
a
Copy code
dependencies {
    //kotlin("jvm")
    implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.22")

    //kotlin("kapt")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")

    //id("io.ktor.plugin")
    implementation("io.ktor.plugin:plugin:2.3.8")

    //id("org.jetbrains.kotlin.plugin.serialization")
    implementation("org.jetbrains.kotlin:kotlin-serialization:1.9.22")

    implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.1")
    testImplementation("org.jetbrains.kotlin:kotlin-test")
}
v
<plugin id>:<plugin id>.gradle.plugin:<plugin version>
just like I showed with JVM plugin. Then you do not need to look for the code artifact coordinates or could be bitten by them changing.