Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 scopeghostdep group
compile (default)main
testdev
providedoptional
runtimemain
systemoptional

build.gradle / build.gradle.kts

Regex-based extraction. Matches Groovy ('group:artifact:version') and Kotlin DSL (("group:artifact:version")) syntax. Supported configurations:

Gradle configghostdep group
implementation, api, runtimeOnlymain
testImplementation, testCompileOnly, testRuntimeOnlydev
compileOnlyoptional
annotationProcessor, kaptbuild

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:

  1. 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 → tries org.apache.commons.lang3 → finds commons-lang3.

  2. 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.