java9-modularity / gradle-modules-plugin

This Gradle plugin helps working with the Java Platform Module System
https://javamodularity.com/
MIT License
234 stars 36 forks source link

Fails building with Javadoc #13

Closed DJViking closed 6 years ago

DJViking commented 6 years ago

This plugin does not work when building with Javadoc

> Task :javadoc FAILED
/home/sverre/workspace/movies/src/main/java/module-info.java:6: error: module not found: 
javafx.controls
    requires javafx.controls;
               ^
/home/sverre/workspace/movies/src/main/java/module-info.java:7: error: module not found: javafx.fxml
    requires javafx.fxml;
               ^
/home/sverre/workspace/movies/src/main/java/module-info.java:8: error: module not found: javafx.web
    requires javafx.web;
               ^
/home/sverre/workspace/movies/src/main/java/module-info.java:9: error: module not found: 
javafx.graphics
    requires javafx.graphics;
                   ^
/home/sverre/workspace/movies/src/main/java/module-info.java:10: error: module not found: 
javafx.media
    requires javafx.media;
                   ^
/home/sverre/workspace/movies/src/main/java/module-info.java:12: error: module not found: 
org.apache.logging.log4j
    requires org.apache.logging.log4j;

build.gradle

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives jar
    archives sourcesJar
    archives javadocJar
}

Without this plugin I have a modules.gradle with the following Javadoc configuration:

javadoc {
    inputs.property("moduleName", moduleName)
    doFirst {
        exclude "**/module-info.java"
        options.addStringOption('-module-path', classpath.asPath)
        options.addStringOption('-add-modules', 'javafx.controls')
        options.addStringOption('-add-modules', 'javafx.fxml')
        options.addStringOption('-add-modules', 'javafx.web')
        options.addStringOption('-add-modules', 'javafx.graphics')
        options.addStringOption('-add-modules', 'javafx.media')
        options.addStringOption('-class-path', "")
        options.addBooleanOption('html5', true)
    }
}
aalmiray commented 6 years ago

Encountered this problem too when testing out this plugin with the aalmiray/ikonli build. Resorted to the following

suprojects { subproj ->
    afterEvaluate {
        javadoc {
            inputs.property('moduleName', subproj.moduleName)
            doFirst {
                options.addStringOption('-module-path', classpath.asPath)
                classpath = files()
            }
        }
    }
}
paulbakker commented 6 years ago

First part of a fix in this PR: #20. Still wouldn't fix the problem for @DJViking, because we need a way to specify extra modules. I'm considering adding dsl syntax for this, such as:


   addModules: [
      'module1', 'module2'
  ]
}
paulbakker commented 6 years ago

Fixed with #20 and #21

DJViking commented 6 years ago

I have now tried to run with 1.1.1 of the plugin Getting this error. The other errors are gone.

> Task :javadoc FAILED
/home/sverre/workspace/movies/src/main/java/module-info.java:12: error: module not found: 
org.apache.logging.log4j
    requires org.apache.logging.log4j;
paulbakker commented 6 years ago

Is the org.apache.logging.log4j module configured as a dependency?

DJViking commented 6 years ago

Yes,

build.gradle

apply from: rootProject.file('dependencies.gradle')

dependencies.gradle

final def log4jGroup = 'org.apache.logging.log4j'
final def log4jVersion = '2.11.1'

dependencies {
    compile group: log4jGroup, name: 'log4j-api', version: log4jVersion
    compile group: log4jGroup, name: 'log4j-core', version: log4jVersion
    compile group: 'com.lmax', name: 'disruptor', version:'3.3.7'
}

module-info.java

requires org.apache.logging.log4j;
DJViking commented 6 years ago

Will #34 fix this last remaining problem?

paulbakker commented 6 years ago

That's already merged in the last release, so if you're using that and it still doesn't work, there's another problem. If so, feel free to reopen this.

DJViking commented 6 years ago

I am using v1.1.1. The #34 was merged in after and there is no v1.1.2 available.

DJViking commented 6 years ago

Tried now with the latest v1.2.0, but getting same problem

Task :javadoc FAILED /home/sverre/workspace/movies/src/main/java/module-info.java:12: error: module not found: org.apache.logging.log4j requires org.apache.logging.log4j;

The Log4j is a multi version JAR with the module-info.class within META-INF/versions/9

mpe85 commented 5 years ago

I'm facing a very similar problem:

[...]\src\main\java\module-info.java:3: error: module not found: net.bytebuddy requires net.bytebuddy;

ByteBuddy is also a multi release jar with the module-info.class inside META-INF/versions/9

Could you please re-open this issue and have another look at it?