Magnus, Thanks for your reply. I am using Camel 2.11.0, gradle 1.5 and groovy 2.1.1. I found a gradle plugin called gradle-one-jar by rholder (https://github.com/rholder/gradle-one-jar) that did the trick. Here are the relevant bits from my build.gradle:
apply plugin: 'groovy' apply plugin: 'application' buildscript { repositories { mavenLocal() } dependencies { classpath 'com.github.rholder:gradle-one-jar:1.0.3' } } apply plugin: 'gradle-one-jar' mainClassName = 'com.bna.psg.camel.psdm.PsdmServices' ... task install(dependsOn: 'oneJar') << { copy { from oneJar.archivePath into "${System.env.ENVIRON}/lib/java" } } task oneJar(type: OneJar) { mainClass = mainClassName additionalDir = file('src/main/resources') // adds my log4j.properties to the combined jar file manifest { attributes 'Built-By': System.getProperty('user.name') attributes 'Built-Date': new Date() attributes 'Built-JDK': System.getProperty('java.version') } } Note the order--it took me a while to figure out that the buildscript { } block needed to come before the "apply plugin: 'gradle-one-jar'" or the script wouldn't be able to find the plugin! -dan -----Original Message----- From: Magnus Palmér [mailto:magnus.palmer.w...@gmail.com] Sent: Thursday, May 02, 2013 1:12 AM To: users Subject: Re: How to deploy an executable jar for a standalone camel application? I do use Groovy and Gradle with Camel. I haven't used the uber-jar with Gradle though, I am using the fatjar plugin instead - https://github.com/musketyr/gradle-fatjar-plugin You didn't provide any information about which versions you are using, for instance in Camel the ".process { closure }" works since 2.11 and not before. (If you try it in earlier versions you get a groovy missing method exception.) It would help seeing a log printout, you say that you get all the logging messages you expect except that you get the ExecResult.toString() instead of the expected XML string, but it would be much easier to try help you if I (we) can see what happens. 2013/5/1 Speck, Dan <dsp...@bna.com> > I'm having trouble deploying my Camel application. It works fine when > I build the java classpath manually (including all of the dependent > jars) but when I follow the instructions for creating an executable > jar in gradle, the app only works partially. Some of the routes work > but others don't. I also get errors when using groovy closures as > arguments to .process() (I need to use the { ... } as Processor syntax to get > the route to run). > > Here is one of the routes that doesn't work when running the > executable jar (it takes a multipart form with an input file parameter > containing an SGML file and translates it to XML via an exec() component): > > from("jetty:http://0.0.0.0:$port/convert/psdm/toXml") > .process(new MultipartFormSingleFileExtractor()) > .choice() > .when(header('origFileName')) > .to('file:///tmp') > .setHeader(ExecBinding.EXEC_COMMAND_ARGS, simple('--indent -o > /dev/stdout /tmp/${id}')) > .setHeader('TempFilename', simple('/tmp/${id}')) > .to('exec:ps2000_sgml2xml') > .process( > { Exchange ex -> > def tempFile = new File(ex.in.headers.TempFileName).delete() > if ( ex.in.headers[ExecBinding.EXEC_EXIT_VALUE] == 0 ) { > log.info "yay! file ${ex.in.headers.origFilename} was valid!" > ex.out.body = ex.in.getBody(String.class) > ex.out.headers[Exchange.HTTP_RESPONSE_CODE] = 200 > ex.out.headers['Content-Type'] = 'application/xml' > } > else { > String msgText = > ex.in.headers[ExecBinding.EXEC_STDERR].getText() > .replaceAll(ex.in.headers.TempFilename, > ex.in.headers.origFilename) > ex.out = new ErrorMessage(errorCode: > ex.in.headers[ExecBinding.EXEC_EXIT_VALUE], > httpResponseCode: 400, > message: msgText).toMessage() > } > } as Processor > ) > .end() > > When I run this using the manually constructed java command I get the > expected output, i.e., an XML document, but when I run the executable > jar I get the string: > org.apache.camel.component.exec.ExecResult@eabd2f<mailto: > org.apache.camel.component.exec.ExecResult@eabd2f> > Aside from the incorrect output, the route seems to be working-I get > the logging messages I expect. > > Here is the "uberjar" task that I am using in my build.gradle: > task uberjar(type: Jar) { > > from files(sourceSets.main.output.classesDir) > from 'src/main/resources' > > from { configurations.compile.asFileTree.files.collect { zipTree(it) > } } { > exclude "META-INF/*.SF" > exclude "META-INF/*.DSA" > exclude "META-INF/*.RSA" > } > > from { configurations.runtime.asFileTree.files.collect { zipTree(it) > } } { > exclude "META-INF/*.SF" > exclude "META-INF/*.DSA" > exclude "META-INF/*.RSA" > } > > manifest { > attributes 'Main-Class': mainClassName, > 'Built-By': System.getProperty('user.name'), > 'Built-Date': new Date(), > 'Built-JDK': System.getProperty('java.version') > } > } > > Has anyone had a similar issue? Does anyone else use groovy/gradle > with Camel? > > -dan > > >>>>>>>>>>>>>>>>>>>>>>>>>> > Daniel Speck > Software Development Manager > Publishing Systems, PR&D > > Bloomberg BNA > > Direct 703.341.3118 > Mobile 202.329.7449 > dsp...@bna.com<mailto:dsp...@bna.com> > >