Skip to content

About

Felix Bundle Extractor - Sorts and decompiles your Felix / OSGi bundles in to a searchable directory

Resources

Stars

5 stars

Watchers

3 watching

Forks

Repository files navigation

Felix Bundle Extractor

An IntelliJ IDEA plugin and standalone CLI tool that attaches AEM / Apache Felix OSGi bundles as a searchable External Library in IntelliJ IDEA, and can also extract bundles from the command line for use in CI/CD pipelines or scripted workflows.

Features

  • Point the plugin at a local Felix launchpad bundles directory
  • All bundles are automatically indexed and available for Go To Class, Find Usages, and Find in Files
  • Sources are fetched from Maven Central where available, or decompiled on demand via IntelliJ's built-in Fernflower decompiler (plugin) / Vineflower (CLI)
  • "Fetch sources" editor banner when opening a .class file from a bundle without sources
  • Dedicated Felix Bundles search scope for targeted searches in Find in Files / Find Usages
  • Configurable include/exclude filters based on groupId and artifactId (regex)

Project Structure

core/    Pure Kotlin/JVM extraction logic — no IntelliJ API dependencies
cli/     Standalone fat JAR entry point (java -jar)
plugin/  IntelliJ Platform plugin — delegates to core, wires IntelliJ Platform APIs

CLI Usage

# Build the fat JAR
./gradlew :cli:shadowJar
# Output: cli/build/libs/cli-2.0.0-SNAPSHOT.jar

# Run
java -jar cli/build/libs/cli-2.0.0-SNAPSHOT.jar <bundlesDir> <outputDir> [options]

# Options
#   --maven-repo <url>           Maven repository base URL (default: Maven Central)
#   --include-groups <regex>     Only extract bundles whose groupId matches
#   --exclude-groups <regex>     Skip bundles whose groupId matches
#   --exclude-artifacts <regex>  Skip bundles whose artifactId matches
#   --exclude-non-maven          Skip bundles without an embedded pom.xml
#   --no-decompile               Do not decompile when Maven sources are unavailable
#   --decompile-timeout <secs>   Per-bundle timeout in seconds (default: 60, 0 = no limit)
#   --no-realign                 Keep decompiled sources compact (not aligned to original lines)
#   --verbose                    Print debug-level messages

Output is written to <outputDir>/artifacts/ (binary JARs) and <outputDir>/sources/ (-sources JARs).

Plugin Installation

  1. Build the plugin ZIP:

    ./gradlew :plugin:buildPlugin

    Output: plugin/build/distributions/plugin-2.0.0-SNAPSHOT.zip

  2. In IntelliJ IDEA: Settings → Plugins → ⚙ → Install Plugin from Disk Select the ZIP file and restart the IDE.

Plugin Configuration

Open Settings → Build, Execution, Deployment → Felix Bundle Extractor.

Setting Description
Bundles directory Absolute path to the Felix launchpad bundles directory (e.g. crx-quickstart/launchpad/felix)
Include groupIds Regex — only bundles whose groupId matches are extracted (leave blank for all)
Exclude groupIds Regex — bundles whose groupId matches are skipped
Exclude artifactIds Regex — bundles whose artifactId matches are skipped
Exclude non-Maven artifacts Skip bundles that have no embedded pom.xml
When sources cannot be found Ask before decompiling / Always decompile / Never decompile
Align decompiled sources On by default: statements sit on their original line numbers (see below); off = compact files

Click Extract / Refresh Bundles Now to run extraction immediately after saving settings.

Debugging Decompiled Sources

Decompiled sources are attached to the bundle JARs, so they are searchable and debuggable. Decompiled code does not line up with the original line numbers, so two things happen:

  1. Realignment. Fernflower runs with the same options as IntelliJ's own decompiler, so each statement gets a trailing // <original line> marker. The output is then realigned so that statements land on their original line numbers: blank lines are inserted where the decompiled code is too short, and where it is too long, blank lines are dropped and structural lines such as } are joined onto the line above (only when that lands the statement exactly). Debuggers (also outside IntelliJ, for the CLI output) then use the bytecode lines as-is, and IntelliJ's "Source code does not match the bytecode" check passes. Statements the decompiler emits out of source order (mostly inner classes and reordered if/else branches) cannot be realigned. The cost is length: aligned files are about as long as the original source (on AEM bundles ~1.8x the compact decompiled output), with blank lines where comments and Javadoc used to be. Turn it off with Align decompiled sources to original line numbers (plugin) or --no-realign (CLI); the plugin's line mapping below still keeps IntelliJ debugging correct.
  2. Line mapping (plugin). For those remaining statements, the plugin turns the markers into a debugger line mapping, both when the file is opened and before the debugger resolves a stop, stack frame or breakpoint in it. IntelliJ may still show the "does not match" warning for those methods; the debugger lands on the right statement regardless.

Sources decompiled by older plugin versions have no markers and are not realigned: delete .idea/felix-bundles/sources/ and run Extract / Refresh Bundles Now again.

To trace the line mapping, enable debug logging for #be.orbinson.felix.bundle.intellij in Help → Diagnostic Tools → Debug Log Settings; messages go to idea.log.

Building

Requires Java 21. Ensure JAVA_HOME points to a Java 21 JDK, then:

./gradlew :core:build          # compile + test core library
./gradlew :cli:shadowJar       # build standalone fat JAR
./gradlew :plugin:buildPlugin  # build IntelliJ plugin ZIP

License

MIT

About

Felix Bundle Extractor - Sorts and decompiles your Felix / OSGi bundles in to a searchable directory

Resources

Stars

5 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages