Monday, 30 August 2010

Jigsaw: WorldClock with Maven

In the previous post I built WorldClock using just the command line, this time I'll use Maven for compiling.

1. Get Maven
sudo apt-get install maven2
Set JAVA_HOME to Jigsaw, so that Maven uses Jigsaw:
export JAVA_HOME=~/dev/jigsaw/build/linux-i586/jdk-module-image


2. Adjusting the paths for Maven
Create new directories:
mkdir -p ~/dev/worldclock/panel/src/main/java

mkdir -p ~/dev/worldclock/application/src/main/java

Move the files:
mv /home/ludovic/dev/worldclock/panel/src/lh.worldclock.panel ~/dev/worldclock/panel/src/main/java
mv /home/ludovic/dev/worldclock/panel/resources ~/dev/worldclock/panel/src/main/

mv /home/ludovic/dev/worldclock/application/src/lh.worldclock.panel ~/dev/worldclock/application/src/main/java
mv /home/ludovic/dev/worldclock/application/resources ~/dev/worldclock/application/src/main/

3. Add the poms



Panel ( gedit ~/dev/worldclock/panel/pom.xml & ):

<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>lh.worldclock</groupId>
  <artifactId>panel</artifactId>
  <packaging>jar</packaging>
  <version>0.7-SNAPSHOT</version>
  <name>Worldclock Panel</name>
  <url>https://worldclock-application.dev.java.net/</url>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Application ( gedit ~/dev/worldclock/application/pom.xml & ):

<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>lh.worldclock</groupId>
  <artifactId>application</artifactId>
  <packaging>jar</packaging>
  <version>0.7-SNAPSHOT</version>
  <name>Worldclock Application</name>
  <url>https://worldclock-application.dev.java.net/</url>
  <dependencies>
    <dependency>
      <groupId>lh.worldclock</groupId>
      <artifactId>panel</artifactId>
      <version>0.7-SNAPSHOT</version>
    </dependency>
  </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <version />
                        <L>../modules</L>
                    </compilerArguments>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
(somehow using <compilerArgument> -L ../modules</compilerArgument> does not work)

4. Recreate the library
rm -rf ~/dev/worldclock/modules
$JIG/bin/jmod create -L ~/dev/worldclock/modules
 5. Compile and add to the library
Panel:
cd ~/dev/worldclock/panel

mvn install

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/panel/build -r ~/dev/worldclock/panel/src/main/resources lh.worldclock.panel
Application:
cd ~/dev/worldclock/application

mvn install

$JIG/bin/jmod -L ~/dev/worldclock/modules install ~/dev/worldclock/application/build -r ~/dev/worldclock/application/resources lh.worldclock.application
6. Run
$JIG/bin/java -L ~/dev/worldclock/modules -m lh.worldclock.application

No comments: