當某些資源未找到時,我想停止從我的程序構建gradle。如何在特定條件下停止Gradle或Maven構建
例如,我的程序搜索abc.properties。當前未找到時,將顯示所有可能的錯誤消息,其中屬性文件的值是必需的。相反,我只想顯示一行錯誤消息,如「文件abc.properties丟失」,然後停止構建而不顯示其他冗長的消息。我試過System.exit(),但沒有幫助。
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
}
這是一個相當不錯的解決方案。 – Sean 2014-11-19 12:21:22