tags:

views:

25

answers:

2

Dear All:

I am trying to make a task to run my Jar file in gradle.

I have come up with the following:

task runJar(dependsOn:[jar]){
  ant.java(jar:,fork:true)
}

However, I am unable to find the path to the jar file. Any help much appreciated. Thank you!

Misha

EDIT: OK this is rather odd. This task runs before compile, etc.???

EDIT: Fixed. The key is in a doLast { } notation, or, in shorthand

task runJar(dependsOn:"jar")<<{
  ant.java(jar:"${libsDir}${File.separator}${archivesBaseName}.jar",fork:true)
}

Misha

+1  A: 

My best solution so far:

task runJar(dependsOn:[jar]){
  ant.java(jar:"${libsDir}${File.separator}${archivesBaseName}.jar",fork:true)
}

Thank you!

Misha

Misha Koshelev
+1  A: 

You should be able to use the jar.archivePath variable ;

task runJar(dependsOn:[jar]){
  ant.java(jar: jar.archivePath ,fork:true)
}
TheKaptain