0

I create Gradle task which requires additional property (./gradlew myTask -PmyProperty=something), so I want to check if this property exists and stop build task if not.

if (!project.hasProperty("myProperty")) {
    throw new StopActionException("Please blebleble...")
}

And it works properly if I use gradlew, but Intellij suggests to import changes (Intellij Gradle plugin) and then I get an error exactly in this line where I throw exception. It seems like plugin tries run this tasks before I launch them or something. Is there any possibility to fix it?

I did it exactly like here: Recommended way to stop a Gradle build

Lukas Körfer
  • 13,515
  • 7
  • 46
  • 62
Passarinho
  • 109
  • 1
  • 2
  • 15
  • Why you need to stop build? If you need some external values for building - add them in `gradle.properties` as empty. android studio is trying to build app when you press `sync`. – DeKaNszn Aug 21 '17 at 06:34
  • Ok, it works, but it's not exactly what I need. When I set default property value in gradle.properties, when user calls my task from the command line without -PmyProperty=something this default value will be taken. But an exception should be thrown. I need to stop build, because my task should have configName passed as a parameter (if no parameter passed it should stop). – Passarinho Aug 22 '17 at 14:06

0 Answers0