I want to stop the gradle build from my program when certain resources are not found.
For example, My program searches for abc.properties. Currently when it is not found, all the possible error messages are displayed where the values of the property file are required. Instead I just want to display one line error message like "The file abc.properties is missing" , and then stop the build without displaying other lengthy messages. I have tried System.exit(), but is does not help.
try {
properties.load(PropertyFactory.class.classLoader.getResourceAsStream("abc.properties") );
} catch(Exception e) {
System.out.println("Please put a valid properties file in the src/main/resources folder named abc.properties");
System.exit(1);//something that will stop the build and prevent other error messages
}