Java (beta)
Java support is in beta. The import-to-artifact mapping is inherently heuristic — there’s no standard 1:1 mapping between Java import paths and Maven artifact IDs. ghostdep covers ~150 common libraries and uses groupId matching as a fallback, but may miss niche libraries.
Manifests
pom.xml
Parses <dependency> elements. Extracts <groupId>, <artifactId>, and <scope>. Maps scopes to dependency groups:
| Maven scope | ghostdep group |
|---|---|
| compile (default) | main |
| test | dev |
| provided | optional |
| runtime | main |
| system | optional |
build.gradle / build.gradle.kts
Regex-based extraction. Matches Groovy ('group:artifact:version') and Kotlin DSL (("group:artifact:version")) syntax. Supported configurations:
| Gradle config | ghostdep group |
|---|---|
implementation, api, runtimeOnly | main |
testImplementation, testCompileOnly, testRuntimeOnly | dev |
compileOnly | optional |
annotationProcessor, kapt | build |
Import scanning
Uses tree-sitter with the Java grammar. Extracts from import_declaration nodes, including static imports and wildcard imports (java.util.* → java.util).
All Java imports are static — confidence is always high.
Normalization
Two-stage process:
-
Alias table lookup — tries progressively shorter prefixes of the import path against a built-in table of ~150 common libraries. Example:
org.apache.commons.lang3.StringUtils→ triesorg.apache.commons.lang3→ findscommons-lang3. -
groupId matching — if no alias matches, falls back to the first 3 segments as a groupId-style prefix (e.g.,
com.example.mylib). The matcher then checks if any declared dependency’s groupId starts with this prefix.
Stdlib detection
Any import starting with java., javax., or jdk. is standard library.
Aliases
~150 built-in mappings covering:
- Google: gson, guava, protobuf, guice
- Apache Commons: lang3, io, collections4, codec, text, csv, compress, etc.
- Jackson: core, databind, annotations, dataformat, datatype
- Spring: boot, web, data, security, context, beans, core, test, jdbc, batch, kafka, cloud
- Testing: junit-jupiter, mockito, assertj, hamcrest, testng, testcontainers, cucumber
- Logging: slf4j, logback, log4j
- Database: HikariCP, mybatis, jooq, flyway, liquibase, jedis, lettuce, mongodb, elasticsearch
- AWS: aws-sdk-java, aws-java-sdk-core, s3, sqs, dynamodb
- And many more
PRs to expand the mapping table are very welcome.