1

I'm trying add "thow StopExecutionException" in my android gradle file:

apply plugin: 'com.android.library'
task exportJar(type: Copy) {

    def classesJar = file("build/intermediatess/bundles/release/classes.jar")
    if (classesJar.exists()) {
       //some code
    } else {
        **throw StopExecutionException**(classesJar.getPath() + " doesn't exist");
    }
}

I use existing solution:

Recommended way to stop a Gradle build

but gradle doesn't recoginze StopExecutionException and any other Exception.

What I have to do? Apply some kind of plugin? Add classpath dependancy?

Community
  • 1
  • 1
antygravity
  • 1,307
  • 10
  • 12

1 Answers1

0

You've forgot to add a new before the exception. You need to throw it like a usual java exception:

throw new StopExecutionException(classesJar.getPath() + " doesn't exist");
Stanislav
  • 27,441
  • 9
  • 87
  • 82