Recently in jEdit Category

Getting started with jEdit hacking: plugin compilation

| Comments | No TrackBacks

In the first installment of jEdit hacking series I described how to get jEdit running from the repo. However, jEdit wouldn’t be what it is without plugins. So, this time I’ll try to add a plugin. Compiled on our own, of course, not from the Plugin Central!

As described on the mailing list, there’s a problem with Sessions plugin in recent compilations of jEdit. The cause is probably API changes. The bug is fixed in the repo. I wanted the plugin, so plugin compilation happened.

First, let’s obtain the plugin. No surprise here, as the plugin is in the same repo, as jEdit itself:

mkidr plugins
cd plugins
svn co http://jedit.svn.sourceforge.net/svnroot/jedit/plugins/Sessions/trunk Sessions

The only thing we need to do to compile Sessions is to know the location of jedit.jar. After successful compilation of basic jEdit it should be in its build directory. If you followed the structure of directories presented in my tutorials (jEdit next to plugins), relative path is ../../jEdit/build/jedit.jar. For one-shot compilation the required property can be given on the command line:

ant -Djedit.install.dir=../../jEdit/build/

And… that’s it! One level above (in plugins) you should have Sessions.jar. After installation of Sessions from Plugins Central, close jEdit (make sure it is not running in the background!) and put the compiled JAR into ~/.jEdit/jars (see http://plugins.jedit.org/install.php for details, also on Windows), replacing the downloaded one (you can make backup if you want). Start jEdit again and check in Plugin Manager if the version is greater than the one in the repo (1.5.1 vs. 1.4.3 from the repo, at the time of writing).

Getting started with jEdit hacking

| Comments | No TrackBacks

I really like jEdit. It’s not my choice for the environment of multi-file, complicated projects, but I use it very often for ad-hoc text, code and XML editing. So I decided to give back to the community a little and hack jEdit a bit.

In a few articles I’ll write my way through the mysteries of jEdit hacking, from the point of view of a newcomer.

In this article we will download, compile and debug with Eclipse the basic jEdit, without plugins.

Fetching the sources

Because I prefer Git to SVN, I decided to convert jEdit repo to local Git repos. So git svn to the rescue!

git svn init http://jedit.svn.sourceforge.net/svnroot/jedit --branches=jEdit/branches/ --tags=jEdit/tags/ --trunk=jEdit/trunk/
git svn fetch

Well, because SourceForge likes to drop connection randomly on large SVN transfers, it’ll be much easier to wrap the last line in a while loop:

while ! git svn fetch; do
    echo "*** Retrying ***"
done

If you’re OK with only SVN, just checkout the repo:

svn co http://jedit.svn.sourceforge.net/svnroot/jedit/jEdit/trunk jEdit

The docs says you’ll also need build-support module, but for building plain jEdit (without modules), you don’t need it. If you ever need it, use the above instructions for fetching jEdit, replacing jEdit in the URL and path with build-support. Make sure to put build-support dir next to jEdit one.

Building

jEdit build system is based on Ant. In Ubuntu required packages can be installed with:

aptitude install ant ant-optional

plus you will need a Java compiler — I won’t go into details here, leave a comment if you have problems.

README.SRC.txt is pretty straight-forward about the required steps to build the system. First, you must configure jEdit build system. Copy build.properties.sample to build.properties and set up what necessary. Most defaults are fine, at the first shot I only setup the deprecation and warning policy (jEdit compilation gives a lot of warnings…):

# warning settings
build.nowarn=true
build.deprecation=false
build.compilerarg=     

Now, just compile:

ant build
# or just ant

Running

If you want to run the just-compiled code, do it with

ant run

For serious hacking you will probably need debugger set up. I prefer Eclipse for my daily programming jobs, so we’ll use that.

In Eclipse, create new Java project, name it ‘jEdit’ (surprise!) and place it anywhere you want. Now, remove the default src folder and create a linked folder to the place where jEdit lives.

jEdit doesn’t use a separate source folder, sources are scattered in the main folder. Fortunatelly, there are not so many top-level packages, so not so many sub-folders.

Configure the project builder to use the just linked folder as the source folder. Configure inclusion/exclusion filter — we only need org.* packages. Resulting setting look like this:

eclipse-project-settings.png

This will allow us to setup breakpoints, navigate and read the code easily. I don’t care about Eclipse compilation as long as there are no errors.

The easiest way to debug jEdit is to run it outside Eclipse, with debugging agent, and to run remote debugging in Eclipse. To run jEdit with debugging server use:

ant run-debug

jEdit virtual machine will stop waiting for a connection from Eclipse (with one minute timeout). In Eclipse, create debug configuration (RunDebug Configurations…Remote Java ApplicationNew launch configuration) and point to localhost on port 5005. Click Debug and here you go, debugging jEdit. Good luck!

About this Archive

This page is an archive of recent entries in the jEdit category.

Android is the previous category.

Movable Type is the next category.

Find recent content on the main index or look in the archives to find all content.

jEdit: Monthly Archives

Pages

OpenID accepted here Learn more about OpenID