Thank you Jan! That's really something I can move forward with!

On 9/29/20 11:46 PM, Jan Lahoda wrote:
Hi Lazslo,

I was looking into this, and it seems to me the immediate problem is the
sourcepath returned for the test files. In particular, the source path
contains not only "gradle-modular-calculator/src/test/java" (and related
roots), but also "gradle-modular-calculator/src/main/java" (and related
roots).

This is problematic, because src/main/java contains module-info.java, and
hence, for javac, this is a modular compilation, leading to the ultimate
error.

I believe this should not be needed - the tests should have (and do have)
"gradle-modular-calculator/build/classes/java/main" on the classpath
(and/or possibly on module path, but in this particular case, the test
compilation seems to be non-modular, and hence classpath is correct), and
NetBeans then should know, via the SourceForBinaryQuery, how to convert
this binary dependency into corresponding source when needed.

In short, if I comment out:
             for (GradleJavaSourceSet sourceDependency :
ss.getSourceDependencies()) {
                 addAllFile(ret, sourceDependency.getAllDirs());
             }

In
java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/SourceClassPathImpl.java,
this particular case starts to work correctly. I wonder if there are cases
that don't work when this is removed?

Jan

On Fri, Sep 25, 2020 at 7:54 PM Laszlo Kishalmi <[email protected]>
wrote:

Dear People strong in Java Compiler,

I've put a very simple modular java project that has some JUnit (4.13)
test, to GitHub:

https://github.com/lkishalmi/gradle-modular-calculator

When loading that project into NetBeans, the JUnit test has several
compile error badges.

Saying: package org.junit is not visible (package org.junit is declared
in the unnamed module, but module modular.calculator does not read it)


As far as I understand this modular testing. In this case we should
treat the main sources / classes as non modular.
I'm 90% sure that the classpath the Gradle plugin provides the correct
classpath. How is it decided that the JavaParser go modular in this case.
Shall I filter out the module-info in this case from the Classpaths I
provide for the test source set?

--

    Laszlo Kishalmi


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to