Wednesday, November 21, 2012

Learning to Deploy (Maven)

I am in the process of learning how to do public deploys with maven; for instance, to publish java library artifacts. Uploading to AWS S3 would be nice, but one step at a time.

I found no 'deploy' menu item in Eclipse's Maven menus. So I made a nice little script:
cd $(dirname $0)
ls -l

echo -----------------------------------
echo deploying...
echo -----------------------------------

mvn javadoc:jar deploy

echo -----------------------------------
echo deploy script done.
echo -----------------------------------

echo -----------------------------------
echo damage report...
echo -----------------------------------

find /tmp/maven-tmp-repo

echo -----------------------------------
echo now back to your regular shell, see you later. 
echo -----------------------------------

I have found it to be a nice pedagogical tool. It's of course not much different from doing it manually but it saves work. I've put it in a 'mvn-deploy.command' file next to the 'pom.xml', which also makes for quick deploys -- it's just a double-click to start from inside Eclipse (provided you set the 'executable' property/flag under Properties); no having to navigate to the right directory in the terminal.

(Btw, why doesn't Eclipse have a 'Open Folder In Shell/Terminal'. Or maybe it does, somewhere. Do tell!)

The 'ls -l' at the start is just for context. The 'find' at the end lists all files in the makeshift repository. Yeah, almost forgot: you need something like this in your pom.xml:
            <name>Temp Folder</name>
Pardon the formatting. (EDIT: Shit, now it looks even worse: '& gt;' and all. Damn you, blogger editor. -- No wait, it looks ok in 'print'.)

So, you can now see in your terminal, or by inspecting the /tmp/ file system tree, how maven adds files like '/1.0-SNAPSHOT/maven-metadata.xml', 'pub-lib-1.0-20121121.203440-1.jar', 'pub-lib-1.0-20121121.205813-2-javadoc.jar', etcetera, without digging in to .m2 (these files are probably simply copies out of the .m2 local repo).

That's it, readers. I just might return with a post about the maven shapshot process, in very concrete terms.

No comments:

Post a Comment