0

I was trying to create runtime for my project, but suddenly I got an error and I couldn't find any info about it. The project is setted up as kotlin+gradle and nothing more.

I use badass-jlink-plugin and log4j2. The error:

Execution failed for task ':prepareModulesDir'.
> Error while evaluating property 'moduleName' of task ':prepareModulesDir'
   > Failed to query the value of extension 'jlink' property 'moduleName'.
      > Cannot find module-info.java in [ProjectFolder\src\main\java]

My build.gradle (not full):

buildscript {
   ...
}
plugins {
    id 'application'
    id 'org.jetbrains.kotlin.jvm' version '1.8.0'
    id 'org.beryx.jlink' version '2.26.0'
//    id 'org.jetbrains.kotlin.multiplatform' version '1.8.0'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.0'
}

apply plugin: 'kotlin'
apply plugin: 'kotlinx-serialization'

group = 'com.adisalagic.codenames'
version = '1.0-SNAPSHOT'
mainClassName = 'com.adisalagic.codenames.Main'

repositories {
    mavenCentral()
}

dependencies {
//    implementation "org.jetbrains.kotlin:kotlin-serialization:1.8.0"
    testImplementation 'org.jetbrains.kotlin:kotlin-test'
//    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0-RC")
    implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
    implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
    implementation 'com.google.code.gson:gson:2.10.1'
}

test {
    useJUnitPlatform()
}

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    forceMerge 'log4j-api'
}

jar {
    manifest {
        attributes "Main-Class": "$mainClassName"
    }

    from {
        configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

tasks.withType(Jar).configureEach {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    manifest {
        attributes["Main-Class"] = "$mainClassName"
    }
}
kotlin {
//    jvmToolchain(8)
}

Should I create module-info myself?

I've discovered that it only happened when I use forceMerge. But everywhere it is suggested to be used.

AdisAlagic
  • 436
  • 2
  • 8

0 Answers0