Gradle exec mvn dependency:copy-dependencies


I’m having troubles with executing command ‘mvn dependency:copy-dependencies’ from Gradle via Exec task:

task copyDeps(type: Exec) << {
    commandLine 'mvn', 'dependency:copy-dependencies'

if I run this via cmdline: gradle copyDeps, nothing happens. I’m not sure what is exactly wrong. I’ve even tried to execute it like this

commandLine 'cmd', '/c', 'mvn', 'dependency:copy-dependencies'

… but it didn’t help at all. Can anyone give me some hint what is wrong with this code, or how can I enable as much logging as possible to reveal what went wrong (–debug is not enough).

Thanks in advance.

You have to remove the ‘<<’ (configuration vs. execution phase).

Thx for lighting-fast answer :).

I figured it out in meantime however. I was running this task from parent project and I was wondering, why it didn’t execute in sub-project (but that’s different issue still to be solved :)).

When I run mentioned command from correct directory, it passed and copied all dependencies as required :).


commandLine 'mvn', 'dependency:copy-dependencies'
   results in "execCommand == null!"
commandLine 'cmd', '/c', 'mvn', 'dependency:copy-dependencies'
   use for Windows

Thx Peter !

btw, can you help me how can I mark question answered? Or reffer me to some manual?

BTW. we adressed this problem and will give a decent warning in upcoming gradle versions.

cheers, René

Unfortunately, only admins can mark a question as answered, and I’ve done it for you.