zyxist / chainsaw

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

Please also transport the --patch-module flags to the start scripts #20

Open Vampire opened 6 years ago

Vampire commented 6 years ago

You need to add the patch libs to some folder like patch-lib in the distribution like with

distributions {
   main {
      contents {
         from(configurations.patch) {
            into 'patch-lib'
         }
      }
   }
}

and then add the --patch-module flags like --patch-module org.apache.logging.log4j=$APP_HOME/patch-lib/patch-lib.jar for *nix or --patch-module org.apache.logging.log4j=%APP_HOME%\patch-lib\patch-lib.jar for Windows.

zyxist commented 6 years ago

Adding patches is a bit tricky, because the current algorithm for translating dependencies into patch flags is based on the JAR location+name within Gradle cache. I'm aware of that limitation since adding support for patching, and I must find out, how the original plugin constructs JAR names in the lib directory and use exactly same API in Chainsaw. I'm adding it to fix in the next release.

Vampire commented 6 years ago

Well, as you remove the patch files from all configurations, they will not end up in the lib directory, which is ok, because they should not be considered as modules themselves which they would if have them on the module path. So you need them in a separate folder like I showed with the configuration above e. g. That is from a build script, but you can do the same in plugin code too of course.

In ModulePatcher you use artifact.getFile().getAbsolutePath() of the resolved artifact, so if you put the patch configuration into some folder like patch-lib and then construct the flag option from artifact.getFile().getName() that should work fine I think. The APP_HOME placeholders can be used as I showed them, the start script interpreter will expand them.