1

I wanted to take a legacy project, and generate an initial pom.xml file for it, without converting the whole project. (The thinking is to take advantage of some Maven tasks without creating a big ripple effect in the automated builds that already include this project, which are not Maven projects.)

Is there some way to do this other than archetype:generate (in a phony directory), and then copying the pom.xml to where I really want it?

Sam Goldberg
  • 6,711
  • 8
  • 52
  • 85
  • How are the builds currently automated? – Vidya Dec 24 '13 at 23:19
  • Ant. It's a complicated build script which checks several projects out of CVS, compiles, unit tests, tags, jars, and distributes to server. Since there are a bunch of related projects, I'm not ready to bite the bullet and convert them all. – Sam Goldberg Dec 25 '13 at 02:21

2 Answers2

1

AFAIK, no.

But if you know enough about Maven, you can typically write a POM file for a legacy project.

The complication is that the files / directories of a legacy project will typically not be organized in the Maven recommended way, so the normal generation tools won't work. However, "it is said" that Maven can cope with non-standard organisations ... if you write the POM file appropriately.


Another approach is to build the legacy project in the legacy way, and then manually add the resulting JAR files to your Maven repo with appropriate "coordinates" (i.e. group-id, artifact-id and version) so that your Maven projects can use them.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Actually, all I wanted to do was to use Maven to copy a dependency jar from the repository to one of the folders we check into CVS (used for the automated Ant build). I'm not looking to use Maven to build this project yet. (It is included in other builds, and doesn't have its own JAR.) – Sam Goldberg Dec 25 '13 at 02:24
  • 1
    In that case, I think you asked the wrong Question. See this Q&A for some alternatives: http://stackoverflow.com/questions/10536221/fetching-maven-artifacts-programmatically – Stephen C Dec 25 '13 at 08:35
  • Yes and no. While the immediate task was to download dependencies, I also looked at it as a first step to building a pom to migrate the project. – Sam Goldberg Dec 26 '13 at 14:02
  • Well those are two distinct tasks. AFAIK, it is not possible to use Maven to *just* download dependencies. – Stephen C Dec 26 '13 at 16:51
1

You seem to want to do an unorthodox thing with Maven, and while I like Maven, I find Maven is absolutely terrible at doing unorthodox things.

I would suggest using Gradle instead--especially since you just need to perform one task and don't need to build with it (and therefore learn it).

Because Gradle is a Groovy DSL, you can simply write some Groovy code to access a repository and copy it into a directory on the local file system.

(I will leave aside my personal abhorrence of putting compiled artifacts into source control.)

Gradle also has outstanding integration with Ant.

Vidya
  • 29,932
  • 7
  • 42
  • 70
  • Thanks for the suggestion. I haven't looked at Gradle yet. Writing in code (rather than configuration) maybe a more flexible way to handle things. – Sam Goldberg Dec 26 '13 at 14:00