2

In the Gradle build file below the fileTree dependency is loading some local jars, but compilation fails with errors like 'package groovy.text is declared in the unnamed module, but module groovy.text does not read it'. I am not sure where the problem reside, could it be that I have to add also something to the compileJava task ? The current configuration is used for a JavaFx application, as discussed in this thread

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
    }
}

apply plugin: 'application'
apply plugin: 'com.google.osdetector'

ext.platform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os

repositories {
    mavenCentral()
    flatDir {
        dirs 'src/main/lib'
    }
}

dependencies {
    compile fileTree(dir: 'src/main/lib', include: ['*.jar'])
    compile "org.openjfx:javafx-base:11:$platform"
    compile "org.openjfx:javafx-graphics:11:$platform"
    compile "org.openjfx:javafx-controls:11:$platform"
    compile "org.openjfx:javafx-web:11:$platform"
}

compileJava {
    doFirst {
        options.compilerArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.controls',
                '--add-modules', 'javafx.graphics',
                '--add-modules', 'javafx.web'
        ]
    }
}

run {
    doFirst {
        jvmArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.controls'
        ]
    }
}

mainClassName = 'HelloFX'
DbSchema
  • 413
  • 5
  • 16
  • After more researches I found out that the jars are passed on the class path to the compiler. But the compile fails with multiple errors like 'package groovy.text is declared in the unnamed module, but module groovy.text does not read it'. What could be this ? – DbSchema Nov 06 '18 at 07:53
  • Why do you add your libs to the src folder (`src/main/lib`)? Can you try moving them to `lib`, outside of `src`? – José Pereda Nov 06 '18 at 08:28
  • I moved the folder and fixed build.gradle now, but the error stays the same – DbSchema Nov 06 '18 at 10:35
  • Do you have a `module-info.java` file? then you need to add something like `requires groovy.text`. – José Pereda Nov 06 '18 at 10:47
  • @dprutean ideal solution would be to add those jars to the modulepath, but given the condition that you might have intentionally put them on classpath, you can use the VM args `--add-reads groovy.text=ALL-UNNAMED` to resolve this temporarily. – Naman Nov 06 '18 at 13:14

0 Answers0