Deployment with Maven

Hello, I’m currently using Maven to deploy a jar on a website. My problem is that the jar name change everytime I upload it. I want to create an html page that link to the jar but it won’t work if the name always change. The part that change is the version number (1, 2, 3, 4, 5, etc.) and the date. Here are 2 example of name that Maven created automatically with the command mvn deploy

MiniRunner-0.0.1-20120621.181701-1.jar
MiniRunner-0.0.1-20120705.020026-2.jar

Maven 3 now use unique Snapshots as a default, it is normaly a good practice to use unique snapshots.
If you really need ununque snapshots u can use the maven option -DuniqueVersion=false
It may be possible to specifie it in your project pom too.
perhaps:
false

Oh that might just be what I need. I will try it. :slight_smile:

I use Maven to automatically deploy the update to my game. So I don’t really need to keep an history of every snapshot. Sometimes I make small update like working 20 minutes. I don’t want to have 100 different jars on the website…

Edit : Sproingie seems to be right, I just add the false in my distribution management block and it doesn’t do anything…

doesn’t work with maven 3, snapshots always have the same pattern now, and m2eclipse depends on it. You pretty much have to run a job to delete old snapshots before updating the index. As with all things maven, there’s a plugin for that.

:o :o :o But why did they do that!!!

Ok I can get a job to delete old one, but how do I link to the correct one?

They did it because snapshot handling in maven 2 was an insane confusing mess that broke all the time. You shouldn’t need to link to the newest snapshot in a filesystem repo – maven should find it automatically. If you’re deploying to a remote repo, use Nexus to update the index.

Well the only thing that is linking to the newest snapshot is an html page with an tag. So no, it doesn’t find the newest snapshot automatically :cranky:

And it’s not really my server or my remote repo. It’s just a free host server with byethost that I use to upload my file so I have no idea if I can install Nexus on that to update the index…

Right now it feels for me like maven snapshot filehandling is a complete mess. I thought it would be good learning to use Maven just to upload a jar via ftp but it seems that it’s impossible to make it simple. Will try simple batch file I guess.

Sorry but I really don’t get why they do all that strange stuff.

If you’re cutting a new version every 20 minutes and need to update a html page that isn’t a nexus index or part of the maven site, you’re going to have to do that by hand no matter what build tool you use. With maven, there is of course a plugin to do that sort of thing, but for your byethost page, you might want to just hack something in PHP to look for the latest snapshot and generate the link that way. (or if a dynamic page is out of the question, what I say below and just use a script to update your public snap rather than dink around doing it with maven)

Seems like a complex solution for a simple problem.

What are you trying to do:
[x] compile source
[x] create jars
[x] upload with ftp

This is scriptable (.sh/.bat) in a few minutes.

You could write a script per platform or just use maven which does it just fine too. Honestly tho, the part about uploading a new snap to byethost and generating a link to it, I would also do with a script. God knows that’s easier than screwing with random maven plugins. There’s no rule that says that one repo has to have all the snapshots that are on another, so let your local repo grow as many snapshots as you have builds, then upload the public snap with a script whenever you feel like it.

I’m quite sure they’ll get it right with the third try.

Maven sucks, don’t bother.

@Nate: I expected you to plug your own project here, and I didn’t want to get in your way.

Seeing that you dropped the ball on that, let me plug it for you.

I have to help Nate and Riven on this one, Scar is awesome. I haven’t used it much but I tried it once and holy crap it’s so straightforward, it’s crazy.

So how does Scar deal with snapshot dependencies?

Its good that you nuanced your retort but now you’ve reduced it so much that you’re missing your original point IMO. This thread is not about Scar, its about getting help with using Maven. Whether you like Maven or not is woefully beside the point - apparently Gudradain does and that’s all that matters here.

Now if you’ll excuse me, I’ve got some .NET forums to visit and spam “.NET sucks, Java rules!”. Its a hard job but somebody has to do it.

Actually, that was exactly my point too, I just figured I’d point out the inapplicability of the tool rather than righteous flaming over attitudes. God knows maven can be clunky at times, but it beats dealing with someone’s ad-hoc reinvention of it whenever I pick up a new project.

Ahem. So, somebody it trying to solve a trivial problem, and I strongly get the impression he just picked Maven as a tool. He finds himself in misery, as said tool is fighting him at every step of the way.

Now how can we possibly restrict ourselves to purely answering the question? Aren’t we also here to push eachother in the right direction?

Most of the thread here follow a simple pattern:
[x] newbie walks in, asks technical question
[x] it becomes clear that in his situation, he shouldn’t be doing what he’s asking for
[x] people jump in, explaining what he should do instead
[x] newbie actually gets the job done, within a reasonable time frame

Note: I’m not saying Gudradain is a newbie, nor am I saying that my suggestion to use Scar was a great move. I’m just trying to get across that this statement:

[quote=“gimbal,post:15,topic:39233”]
seems a tad odd, but maybe it’s just me…

It might just be entirely possible that Gudradain is using maven for other reasons and not just to upload snapshot builds, and thus isn’t keen on replacing it with a different tool that doesn’t even begin to cover the basic functionality most people use maven for in the first place.

That’s at least the assumption I tend to make from the start.

Surely that might very well be the case, but when I read his quote, I can’t help but feel that these are hist first steps with Maven:

Oh well, it doesn’t really matter, Gudradain will be here soon enough to tell us it all worked out, with maven, too - I was merely surprised by the harsh ‘answer the question or stfu’ post of gimbal.

Deployment is actually a great reason for using maven since it lets you configure the destination in just one place and then all your projects can use it. I’ll grant however that it does defeat the purpose a bit to use it only to upload to a non-repository destination with nothing else using it as a dependency.