Skip to content

jbangdev/jbang-eclipse

Repository files navigation

JBang / Eclipse integration POC

This experimental plugin aims to let you author JBang scripts in Eclipse with ease.

Features:

  • Import JBang Scripts as projects
  • Synchronize JBang Dependencies to existing projects
  • Automatically configures JDKs managed by JBang
  • Validation of JBang scripts on file save
  • Automatic configuration of Annotation Processors
  • JBang runtime management

Cuurently supports

  • //DEPS / @Grab dependencies
  • //JAVA version
  • //SOURCES additional sources

By default, the plugin will try to find JBang from the PATH, from ~/.jbang/bin or ~/.sdkman/candidates/jbang/current/bin/jbang. Alternate locations can be defined in Preferences > JBang > Installations

Import JBang Script as project

Import JBang scripts in Eclipse: Import Project... > JBang > JBang script.

import-jbang

A project named after the script file will be created in the current workspace, that will link to the real script file.

Synchronize JBang

The Synchronize JBang command is available when right-clicking on a JBang script in an existing project. If the script belongs to a non-Java project, the Java nature will be added to that project. The source folder containing the JBang file will automatically be added to the project's classpath. The JBang Dependencies classpath container will be added to the classpath as well.

Jun-20-2022 19-32-10

Caveats:

  • JBang files and dependencies will leak to the project's main and test-scoped sources
  • the project's main files and dependencies will leak to the JBang script
  • If the script file is at the root of the project and there are other source folders nested beneath that root, compilation errors will occur in those folders
  • Other build tools (m2e/buildship) might conflict with the classpath changes. Typically, Updating the Maven project configuration would remove the JBang source folder and its classpath container. Re-running Synchronize JBang will be necessary to get completion and validation in JBang scripts.

Recommended 3rd party plugins

  • Automatic source downloads: Currently, JBang dependencies sources are not automatically fetched. You can install the PDE source lookup plugin to automatically download sources from Maven Central, when opening a type from a JBang dependency.

Installation

JBang Eclipse Integration is available in the Eclipse Marketplace. Drag the following button to your running Eclipse workspace. (⚠️ Requires the Eclipse Marketplace Client)

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

Alternatively, in Eclipse:

  • open Help > Install New Software...
  • work with: https://github.com/jbangdev/jbang-eclipse/releases/download/latest/
  • expand the category and select the Jbang Eclipse Feature
  • proceed with the installation
  • restart Eclipse

Build

Requires Java 17 or more recent to build/run

Open a terminal and execute:

./mvnw clean package

You can then install the generated update site from dev.jbang.eclipse.site/target/repository, also zipped as dev.jbang.eclipse.site-<VERSION>-SNAPSHOT.zip

License

EPL 2.0, See LICENSE file.