Question

I am trying to write a Gradle plugin and I have a situation in which user specified bunch of files and when the file is not with specific extension then the warning has to be thrown, because these files can not be processed. So I am wondering if there is a convention how to construct appropriate warning message, so the message to be clear and not to disappear in the thousands line of project log.

I think something like:

WARNING!!! The file ${file.getName()} is with incompatible extention type ${extention}. The appropriate extension is ${EXTETNIO_TYPE}. The current file will not be taken during the build."

But while looking in the Gradle code. Their warning messages are just the message without WARNING or anything else. Please, give me your advises.

Was it helpful?

Solution

Warning messages are typically logged with log.warn(). However, if the files cannot be processed, it might be more appropriate to throw a GradleException. Warnings should be avoided whenever possible because they create noise, require the user to always check the command line output, and are easily overlooked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top