javamavenpom.xmlheritrix

How do I upgrade maven.xml to pom.xml?


I'm working with the 1.14.4 branch of Heritrix and I'm unfortunately for the time being stuck in that branch.. The problem I'm encountering is, its maven.xml is dependent upon Maven 1.1 which is so old I had trouble even finding the dependencies to get it to build.

Moreso, because it's a maven.xml and not a pom.xml, no reasonably old or recent IDE can load the project up - I have to build it by hand running the 'maven' script.

I'll freely admit I'm fairly ignorant when it comes to Java and maven, but surely someone out there has to have some pointers on how I could upgrade to a more recent version of Maven.

Help me Obi-Wan! You're my only hope!

An embarrasing 5 minutes later update..

After wasting 3 hours on this I stumbled on the answer here

A couple hours later.. reality sets in..

Upgrading to maven-2 or maven-3 has introduced a new new modules which are all out of whack from what got promoted out of my maven.xml into the pom.xml. Additionally, there's no pom.xml for 'the project' which seems to be a bit of a snag too.

So, if I want to play this way, I have to play for keeps - upgrade my modules, format everything as if it were a new project. The upgrade technique got me a little of the way, but this is going to take a while I think.. Accepting Tim's prompt and detailed answer, thanks again. I realize in a way 'Hai guys make maven work for me?' is somewhat like asking someone to fix your makefile.. If it's busted, it's busted. :D


Solution

  • Well, there is an official guide to this sort of thing, but here's a quick start.

    Start with a minimal POM:

    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <version>1</version>
    </project>
    

    The easiest (although not strictly necessary) step is to ensure the project has the Maven 2 default directory structure.

    Essentially just:

    src/main/java              - your java files, e.g. /com/mycompany/...
    src/main/resources         - other dependencies (e.g. xml files)
    

    You should then be able to load up that empty project into an IDE as a valid Maven 2 project.

    However, it will be full of errors because you have not yet specified the dependencies. Now you have two choices:

    1) Add dependencies to the POM by hand. E.g.:

    <project>
    ...
    <dependencies>
        <dependency>
          <groupId>commons-math</groupId>
          <artifactId>commons-math</artifactId>
          <version>1.2</version>
          <type>jar</type>
        </dependency>
    </dependencies>
    ...
    </project>
    

    2) Or use the IDE to pull in the required dependencies. Depending on your IDE, this may be significantly easier as it may offer the ability to automatically search Maven central for the right library and you can pull in the latest version easily. Netbeans for example, will provide a tooltip on the left of a code line where there is a missing class definition that allows you to search Maven for the dependency.