zeroturnaround / gradle-jrebel-plugin

The plugin generates rebel.xml configuration file for the Gradle-based project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gradle Shadow plugin Relocation causes ClassNotFoundException (JR-7701)

HeroCC opened this issue · comments

Corresponding Shadow issue: johnrengelman/shadow#308

Shadow Plugin version: 2.0.1
Gradle plugin version: 4.0
JRebel plugin version: 1.1.5
JRebel Agent Version: 7.0.10

The shaded imports should automatically point to the new dependency location, and JRebel updates classes successfully. However, when relocating with Shadow and using JRebel, the dependency cannot be found. The exception can be found here: https://pastebin.com/eCcWL4Q2.

To reproduce, make a project that uses jRebel and relocates a dependency using Shadow (example). When not using a relocated dependency it works fine, and when not using jRebel it works fine. Together it is a no-go. I can give more detailed setup instructions if you'd like. Commenting out lines 45 and 36 in that example fix it, as the plugin no longer uses JRebel. Or you can not include JRebel in the classpath when running the jar.

If you need more information, please let me know!

Hey HeroCC

JRebel reloads classes when the underlying .class files are updated, following rebel.xml redirection, if present. If classes are compiled first with shading/relocating and later without, it's expected that it will run into error - e.g. dependencies are located at com.relocated.foo.Dependency, but compiled classes point to com.foo.Dependency. So, you should either

  1. Drop shading during development
  2. Create pre-shaded jar with dependencies and compile against that
  3. Always use gradle with shade build step to compile.