This message was deleted.
# community-support
s
This message was deleted.
c
perhaps check the tasks of any given project - are there Kotlin compile tasks present? Is the Kotlin plugin applied on the subproject?
s
It is applied on our “buildSrc” project (that contains the source for our own “conventions” classes, those are then used for the subprojects)
c
Do your convention plugins then apply the Kotlin plugin?
s
Hm. The sup project build.gradle didn’t mention it. I added `id("org.jetbrains.kotlin.jvm") version ("1.6.21")`to its plugin section … and now I get an error: Could not find org.jetbrains.kotlinkotlin stdlib jdk81.6.21
c
those look like the right coordinates. Is that error from resolving the artifact against your repository?
s
yep
which (theoretically) should just “route” request to maven central itself. well, for certain things.
c
try
kotlin("jvm") version "1.6.21"
s
Nope.
startup failed:
build file whatever/build.gradle’: 13: only id(String), alias(Provider), or alias(ProviderConvertible) method calls allowed in plugins {} script block ….. @ line 13, column 5. kotlin(“jvm”) version “1.6.21" ^ 1 error
c
ah, suspect that’s a build.gradle, not the Kotlin DSL build.gradle.kts.
Groovy.
s
Yes. The project build gradles couldn’t be kotlin, because we also have to support eclipse/VS code, and at least in the past, those IDEs only work with groovy build.gradle files 🤷‍♂️ As said, our setup is complicated.
c
understood. What you had previously:
id("org.jetbrains.kotlin.jvm") version ("1.6.21")
- should work to pull in the Kotlin plugin. What plugin repositories are configured?
s
ahhhhh
c
lol
s
there is a section in our toplevel build.gradle that restricts which modules can be pulled directly from maven central, to ensure we don’t start pulling things by accident. When I add org.jetbrains.kotlin there … it fails differently now (resolving other modules).
c
ok! progress.
s
yeah, some more “yeah, allow these modules”, and now I get … kotlin compilation errors. Fine, my example files have errors, that is acceptable.
🙂 1
./output/gradle-build-ide/dpm_zcpc/classes/kotlin/main/whatever/RootKotlinator.class The class files don’t (yet) end up where I want them, but the first step has been made. It is only a small step for mankind, but a big step for me. Thank you very much!
c
cool, glad that is working, enjoy your Kotlin Journey!
s
I will try my best!
c
btw, you don’t usually need to move classes directory around; you can copy them to wherever by referencing the compile task, if need be. Usually safer to have a few extra copies than mess with lower-level directory stuff.
s
as said … it is complicated. We have a complex legacy build system that does everything in strange ways. We couldn’t replace the whole build system, so we decided to only redo the “java” parts of the build with gradle. But in order to make that a smooth transition, we have to make sure that A) cleaning up things is robust and B) that the class files end up where the legacy build tool would place them. But yeah, one of our big goals is to follow the maven layout for all projects, so we can simplify such work.
c
ah, i see. still, you could keep the conventional classes dir and add a task to copy them to <legacy place>. that way, when you no longer need the legacy stuff, it’s a simple matter of removing that task (versus reconfiguring stuff).
Something like this (Kotlin):
Copy code
val copyKotlinClasses = tasks.register<Copy>("copyKotlinClassesToLegacy") {
    into("legacyDir")
    from(tasks.named("compileKotlin"))
}

tasks.named("assemble") {
    dependsOn(copyKotlinClasses)
}
s
I think we had specific reasons why we did it that way … but I will definitely keep your idea in mind!
👍 1
j
Did you setup the Kotlin compiler in the tasks block? Here is what mine looks like to build Kotlin:
Copy code
// Kotlin compile
    withType<KotlinCompile> {
        sourceCompatibility = JavaVersion.VERSION_11.toString()
        targetCompatibility = JavaVersion.VERSION_11.toString()

        kotlinOptions {
            apiVersion = "1.6.21"
            languageVersion = "1.6.21"
            jvmTarget = JavaVersion.VERSION_11.toString()
            freeCompilerArgs = listOf("-Xjsr305=strict")
            allWarningsAsErrors = true
        }
    }