How to build a Confluence Macro Plugin

The goal is to build a small macro plugin deployable via the Confluence plugin API rendering some spaces. Please note that I am going to build the plugin using just Maven and not the Atlassian Maven Wrapper called the “Atlassian Plugin SDK” – more information about that is available at the Atlassian website. The macro output will be rendered using a Velocity template and all messages are stored for i18n in properties files bundled with the plugin. ...

April 13, 2010 · 7 min · 1431 words · Micha Kops

Create a SOAP client using the JAX-WS Maven Plugin

Having written the article “How to build a Confluence SOAP client in 5 minutes” some readers asked me for some more information and help using the JAX-WS plugin that I mentioned in the article instead of the Axis plugin – so here we go ;) Steps Create a simple maven project first using archetype:create or archetype:generate mvn archetype:create -DgroupId=com.hascode.jaxws -DartifactId=soap-tutorial We get a pom.xml like this: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.jaxws</groupId> <artifactId>soap-tutorial</artifactId> <version>0.1</version> </project> ...

April 8, 2010 · 3 min · 530 words · Micha Kops

Named Queries in Grails 1.2

They built a nice new feature in Grails 1.2 called “named queries“. Named queries can be defined in a domain class as static properties and support the criteria builder syntax. Examples package testapp class User { String name int iq int age static namedQueries = { dumbUsers { int referenceIq = 60 lt 'iq' , referenceIq } nameStartsWith { letter -> like 'name', '${letter}%' } midAges { between('age', 20, 40) } } } // count dumb users println User.dumbUsers.count() // print amount of users, usernames starting with an 'a' User.nameStartsWith('a').count() ...

April 6, 2010 · 1 min · 111 words · Micha Kops

Manage dependencies with the Maven Dependency Plugin

In a maven project there are lots of dependencies to handle – often one wants to know which version of a software comes from. The solution to this problem is the Maven Dependency Plugin which helps you to find used/unused/declared/undeclared dependencies in your project. In addition the plugin allows you to copy or unpack artifacts. Maven Goals dependency:copy – copies artifacts defined in the config to a specified location – details available here dependency:resolve – resolves all dependencies and shows the versions dependency:go-offline – resolves everything the project needs like dependencies, plugins and reports dependency:analyze - parses the dependencies and shows if they are used/declared/unused/undeclared .. dependency:analyze-dep-gmt - finds mismatches between resolved dependencies and those listed in the dependencyManagement section dependency:tree – shows a nice dependency tree for the maven project ...

April 4, 2010 · 2 min · 321 words · Micha Kops

Snippet: Simple One-Minute IMAP Client

Building a simple IMAP Client that displays the subject of the messages in the “inbox” Folder using Maven (I just like Maven). Project Setup / Maven Create a new Maven project mvn archetype:create -DgroupId=com.hascode.imap -DartifactId=imap-client Edit your pom.xml and add some dependencies <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.imap</groupId> <artifactId>imap-client</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.2</version> </dependency> </dependencies> </project> Creating the E-Mail Client Create a package .. something like com.hascode.imap.client ;) Create a simple mail client using javax.mail in a class named ImapClient package com.hascode.imap.client; import javax.mail.Folder; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Store; public class ImapClient { private Session session = null; private Store store = null; private String host = null; private String userName = null; private String password = null; public ImapClient(String host, String userName, String password){ this.host = host; this.userName = userName; this.password = password; } public boolean getMail() throws MessagingException { session = Session.getDefaultInstance(System.getProperties(),null); // session.setDebug(true); System.out.println("get store.."); store = session.getStore("imaps"); System.out.println("connect.."); store.connect(this.host, this.userName, this.password); System.out.println("get default folder .."); Folder folder = store.getDefaultFolder(); folder = folder.getFolder("inbox"); folder.open(Folder.READ_ONLY); System.out.println("reading messages.."); Message[] messages = folder.getMessages(); for(Message m:messages){ System.out.println(m.getSubject()); } return false; } } ...

April 3, 2010 · 2 min · 295 words · Micha Kops

How to integrate Android Development Tools and Maven

With the Maven Android Plugin it is possible to build and deploy/undeploy your android app and start/stop the emulator – if you’re used to maven you won’t be going without it ;) If you’re interested in signing your apk using maven – take a look at this article Project Setup Create an android project using the android tool We need some dependencies – so create a pom.xml in the project’s root directory – I took this from the plugin samples and modified it: <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (C) 2009 Jayway AB Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.android.app</groupId> <artifactId>demo</artifactId> <packaging>apk</packaging> <name>hasCode.com - Sample Android App using the Maven Android Plugin</name> <version>0.1</version> <dependencies> <dependency> <groupId>android</groupId> <artifactId>android</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <!--<finalName>${artifactId}</finalName>--> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>maven-android-plugin</artifactId> <configuration> <sdk> <path>${env.ANDROID_HOME}</path> <platform>3</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> </configuration> <extensions>true</extensions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> </project> ...

April 2, 2010 · 3 min · 453 words · Micha Kops

How to build a Confluence SOAP client in 5 minutes

In this tutorial we are going to build a SOAP client for the popular Confluence Wiki in about five minutes. The client is going to receive rendered HTML Markup from a specified Confluence Page. Prerequisites A running Confluence Installation with SOAP API enabled – if you don’t already have one take a look at this article or if you’ve got the Atlassian Plugin SDK installed .. start a standalone instance using atlas-run-standalone .. Maven – never go without it ;) Five minutes of your life time .. ...

March 28, 2010 · 3 min · 537 words · Micha Kops

Confluence Developer Instance Quick Setup

This short tutorial shows how to set-up a developer instance of the popular Confluence Wiki from Atlassian in a few minutes. It’s a prerequisite for a few following tutorials regarding the Confluence API and plug-in development for this system. We want a quick install so we are going to run Confluence with the embedded servlet container and HSQL database. update Meanwhile it is way much easier to use Atlassian’s Plugin SDK using atlas-mvn run or atlas-mvn-run-standalone –product confluence –version x.x.x but if you need to setup an independant instance, this article still might be useful. ...

March 26, 2010 · 3 min · 431 words · Micha Kops

How to build a quick Lucene Search

Helo – today I wanted to post a small tutorial for a small index and search operation using the Lucene indexer and Maven for the project setup. Setup Create an empty Maven sample project using the Eclipse Maven Plugin or use the following console command: mvn archetype:create -DgroupId=com.hascode.demo.search -DartifactId=lucene-sample Here is my pom.xml there are some dependencies for Lucene defined: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.demo.search</groupId> <artifactId>lucene-sample</artifactId> <version>0.0.1-SNAPSHOT</version> <name>My Lucene Search Sample</name> <description>Lucene Search Sample</description> <dependencies> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>lucene</groupId> <artifactId>lucene</artifactId> <version>1.4.3</version> </dependency> </dependencies> </project> ...

March 25, 2010 · 3 min · 540 words · Micha Kops

How to add a local lib directory to Maven

Sometimes there is a dependency not available at a remote repository and one is too lazy to set up a local maven repository – that’s when one adds a directory in the project structure and wants maven to find dependencies there. Create a directory called “lib” in the project root Add the following markup to the pom.xml inside the <repositories>-Tag (create if it does not exist): <repository> <id>lib</id> <name>lib</name> <releases> <enabled>true</enabled> <checksumPolicy>ignore</checksumPolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>file://${project.basedir}/lib</url> </repository> ...

March 18, 2010 · 1 min · 206 words · Micha Kops