question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: handling split package modules issues

See original GitHub issue

Certain well-known, often-used jar files exhibit split package issues when both were put on the module path. One pair that I encountered is the conflict between

"javax.annotation:javax.annotation-api:1.3.2"

and

"com.google.code.findbugs:jsr305:3.0.2"

Fortunately, this conflict can be resolved by putting only one of them on the module path and then patch it with the content of the other. This can be achieved by applying snippets of Gradle codes for the compileJava, compileTestJava, test, run, startScripts, and distributions tasks, such as the following:

compileJava {
    doFirst {
        def jsr305 = classpath.filter{it.name.contains('jsr305')}.asPath
        classpath = classpath.filter{!it.name.contains('jsr305')}
        options.compilerArgs += [
                '--patch-module', "java.annotation=$jsr305"
        ]
    }
}

Since these snippets are scattered repetitively throughout the build.gradle file, and the modifications they trigger are quite in line with that the moduleplugin does, I wonder if it makes sense for the moduleplugin to provide a declarative way to handle the situation.

Here’s a simple test case that demonstrates the issue:

https://github.com/weiqigao/jsr305-split-package-issue

where the foo project is a non-modular Maven jar project that depends on both jars, and the bar project is a Gradle modular jar project that depends on the artifact of the foo project and therefore transitively depends on the conflicting two jars. The build.gradle in the bar project contains more snippets similar to the above but for the run, startScripts, and distributions tasks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
paulbakkercommented, Nov 6, 2018

Thanks @mwkroening, that’s useful. @weiqigao I’m thinking this should be “global” config that applies to all tasks right?

0reactions
paulbakkercommented, Dec 28, 2018

Merged and released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve split package issue in Java 9 - Stack Overflow
Important this approach does not work when the same package exposes different classes from different modules and both of them are required.
Read more >
Issues for Configuration Split | Drupal.org
Title Status Priority Category Allow dependency on another split Active Normal Feature requ... Fatal error when trying to run csex Active Critical Bug report Drupal Coding...
Read more >
How to split HTTP Interceptors between multiple backends
This article explains one of the possible ways to build different types of HttpClients for different feature modules (including non-lazy loaded) and ...
Read more >
Overview of Play Feature Delivery | Android Developers
Installing 50 or more feature modules on a single device, via conditional or on-demand delivery, might lead to performance issues. Install-time modules, which ......
Read more >
Code Splitting - webpack
This feature allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found