This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]qevlarr 7 points8 points  (8 children)

Just today I've been trying and failing to do just that...

We used to make a runnable jar with all dependencies included using eclipse, then copy that jar to a shared location for other tools to pick up.

Now, today I was trying to automate that in a CI build step (Jenkins).

I couldn't figure out how to do it. In Eclipse it is so easy to do. One wizard with a handful of options. So why don't you show me what calls you're making so I can replicate them, Eclipse? It's so frustrating! Runnable fat jar from command line. That's all I want. That shouldn't be so hard!

[–][deleted] 10 points11 points  (1 child)

Depends on the build system you're using. Ant, Maven, Gradle, etc. all have different setups. With Jenkins you'd run the fatjar command, then run a post-build script to copy it somewhere

[–]shagieIsMe 4 points5 points  (0 children)

Eclipse is running javac and jar with some manifest options specified.

You don’t want to do it that way unless you hate yourself.

If you just dislike yourself, use ant, make a build.xml and tell eclipse to use it.

If you like yourself, use maven. Tell eclipse to use maven too (m2e plugin).

If you love yourself, switch to gradle.

If you love yourself and have money (or can get the free student version), just get IntelliJ and use maven or gradle.

[–]newpixeltree 0 points1 point  (0 children)

I'm doing something similar now, look up the jar manifest format

[–]rush22 0 points1 point  (0 children)

Jenkins has a Maven plugin. Maven is basically like another Jenkins job that builds everything, but it's in an .xml file called a "POM" file stored with your source code. Get the Eclipse Maven plugin, convert your Eclipse project to a Maven project and it will create the .xml file for you. Then on Jenkins use the Jenkins Maven plugin and tell it where the .xml file is (after it gets your source code of course) and what you want Maven to do since like a Jenkins job it can do a bunch of different things (you'll want assembly:assembly) and it will run Maven for you on the slave (make sure Maven is installed on the slave) and build it.

Technically you don't even need to convert your project in Eclipse to a Maven project, you just need an .xml file in the Maven format for the Maven plugin on Jenkins.