Ancient Programming

What I encounter in my software part of life is in danger of being commented upon here

Archive for the 'maven' Category

Any good maven support for Google Appengine?

Posted by Jacob von Eyben on 5th June 2009

Yesterday I created a appengine project testing the JPA/Spring/Wicket stack.

This was created using the build.xml file found in the appengine documentation. It all worked fine, but I would like to build my project using maven so I started looking for a good maven plugin.

I found this blog talking about what features a good plugin should contain and a guy from the kindleit company claiming that they actually had implemented a maven-gae-plugin capable of executing most of these tasks.

Unfortunately I ran into several problems using this plugin, hence I have created an issue.

Untill these tasks in the issue has been fixed I would like to use another plugin.
Can anybody guide me in the direction of a more stable plugin?

Posted in java, maven | 1 Comment »

How to create macros for maven-site-plugin

Posted by Jacob von Eyben on 5th June 2008

Many maven projects uses the maven site plugin to generate there documentation.

The maven-site-plugin uses the doxia to let authors write xdoc, apt and fml documents as the source for there project documentation. These written documents is processed by doxia to generate html and merged into the complete project site by the maven-site-plugin.

I found doxia and especially the apt language somehow lacking in functionality. I would like to use the syntaxhighlighter to be able to highlight code examples on the fixedformat4j project.

Doxia comes out-of-the-box with a small bunch of macros and you have the ability to write custom macros as well.

Custom macro

I wrote a simple macro based on the core snippet macro:


  Doxia :: syntaxhighlighter


Changes to the snippet plugin:

  public void execute(Sink sink, MacroRequest request)
      throws MacroExecutionException {
    System.out.println("ancientprogramming - running execute");
    String id = (String) request.getParameter("id");

    required(id, "id");

    String urlParam = (String) request.getParameter("url");

    String fileParam = (String) request.getParameter("file");

    String codeParam = (String) request.getParameter("code");

    required(codeParam, "code");

    URL url;

    if (!StringUtils.isEmpty(urlParam)) {
      try {
        url = new URL(urlParam);
      catch (MalformedURLException e) {
        throw new IllegalArgumentException(urlParam + " is a malformed URL");
    } else if (!StringUtils.isEmpty(fileParam)) {
      File f = new File(fileParam);

      if (!f.isAbsolute()) {
        f = new File(request.getBasedir(), fileParam);

      try {
        url = f.toURL();
      catch (MalformedURLException e) {
        throw new IllegalArgumentException(urlParam + " is a malformed URL");
    } else {
      throw new IllegalArgumentException("Either the 'url' or the 'file' param has to be given.");

    StringBuffer snippet;

    try {
      snippet = getSnippet(url, id);
    catch (IOException e) {
      throw new MacroExecutionException("Error reading snippet", e);

   sink.rawText("... syntaxhighlighter prefix ...");
   sink.rawText("... syntaxhighlighter postfix ...");

Note: wordpress obfuscates the above code where I wrote the syntax hightlighter pre and post fix. You can see what you actually should write at the syntaxhighligther project.

Use custom macro
To be able to use the macro you have to add your macro as dependency to the maven-site-plugin:


Now you can use the macro by writing the following in your apt files:


Change your site template
Before the the source can be highlighted in your documentation you should add the syntaxhighlighter javascript and stylesheets to your template.
See how to change your template here.

Posted in how to, java, maven | 1 Comment »