Skip to content

"Module ___ not found" for run task (Java 11 with Kotlin/Groovy plugin applied) #118

Open
@tlinkowski

Description

@tlinkowski

When targeting JDK 11, in a project that has Java, Kotlin, and Groovy plugins applied but has only Java sources, run task fails with:

java.lang.module.FindException: Module ___ not found

It seems to be due to:

  • run task getting build/classes/merged on a module path (as it shouldn't)
  • mergeClasses task being absent (as it should)

Example

This behavior is exemplified on a branch of my project, where run fails like below:
https://travis-ci.com/tlinkowski/UniJ/builds/127633638#L1234-L1236

For a module targeting JDK 8, it works fine, though:
https://travis-ci.com/tlinkowski/UniJ/jobs/235293201#L1271-L1273

In a debugger, I managed to find out that for JDK 11, run is instrumented with the following command line arguments:

--module-path [...]\UniJ\subprojects\api\pl.tlinkowski.unij.api\build\libs\pl.tlinkowski.unij.api-0.1.0-SNAPSHOT.jar;C:\Users\tlink.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.28\cf5f2cf3c31e0e41b68d932d756398a1238d4456\slf4j-simple-1.7.28.jar;[...]\UniJ\subprojects\bindings\collect\pl.tlinkowski.unij.service.collect.jdk10\build\libs\pl.tlinkowski.unij.service.collect.jdk10-0.1.0-SNAPSHOT.jar;[...]\UniJ\subprojects\bindings\misc\pl.tlinkowski.unij.service.misc.jdk11\build\libs\pl.tlinkowski.unij.service.misc.jdk11-0.1.0-SNAPSHOT.jar;[...]\UniJ\subprojects\samples\enduser\pl.tlinkowski.unij.sample.enduser.jdk11\build\classes\merged;[...]\UniJ\subprojects\bundles\pl.tlinkowski.unij.bundle.jdk11\build\libs\pl.tlinkowski.unij.bundle.jdk11-0.1.0-SNAPSHOT.jar;[...]\UniJ\subprojects\api\pl.tlinkowski.unij.service.api\build\libs\pl.tlinkowski.unij.service.api-0.1.0-SNAPSHOT.jar;C:\Users\tlink.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.28\2cd9b264f76e3d087ee21bfc99305928e1bdb443\slf4j-api-1.7.28.jar;[...]\UniJ\subprojects\samples\enduser\pl.tlinkowski.unij.sample.enduser.jdk11\build\resources\main -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=50721 --patch-module pl.tlinkowski.unij.sample.enduser.jdk11=[...]\UniJ\subprojects\samples\enduser\pl.tlinkowski.unij.sample.enduser.jdk11\build\resources\main --module pl.tlinkowski.unij.sample.enduser.jdk11/pl.tlinkowski.unij.sample.enduser.jdk11.EndUsage

As you can see, we have build\classes\merged which shouldn't be there according to the spec from #101. However, :pl.tlinkowski.unij.sample.enduser.jdk11:mergeClasses task was not run (and was not present, which I confirmed in the debugger).

Conclusions

Because we:

  1. don't have mergeClasses tasks
  2. have build/classes/merged on the module path

it seems to me that the two calls to isMergeRequired return different results:

  1. returns false:

    public void configureMergeClassesAfterEvaluate() {
    if (!mergeClassesHelper().isMergeRequired()) {
    return;
    }

  2. returns true:

    public FileCollection getMergeAdjustedClasspath(FileCollection classpath) {
    if (!isMergeRequired()) {
    return classpath;
    }

I haven't yet confirmed if they really do return different results, and - if so - why it happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions