Bohemian
Bohemian

Reputation: 424973

How to create a dependency for a custom gradle task?

I want to execute a shell command that requires a particular jar (eg someJar.jar) from a particular library (eg someGroup:someName:someVersion) that is not used by the rest of the project, but I can't figure out how to specify the dependency for the task.

In my build.gradle, I have tried many variations of:

task salesforce(type: Exec, variousProperties: ???) { 
    executable "sh"
    args "java", "-jar", "someJar.jar"
}

and other properties without success.

The task should download the dependency when run.

What's the cleanest way to specify the dependency?

Upvotes: 0

Views: 128

Answers (1)

Opal
Opal

Reputation: 84756

Try:

configurations {
   cp 
}

dependencies {
   cp 'some:dependency:1.0'
}

task salesforce(type: JavaExec) { 
    classpath configurations.cp
    main 'MainClass'
}

Upvotes: 1

Related Questions