zyxist / chainsaw

Gradle plugin: adds support for building Java 9 modules.
Apache License 2.0
71 stars 4 forks source link

Unexpected Behaviour in the gradle run task #4

Closed mirko-lelansky closed 6 years ago

mirko-lelansky commented 6 years ago

Hallo,

i have found a strange behaviour in the gradle run task see Working Example . That example reads a property file from the module|classpath and prints the property to the console.

When you use the run task then the example didn't working because the Stream is null, but if you use the install task and then run the generate script the example works.

I think the problem is that gradle separates the class and resource files in two separate directories. The module-info.class file which identify the module are only in the folder of the classes. Then when you use the run task both folders are add to the module path, but i think that the resouces aren't correctly recognized, because they have no module-info.class file.

SingingBush commented 6 years ago

this is a problem for me. I have a unit test that uses a test resource but when running gradle check the resource is null

zyxist commented 6 years ago

Sorry for the very late answer. Due to external circumstances I could not take care of the project for a while.

I managed to resolve the issue, although the root cause has something to do with Gradle internals, not with Jigsaw. The thing that helped was configuring JavaExec task with doLast closure, instead of doFirst. I added some integration tests both for run and test tasks.

zyxist commented 6 years ago

Unfortunately, it turned out that the delivered fix disables Jigsaw completely for the run task. The tests did not capture it, because they did not look at the generated command line.

I managed to find a proper fix, will be merged later today.