On 12/04/2011, at 1:31 PM, Eric Berry wrote: > Adam, thank you very much. > > That's certainly cleaner than my solution. > > It's very similar to the example in the cookbook. Would anyone be against my > adding this to the example there?
That would be good. You should probably just change the example that's already there, as it doesn't work well in a multi-project build (as you've discovered). > > Thanks again. > Eric > > On Mon, Apr 11, 2011 at 7:37 PM, Adam Murdoch <[email protected]> > wrote: > > On 12/04/2011, at 11:33 AM, Eric Berry wrote: > >> Hello, >> I'm about 2 minutes away from giving up on using Gradle for my java >> application. >> >> I have a multi-module Java project that looks like: >> MyProject/ >> app/ >> common/ >> >> The App project depends on the common project for compile and for runtime. >> The Common project requires commons-lang. >> >> Using commons lang classes in my App project is fine during compilation >> time, and all my unit tests pass. However I cannot for the life of me get >> the dependencies of the common project into the app project for deployment. >> >> I cannot see any easy way to collect all the dependencies of App into a >> single jar file to ship. >> I was pointed to this in the IRC chat room: >> http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar >> >> But even changing it to configurations.runtime does absolutely nothing. > > Assuming that your app project is using the java plugin, you can do something > like this: > > jar { > dependOn configurations.runtime > from { configurations.runtime.collect { it.isDirectory() ? it : > zipTree(it) } } > } > > At some point, we will add a nicer way of merging stuff into the jar. And > perhaps we will add a variation of the application plugin which takes care of > configuring things to create an executable self-contained jar. > > >> >> The best that I can come up with is something like: >> [code] >> assemble << { >> copy { >> into "${buildDir}/classes/main" >> from configurations.compile.allDependencies.collect { dep -> >> dep.dependencyProject.configurations.compile.collect { >> it.isDirectory() ? it : zipTree(it) >> } >> } >> } >> } >> [/code] >> >> But this seems horrible to me. >> >> Please tell me that there is an easy way to do this. Any help here would be >> greatly appreciated. >> >> Thanks. >> Eric >> >> -- >> Learn from the past. Live in the present. Plan for the future. >> Blog: http://eric-berry.blogspot.com >> jEdit <http://www.jedit.org> - Programmer's Text Editor >> Bazaar <http://bazaar.canonical.com> - Version Control for Humans > > > -- > Adam Murdoch > Gradle Co-founder > http://www.gradle.org > VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting > http://www.gradleware.com > > > > > -- > Learn from the past. Live in the present. Plan for the future. > Blog: http://eric-berry.blogspot.com > jEdit <http://www.jedit.org> - Programmer's Text Editor > Bazaar <http://bazaar.canonical.com> - Version Control for Humans -- Adam Murdoch Gradle Co-founder http://www.gradle.org VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting http://www.gradleware.com
