java - Gradle - export property after copy task finishes -


i have build pipeline want run particular jar (with args) after copying separate folder dependency list.

currently i'm doing following:

task copytolib(type: copy, dependson: classes) {     "$builddir/server"     from(configurations.compile) {         include "webapp-runner*"     }     ext.serverpath =  filetree("$builddir/server/").include("webapp-runner-*.jar").getsinglefile() }  task run(type: exec, dependson: [copytolib, war]) {     mustrunafter copytolib     executable 'java'     args '-jar', copytolib.serverpath, war.archivepath, '--port', "$port" } 

but fails expected directory '...' contain 1 file, however, contains no files. since i'm guessing serverpath set during config phase when file has not been copied. how around this?

you falling common mistake of executing logic in configuration phase when should executing in execution phase.

try this

task copytolib(type: copy, dependson: classes) {     ...     dolast {         ext.serverpath = ...     } } 

if me, i'd calculate serverpath inside run rather in copytolib. perhaps use closure delay calculation.

eg:

task run(type: exec, dependson: [copytolib, war]) {     def pathclosure = {         filetree("$builddir/server/").include("webapp-runner-*.jar").singlefile     }     mustrunafter copytolib     executable 'java'     args '-jar', pathclosure, war.archivepath, '--port', "$port" } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -