Getting started with jEdit hacking

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!

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…):

Categories:

Tags:

No TrackBacks

TrackBack URL: http://tu.wesolek.net/cgi-bin/mt/mt-tb.cgi/13

Getting started with jEdit hacking

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.\n\nIn a few articles I'll write my way through the mysteries of jEdit hacking, from the point of view of a newcomer.\n\nIn this article we will download, compile and debug with Eclipse the basic jEdit, without plugins.\n\nFetching the sources\n-----\n\nBecause I prefer Git to SVN, I decided to convert jEdit repo to local Git repos. So `git svn` to the rescue!\n[code:bash]\ngit svn init http://jedit.svn.sourceforge.net/svnroot/jedit --branches=jEdit/branches/ --tags=jEdit/tags/ --trunk=jEdit/trunk/\ngit svn fetch\n[/code]\n\nWell, 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:\n\n[code:bash]\nwhile ! git svn fetch; do\n\techo \"*** Retrying ***\"\ndone\n[/code]\n\nIf you're OK with only SVN, just checkout the repo:\n[code:bash]\nsvn co http://jedit.svn.sourceforge.net/svnroot/jedit/jEdit/trunk jEdit\n[/code]\n\nThe 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.\n\nBuilding\n-----\n\njEdit build system is based on Ant. In Ubuntu required packages can be installed with:\n[code:bash]\naptitude install ant ant-optional\n[/code]\nplus you will need a Java compiler -- I won't go into details here, leave a comment if you have problems.\n\n`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...):\n[code:bash]\n# warning settings\nbuild.nowarn=true\nbuild.deprecation=false\nbuild.compilerarg= \n[/code]\n\nNow, just compile:\n[code:bash]\nant build\n# or just ant\n[/code]\n\nRunning\n------\n\nIf you want to run the just-compiled code, do it with\n[code:bash]\nant run\n[/code]\n\nFor serious hacking you will probably need debugger set up. I prefer Eclipse for my daily programming jobs, so we'll use that.\n\nIn 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.\n\njEdit 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.\n\nConfigure 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:\n\n\n\nThis 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.\n\nThe 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:\n[code:bash]\nant run-debug\n[/code]\n\njEdit virtual machine will stop waiting for a connection from Eclipse (with one minute timeout). In Eclipse, create debug configuration (_Run_ -- _Debug Configurations..._ -- _Remote Java Application_ -- _New launch configuration_) and point to `localhost` on port `5005`. Click _Debug_ and here you go, debugging jEdit. Good luck!\n