In the main sources set I have java files that I wanted to modify, compile and put into original jar. When I run gradle build then resulting Base-1.3.4.jar file is perfectly ok. Classes substituted.
But gradle buildExt make Ext-1.3.4.jar with same content as in the original jar. Classes not substituted.
Just declare a target to patch and put overrides in src/main/java and src/main/resources. The resultant artifact contains has the same transitive dependencies as the target so it’s a drop in replacement
Interesting, but I already find solution. Custom task of type Jar does not include project compiled classes by default. They needed to be included explicitly:
This approach will work but you’ll lose the transitive dependency information from the target jar so you’ll need to manually declare these dependencies (if any) wherever you use the patched jar