I haz Maven power!

UPDATE This is out of date following JME3’s Nifty 1.3 / jheora / JOGL / ISO DATE changes which happened at the beginning of March 2011. I’ll post the updated material before March 14th



I have a python (well … Jython 2.5.1) script that:

1 - download the jme3 snapshot

2 - unpacks it

3 - builds and installs it into my local mvn repo (including sources!!)

4 - builds a few “dependency aggregate” projects to make life easier



I like this because … mvn is awesome and works well with me for Eclipse & Hg



The files can be downloaded from https://jme3mvn.peter-lavalle.googlecode.com/hg/ (there is a certificate warning thanks to Google’s laziness. The files are in plain text so you can double check them for safety)

Also see https://wiki.jmonkeyengine.org/legacy/doku.php/jme3_maven



You need to:

1 - put the files in a folder

2 - run install.py from that folder

3 - make POMs that rely on the produced artifacts



If you have ANY problems please post them here so I can take a whack at correcting them



(EDITED to be prettier)

1 Like

Just one simple question, why should I use maven when I can use ant buildscripts?

Because orange juice tastes better than apple juice



I don’t know if you’re asking me to explain why I want to use it, or if you’re asking me to sell you on it. I’m not using Maven to build JME, this is a script to install JME3 into a computer’s Maven repo

… is this the wrong forum for sharing things?

I thought it is only for jme stuff that should go t the svn, but whatever



No I more wanted to find out what are the basic differences (if there are any real ones) between ant and maven.

I’m not a maven expert, but some benefits come to mind:



Ant scripts are project wide, maven knows about dependencies between projects. If I have my project using jme3, I can ask maven to deploy my project with all dependencies - and it will prepare a directory with my compiled project, 3rd part libraries my project is using, compiled jme3 and jme3 3rd party libraries. With ant scripts, I will start to start referencing internals of jme3 layout to get jars copied



This benefit applies even if you already have ant scripts. Most benefits of maven are that you don’t have to write them in first place


  • you got nice separate compile/test/runtime classpath and deploy dependencies (so you don’t need to distribute junit and test classes with ‘runtime’ distribution)
  • automatic download and update of third party libraries, including deep dependency graphs
  • packaging/repackaging/deployments etc mostly preconfigured
  • reasonable way to push snapshot/releases to repository to be automatically discovered by further projects



    Most of the stuff can be achieved by hand with ant scripts (probably except automatic download of deep dependencies, as it requires very specific metadata). It is just that you don’t need to write those scripts if you have a new projects.



    There are also some dark sides of maven - it is very often failing in corporate/firewalled environments because of happily assuming everything is downloadable as needed, it expects certain project structure which I personally find way too elaborate and you sometimes spend hours trying to get it to do small thing which would take one line in ant, only to discover that somebody has already made a plugin for that, with hundred configuration options which has to be downloaded from obscure repository and installed into your pom file with extra 20 lines of xml…



    Anyway, love it or hate it, it is kind of standard of java dependency handling right now. I suppose it would be very nice to have jme3 available somewhere as snapshot maven package, with all it’s dependencies properly mavenised. With that, creating jme3-dependent project would mean just adding a repository url to pom, clicking on jme3 dependency in wizard and everything would be downloaded/installed automatically. What is ever better, on deployment, you could ask for all the jars (jme3 proper, lwjgl, openal etc, etc) to be deployed with your app or even everything repackaged into one big jar if needed.



    Basically, it is shifting some ant/deployment burden from developers of every project using jme3 to jme3 developers. And to be honest, it doesn’t even have to be done by jme3 team itself - it is perfectly possible of somebody just deploying it to some repository on his own (after preparing pom file).
No I more wanted to find out what are the basic differences (if there are any real ones) between ant and maven

Ant = a Make replacement
Maven = an IDE's project manager replacement.

Maybe "Ant on steroids. It gently suggests some conventions, and allows you to (mostly) fire and forget your dependencies"

Sorry if this constitutes "flame" but I have a different experience;
... often failing in corporate/firewalled environments ...

We had a pretty neurotic firewall at work that never noticed or cared what we downloaded by HTTP / Maven

... expects certain project structure which I personally find way too elaborate ...

YaY! All project / source trees will look the same. You can meddle with it to change this if you really want to, but I like the idea that projects will start to have identical layouts.

... spend hours trying to get it to do small thing which would take one line in ant, only to discover that somebody has already made a plugin for that, with hundred configuration options which has to be downloaded from obscure repository and installed into your pom file with extra 20 lines of xml …

If it's hard to do in Maven, use something else - I chose Jython

I've had my own problems with it. I think that the amount of XML required to switch from Java 1.4 to Java X.X is a wee bit excessive. There are a few features I've probably thrown 20 hours at (since November) and seen no return on the investment. I'm still much happier with it than I was with V$ or make

We had a pretty neurotic firewall at work that never noticed or cared what we downloaded by HTTP / Maven


In my previous 4 jobs (last 10 years) there was not a SINGLE case where development server machine was allowed to connect to internet. And I do want server side builds... Of course, solution for that is local repository mirror (which is good idea anyway), but this requires some considerable upfront effort (especially if this mirror also has no internet access...)


YaY! All project / source trees will look the same. You can meddle with it to change this if you really want to, but I like the idea that projects will start to have identical layouts.

But why they have to be identically ugly ? ;)

Yes, I’ll concede that point - Maven is painful when you’re trying to use it on a host without HTTP access

You’ve always got Ivy+ant if you want dependency management + ant, and at least within jme itself running the test phase would be fast from either Maven or Ant - coz there aren’t any :wink:

Hi folks,



I created a simple pom.xml for the jme3 branch (http://jmonkeyengine.googlecode.com/svn/branches/jme3) …

With this it’s easy to build jme3 with maven (or even better with m2eclipse directly in eclipse g). Here is the code:



[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/xsd/maven-4.0.0.xsd”>

<modelVersion>4.0.0</modelVersion>

<groupId>com.jme3</groupId>

<artifactId>jMonkeyEngine3</artifactId>

<version>3.0.0-SNAPSHOT</version>

<build>

<plugins>

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>2.3.2</version>

<configuration>

<source>1.6</source>

<target>1.6</target>

<encoding>UTF-8</encoding>

</configuration>

</plugin>

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>build-helper-maven-plugin</artifactId>

<executions>

<execution>

<id>add-source</id>

<phase>generate-sources</phase>

<goals>

<goal>add-source</goal>

</goals>

<configuration>

<sources>

<!-- <source>${basedir}/src/android</source> -->

<source>${basedir}/src/core</source>

<source>${basedir}/src/core-data</source>

<source>${basedir}/src/core-plugins</source>

<source>${basedir}/src/desktop</source>

<source>${basedir}/src/desktop-fx</source>

<source>${basedir}/src/games</source>

<source>${basedir}/src/jbullet</source>

<!-- <source>${basedir}/src/jheora</source> -->

<source>${basedir}/src/jogg</source>

<source>${basedir}/src/jogl</source>

<!-- <source>${basedir}/src/jogl2</source> -->

<source>${basedir}/src/lwjgl-oal</source>

<source>${basedir}/src/lwjgl-ogl</source>

<source>${basedir}/src/networking</source>

<source>${basedir}/src/niftygui</source>

<source>${basedir}/src/ogre</source>

<source>${basedir}/src/pack</source>

<source>${basedir}/src/terrain</source>

<source>${basedir}/src/test</source>

<source>${basedir}/src/test-data</source>

<source>${basedir}/src/tools</source>

<source>${basedir}/src/xml</source>

</sources>

</configuration>

</execution>

</executions>

</plugin>

<plugin>

<artifactId>maven-antrun-plugin</artifactId>

<version>1.6</version>

<executions>

<execution>

<phase>package</phase>

<configuration>

<ant antfile="${basedir}/build.xml">

<target name=“jar” />

</ant>

</configuration>

<goals>

<goal>run</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</build>

<dependencies>

<dependency>

<groupId>android</groupId>

<artifactId>android</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/android/android.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jbullet</groupId>

<artifactId>asm-all</artifactId>

<version>3.1</version>

<systemPath>${basedir}/lib/jbullet/asm-all-3.1.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jbullet</groupId>

<artifactId>jbullet</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jbullet/jbullet.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jbullet</groupId>

<artifactId>stack-alloc</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jbullet/stack-alloc.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jbullet</groupId>

<artifactId>vecmath</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jbullet/vecmath.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jogl</groupId>

<artifactId>jme3-natives</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jogl/jME3-jogl-natives.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jogl</groupId>

<artifactId>jogl</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jogl/jogl.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jogl</groupId>

<artifactId>gluegen-rt</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jogl/gluegen-rt.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jogg</groupId>

<artifactId>j-ogg-oggd</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jogg/j-ogg-oggd.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>jogg</groupId>

<artifactId>j-ogg-vorbisd</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/jogg/j-ogg-vorbisd.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>niftygui</groupId>

<artifactId>nifty-examples</artifactId>

<version>1.1</version>

<systemPath>${basedir}/lib/niftygui/nifty-examples-1.1.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>niftygui</groupId>

<artifactId>xmlpull-xpp3</artifactId>

<version>1.1.4c</version>

<systemPath>${basedir}/lib/niftygui/xmlpull-xpp3-1.1.4c.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>niftygui</groupId>

<artifactId>nifty</artifactId>

<version>1.2-SNAPSHOT</version>

<systemPath>${basedir}/lib/niftygui/nifty-1.2-SNAPSHOT.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>niftygui</groupId>

<artifactId>nifty-default-controls</artifactId>

<version>1.2-SNAPSHOT</version>

<systemPath>${basedir}/lib/niftygui/nifty-default-controls-1.2-SNAPSHOT.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>niftygui</groupId>

<artifactId>nifty-style-black</artifactId>

<version>1.2-SNAPSHOT</version>

<systemPath>${basedir}/lib/niftygui/nifty-style-black-1.2-SNAPSHOT.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>swing-layout</groupId>

<artifactId>swing-layout</artifactId>

<version>1.0.4</version>

<systemPath>${basedir}/lib/swing-layout/swing-layout-1.0.4.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>swingext</groupId>

<artifactId>swing-layout</artifactId>

<version>1.0.3</version>

<systemPath>${basedir}/lib/swingext/swing-layout-1.0.3.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>lwjgl</groupId>

<artifactId>jinput</artifactId>

<version>2.5</version>

<systemPath>${basedir}/lib/lwjgl/2.5_jar/jinput.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>lwjgl</groupId>

<artifactId>lwjgl</artifactId>

<version>2.5</version>

<systemPath>${basedir}/lib/lwjgl/2.5_jar/lwjgl.jar</systemPath>

<scope>system</scope>

</dependency>

<dependency>

<groupId>lwjgl</groupId>

<artifactId>jME3-lwjgl-natives</artifactId>

<version>1.0</version>

<systemPath>${basedir}/lib/lwjgl/jME3-lwjgl-natives.jar</systemPath>

<scope>system</scope>

</dependency>

</dependencies>

</project>

[/xml]



Regards

Andreas