Please help solve a Maven mess when migrating an old project from ant / jar builds

I know this is a frequent one but I tried all previous solutions and got lost on the way.

Here we go:

I have the following structure: An old system called OB with four modules: Core, IO, Matching and GUI. IO and Matching reference Core, GUI references all the rest. Development is done in Eclipse with project references and an ANT script compiles the whole thing to 4 jars and a lib folder.

A newer system called ORE references these 4 jars. and has a bigger lib folder of which the OB lib folder is a subset.

I've been trying for a week to get this thing into a maven structure. I'll spare you the humongous mess I did and lets just say I'm open for concrete suggestions.

Thanks in advance,

Tomer

Answers


Given that you also use eclipse, and need a good way of integrating it, I would suggest you set it up as a multi module build, layed out from (minimum) 6 directories from root:

- build
- core
- io
- matching
- ob
- ore

Build is the master project to build it all. Add reference to all the modules from here

<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>
  <!-- The Basics -->
  <groupId>com.example</groupId>
  <artifactId>build</artifactId>
  <!-- Change Project version here. Do not use a property for this, Maven will complain -->
  <version>1.0-SNAPSHOT</version>

  <packaging>pom</packaging>
  <modules>
    <module>../core</module>
  </modules>
</pom>

Core and the others could refer back to this build pom as parent, but it is not necessary unless you have global settings in the build pom (such as compiler versions et al).

Instead, each project could be rather individual (but keep the version number the same). Given core is standalone, I could show you io instead:

<project>
  <modelVersion>4.0.0</modelVersion>
  <!-- The Basics -->
  <groupId>com.example</groupId>
  <artifactId>io</artifactId>
  <version>1.0-SNAPSHOT</version>

  <packaging>jar</packaging>

  <!--Parent is optional but useful if you need global settings in the build pom -->
  <parent>
    <groupId>com.example</groupId>
    <artifactId>build</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../build/pom.xml</relativePath>
  </parent>


 <!-- Refer back to other projects easily -->
 <dependencies>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>core</artifactId>
      <version>${project.version}</version>
    </dependency>
 </dependencies>

</project>

With this setup it is easy to import in eclipse (Import as Maven project). I usually find that the slight strict nature of maven leads to aligning projects a little bit better, so eventually I end up moving sources and resources around to better fit the maven model (convention does make pom files smaller).

Occasionally you may end up with defining a few more modules along the way, but that would be no problem.

You can controll all modules from the build directory, such as

mvn clean install
mvn versions:set -DnewVersion=2.1.16.GA -DgenerateBackupPoms=false
mvn sonar:sonar

or whatever you fancy.


You can modify the source directories used by maven, configuring it by exception.

The Maven site has a brief tutorial on it here.

I have not migrated from Ant to Maven before, but I have given a suggestion from many other devs that this is the normal case when doing it.


All you need to do is to put all the references in your respective pom.xml. -IO's and matching's pom will have dependency of Core. like

<dependency>
<groupId>com.core</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>

Same thing goes for other modules. You can define modules inside your pom.xml. It should work for you if I understood your problem correctly.


Need Your Help

Appcelerator Titanium Mobile showTimePickerDialog not showing

android appcelerator

I posted this on the Appcelerator Q&amp;A but I've got a feeling that place is kinda dead. So...