TL;DR
Managing dependencies in large, multi-module projects is a notorious headache often called "dependency hell." This paper introduces LibHarmo, an interactive tool that doesn't just detect when different modules are using conflicting versions of the same library, but actually calculates the "path of least resistance" to harmonize them by analyzing API usage and suggesting the version that requires the fewest code changes.
What Problem Does This Paper Address?
In modern software development, projects are often split into multiple modules (e.g., a "core" module, a "web" module, and a "util" module). In the Java/Maven ecosystem, it is surprisingly easy for these modules to accidentally depend on different versions of the same third-party library.
This leads to two major issues:
- Library Version Inconsistency (IC): Module A uses version 1.0, while Module B uses version 2.0. This can cause unpredictable crashes at runtime if both versions end up on the classpath.
- False Consistency (FC): Modules use the same version, but they are hard-coded separately rather than referencing a single central property. This is a "ticking time bomb"—the moment one developer updates a version in one module but forgets the others, the project falls into inconsistency.
Existing tools like Maven’s enforcer plugin can tell you there is a problem, but they offer no help in fixing it. Developers are often afraid to harmonize versions because they don't know how many breaking API changes they’ll have to deal with if they upgrade (or downgrade) to a unified version.
Methods
The authors first surveyed 131 professional developers to understand their pain points. Based on those insights, they built LibHarmo, which operates in three main phases:
- Detection via POM Graph: LibHarmo parses the project's Project Object Model (POM) files to build an inheritance graph. It resolves all direct dependencies to identify both explicit inconsistencies and "false consistencies."
- Effort-Aware Suggestion: This is the core innovation. For every possible "harmonized" version, LibHarmo performs a static analysis of the project's source code. It uses
JavaParserandjava-callgraphto count how many library APIs used by the project would be deleted or changed in the new version. It then presents developers with a ranked list of versions based on the lowest predicted migration effort. - Automated Refactoring: Once a developer selects a version, LibHarmo automatically refactors the POM files to use a centralized property. If an API was deleted in the new version, the tool even attempts to suggest a replacement by scanning Javadoc for "use [new_api]" patterns.
Datasets
The researchers evaluated LibHarmo using a dataset of 443 highly-starred Java Maven projects crawled from GitHub. This provided a diverse set of real-world, complex multi-module projects to test the tool's effectiveness.
Key Insights and Ideas
- Quantifying "Fear": The survey revealed that the primary reason developers avoid fixing version inconsistencies is the fear of "heavy fixing efforts" due to backward incompatibility. LibHarmo turns this subjective fear into a concrete metric (number of affected API calls).
- The Danger of "False Consistency": The paper highlights that FC is incredibly common. By identifying these, LibHarmo helps developers move toward a "Single Source of Truth" for dependencies before bugs even occur.
- Interactive over Fully Automated: The authors realized that a "one-click fix" isn't always desirable. Developers need to see the trade-offs (e.g., "Version X is newer, but Version Y requires zero code changes") to make informed decisions based on their current release schedule.
Key Results
- Prevalence: LibHarmo found 621 library version inconsistencies across 152 projects (34.3% of the dataset).
- Harmonization Effort: On average, harmonizing an inconsistency affected only 1 deleted API and 12 changed APIs. This suggests that many inconsistencies are actually quite easy to fix, but developers simply lacked the data to know that.
- Real-World Impact: The authors sent reports to developers. Within a week, 16 developers responded, with many confirming the issues were "very real." Five inconsistencies were officially confirmed as bugs, and one was immediately harmonized by the project maintainers following the report.
Limitations and Future Work
- Static Analysis Limits: Like all tools based on static analysis, LibHarmo can struggle with Java Reflection, where library calls are made dynamically at runtime. This could lead to underestimating the fixing effort.
- Ecosystem Scope: Currently, the tool only supports Java and Maven. The authors acknowledge that extending this to Gradle or other languages (like JavaScript/npm) would be valuable but requires handling different dependency resolution logic.
- CI/CD Integration: While currently a prototype, the authors suggest that integrating LibHarmo directly into the build pipeline or as a GitHub Action would help catch these issues the moment a pull request is created.
Summary updated