Skip to content

Smart ~/.m2 search in index goal #4

@dblevins

Description

@dblevins

Summary

mvn jackknife:index -Dclass=com.fasterxml.jackson.databind.ObjectMapper — find a class in ~/.m2/repository without shell commands or permission prompts.

Motivation

When Claude needs to understand a class that isn't a project dependency, the current workflow is find, jar tf, jar xf, javap — every one prompts the user for permission. This eliminates that entire workflow.

Design

Algorithm

  1. Check existing manifests — if found, print location, done
  2. Derive search root from class package: com.fasterxml maps to ~/.m2/repository/com/fasterxml/
  3. Walk from that root, collecting all *.jar files
  4. Group by groupId:artifactId, keep only latest version of each (see version sorting below)
  5. Sort by longest match of groupId+artifactId path to class package
  6. Walk the sorted list, open zip directory, check for the .class entry
  7. First hit: index that jar, print result

Version sorting

Use numeric component comparison (adapted from Harminie Version.java). Split version string on non-numeric characters, compare int arrays component by component. Correctly sorts 2.9.1 < 2.14.0 < 2.15.3.

Search root optimization

The first two segments of the package name (com.fasterxml) map to the repo directory (com/fasterxml/). Start the walk there. This eliminates 90%+ of ~/.m2 without scanning.

Examples

mvn jackknife:index -Dclass=com.fasterxml.jackson.databind.ObjectMapper
mvn jackknife:index -Dclass=org.apache.commons.lang3.StringUtils

Acceptance Criteria

  • Finds class in ~/.m2 without prior index
  • Starts search from package-derived directory
  • Latest version wins when multiple versions exist
  • Indexes the jar on first hit
  • Subsequent decompile works on the indexed jar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions