views:

86

answers:

1

We have a largish standalone (i.e. not Java EE) commercial Java project (10,000+ classes, four or five SVN repositories, ten or twenty third-party libraries) that's in the process of switching over to Maven. Unfortunately only one engineer (in a team of a dozen or so distributed across three countries) has any prior Maven experience, so we're kind of figuring it out as we go.

In the old Ant way of doing things, we'd:

  1. check out source code from three or four repositories
  2. compile it all into a single monolithic JAR
  3. release that (as part of a ZIP file with library JARs, an installer, various config files, etc.)
  4. check the JAR into SVN so we had a record of what the customers had actually got.

Now, we've got a Maven repository full of artifacts, and a build process that depends on Maven having access to that repository. So if we need to replicate what we actually shipped to a customer, we need to do a build against a Maven repository that has all the proper versions of everything. This is doable, I guess, if in (some version of) the (SVN-controlled) POM files we set all the dependencies to released versions?

But it gives our release engineer the creepy-crawlies, because there doesn't seem to be any way:

  1. to make sure that somebody doesn't clobber the copy of foo-api-1.2.3.jar on the WebDAV server by mistake (the WebDAV server has access control, but that wouldn't stop a buggy build script)
  2. to detect it if they did
  3. to recover afterwards

His idea is, for release builds, to use a local file system as the repository rather than the WebDAV server, and put that local repository under SVN control.

Our one Maven-experienced engineer doesn't like that -- I guess because he doesn't like putting binaries under version control? -- and suggests that maybe the professional version of the Nexus server can solve the clobbering or clobber-tracking/recovery problem.

Personally, I'm not happy (sorry, Sonatype readers) with shelling out money for a non-free build system when we haven't even seen any benefit from the free version yet, and there's no guarantee it will actually solve the problem.

So our choices seem to be:

  1. WebDAV server
    • Pros: only one server, also accessible by devs, ...?
    • Cons: easy clobbering, no clobber-tracking/recovery
  2. Local file system
    • Pros: can be placed under revision control
    • Cons: only works with the distribution script

Frankly, both of these seem like hacks to me, and I have to wonder if there isn't a better way to do this.

So: Is there a right thing to do here?

A: 

I'm not sure to get everything but I would:

  • Use the maven-release-plugin (which automates the release process i.e. execute all the steps documented in release:prepare).
  • Use WebDAV with anonymous read-only and authenticated write policy (so only release engineer can actually deploy released artifacts to the corporate repo).

There is a no need to put generated artifacts under version control (if you have the poms under version control). I don't see the benefits of using the local file system instead of WebDAV (this is not providing more security, you can secure WebDAV as well). I don't see what the commercial version of Nexus would solve here.

Pascal Thivent
That doesn't solve the build engineer's concern that he himself is accidentally going to deploy the wrong artifact to the repository, and then have no way to easy way to recognize that that happened or to roll back.
David Moles
Please, explain what a "wrong artifact" is, I don't get the situation you are describing (maven is performing the release, not the build engineer). If there is a mistake, release a patched version (with another version number) and deploy again. This is how things work with Maven. Re releasing a previous released artifact is NOT something to do (it won't get downloaded anyway).
Pascal Thivent
Say something's tagged wrong, or there's a problem in a build script, or whatever. Stuff happens. You're saying there's no rollback, only forward? That seems -- not to confuse the issue too much -- like a big step backward, process-wise.
David Moles
_"Re releasing a previous released artifact is NOT something to do (it won't get downloaded anyway)."_ This I'm afraid I don't understand at all. Can you clarify?
David Moles
Let's say you deploy `foo-1.2.3.jar` in your enterprise repository and people update their POMs and download it in their local repositories. Then, if you "redeploy" `foo-1.2.3.jar`, people won't get the new version (unlike SNAPSHOTS) unless they delete the old one locally. But you don't have any control on that and this will lead to horrible/unpredictable mess like *which "real" version do they have*?. If something is wrong, the maven way is to branch, fix, release and deploy a `foo-1.2.3-patched.jar`. There is no other way to guarantee users are really using what is in the repository.
Pascal Thivent
No, the correct way is to release `foo-1.2.4.jar`. Everybody makes mistakes, learn to live with them.
Dominic Mitchell
Well, "patched" was obviously an example here. What I meant was that you have to release a new version. Having that said, **nothing** forces you to increment the version number and to use `foo-1.2.4.jar`. You are free to use `foo-1.2.3.1.jar` or whatever you want if this makes sense to you.
Pascal Thivent
Nobody's using the repository except a dozen internal developers, who can always be told to blow away ~/.m2/repository. Customers don't even know it exists. Besides which, developers should be seeing SNAPSHOTs, not actual versions, right?
David Moles
Do as you want but this is not the maven way, this is not how the release plugin works (and if you adopt maven, you should adopt its philosophy, not fight against). Regarding SNAPSHOTS, developers may have to reproduce a bug with a released version, they may not always deal with SNAPSHOTS IMO.
Pascal Thivent