Search code examples
javagradlemulti-modulerserve

Module not found, trying to use old java library


I have a multi-module java project and I am using Gradle 8.1 and java jdk 17.0.4. But I get an error when running 'gradle build' the child module "rengine-rserve-wrapper":

...
> Task :rengine-rserve-wrapper:compileJava FAILED
D:\JavaProg\MASI_Projet_Integre\data-mining-apps\rengine-rserve-wrapper\src\main\java\module-info.java:3: error: module not found: REngine
    requires REngine;
             ^
D:\JavaProg\MASI_Projet_Integre\data-mining-apps\rengine-rserve-wrapper\src\main\java\module-info.java:4: error: module not found: Rserve
    requires Rserve;

So the problem seems to come from the module.info. Here it is :

module data.mining.apps.rengine.rserve.wrapper.main {
   requires org.mongodb.bson;
   requires REngine;
   requires Rserve;
}

And the 2 packages dependencies (in the build.gradle.kts of the child module) :

dependencies {
    implementation("org.rosuda.REngine:REngine:2.1.0")
    implementation("org.rosuda.REngine:Rserve:1.8.1")
    implementation("org.mongodb:bson:4.8.2")
    ...
}

Here I added the "org.mongodb:bson:4.8.2" to check wether the problem comes from any dependecies or wether the problem comes especially from the 2 libraries "REngine" and "Rserve". Regarding the above error, it seems the problem comes from the 2 libraries.

But I don't know how to solve this problem. At the beginning, I had done this project using Maven and it worked just fine, but now that I'm using Gradle, I have this problem.

Just in case, here is the hierarchy of the project :

data-mining-apps
|- "rengine-rserve-wrapper"
|- "Other children module"
|- settings.gradle.kts
 \ build.gradle.kts

And here is the parent "settings.gradle.kts" :

rootProject.name = "data-mining-apps"
include("rengine-rserve-wrapper")
...

And the full build.gradle.kts of the "rengine-rserve-wrapper" child :

plugins {
    id("java-library")
}

group = "be.masi.g2"
version = "0.0.1"

repositories {
    mavenCentral()
}

java {
    modularity.inferModulePath.set(true)
}

dependencies {
    implementation("org.rosuda.REngine:REngine:2.1.0")
    implementation("org.rosuda.REngine:Rserve:1.8.1")
    implementation("org.mongodb:bson:4.8.2")
    testImplementation(platform("org.junit:junit-bom:5.9.1"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
    useJUnitPlatform()
}

Solution

  • This is a bit akward, but i forgot to add the java modularity module in the build.gradle.kts of the "rengine-rserve-wrapper" :

    plugins {
        id("java-library")
        id("org.javamodularity.moduleplugin") version "1.8.12"
    }