How to Use Make with jEdit Projects: Step-by-Step

Make for jEdit: A Beginner’s Guide to Building Plugins

jEdit is a powerful, extensible text editor written in Java. If you’re developing plugins for jEdit, using Make (or a Makefile-like workflow) can simplify building, packaging, and testing your plugin. This guide walks through a minimal, practical setup using GNU Make to compile Java sources, create a plugin jar, and prepare a jEdit plugin distribution.

Prerequisites

  • Java JDK installed (javac, jar on PATH).
  • GNU Make installed.
  • jEdit plugin API jar (typically jedit.jar) available — place it in a lib/ directory or use your local jEdit installation.

Project layout (reasonable default)

Use this simple structure:

  • src/ — Java source files
  • lib/ — third-party jars (e.g., jedit.jar)
  • build/ — compiled classes (generated)
  • dist/ — plugin jar output
  • plugin.xml — jEdit plugin descriptor
  • Makefile

Example Makefile

Save this as Makefile in your project root.

Code

JAVAC = javac JAR = jar SRC_DIR = src BUILD_DIR = build DIST_DIR = dist LIB_DIR = lib CLASSES = \((shell find \)(SRC_DIR) -name ‘*.java’) CP = $(LIB_DIR)/jedit.jar.PHONY: all clean jar

all: $(DIST_DIR)/MyPlugin.jar

\((BUILD_DIR)/%.class: \)(SRC_DIR)/%.java

mkdir -p $(dir $@) $(JAVAC) -cp $(CP) -d $(BUILD_DIR) $< 

classes: \((CLASSES:\)(SRC_DIR)/%.java=$(BUILD_DIR)/%.class)

$(DIST_DIR)/MyPlugin.jar: classes plugin.xml

mkdir -p $(DIST_DIR) cp plugin.xml $(BUILD_DIR)/ cd $(BUILD_DIR) && $(JAR) cf ../$(DIST_DIR)/MyPlugin.jar . 

Notes:

  • This Makefile compiles each Java file into build/, copies plugin.xml into build/, then creates a jar in dist/.
  • Adjust CP to include any other dependencies in lib/.

plugin.xml essentials

A minimal plugin.xml (placed at project root) should contain plugin metadata and lists of classes to load. Example skeleton:

Code

<author>Your Name</author> <description>Short description of the plugin.</description> 

jEdit expects plugin.xml inside the plugin jar at root.

Compiling multiple packages

The Makefile above uses find to enumerate sources and a pattern rule to compile to mirrored paths under build/. This keeps package structure intact.

Adding resources

If your plugin includes resources (icons, properties), place them under src alongside Java packages and ensure they are copied into build/ before creating the jar:

Add a rule:

Code

resources: rsync -a –include=’/’ –include=’.properties’ –include=’.png’ –exclude=’\((SRC_DIR)/ \)(BUILDDIR)/

Make jar depend on resources.

Testing in jEdit

  • Copy dist/MyPlugin.jar into jEdit’s plugins/ directory (or use package manager if you create a proper zip).
  • Start jEdit and confirm your plugin loads (check Plugins menu / About Plugins).

Packaging for distribution

jEdit plugins are typically distributed as .jar placed in the plugins/ directory or packaged as jedit-plugin zip including README and license. For a zip step, add in Makefile:

Code

.PHONY: package package: all

zip -r $(DIST_DIR)/MyPlugin-plugin.zip -j $(DIST_DIR)/MyPlugin.jar README.md LICENSE 

Tips and troubleshooting

  • Ensure plugin.xml is at the jar root.
  • Keep classpath consistent when compiling; include jedit.jar to access API headers.
  • Use verbose javac errors: add -Xlint to JAVAC variable when debugging.
  • For larger projects, consider using Ant, Maven, or Gradle; Make is lightweight and works well for small plugins.

Summary

This guide gives a minimal Make-based workflow to compile Java sources, package plugin.xml and resources, and produce a jEdit plugin jar. It’s a straightforward approach for small-to-medium jEdit plugins; migrate to a build tool like Maven/Gradle when dependencies or complexity grow.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *