Check that cli jar command only writes .jars

Update `JarCommand` to check that the file extension of the output is
`.jar`.

Fixes gh-581
This commit is contained in:
Phillip Webb
2014-03-25 14:57:12 -07:00
parent 1dcd4ddf9e
commit 0960ac760e
3 changed files with 20 additions and 1 deletions

View File

@@ -110,6 +110,8 @@ public class JarCommand extends OptionParsingCommand {
"The name of the resulting jar and at least one source file must be specified");
File output = new File((String) nonOptionArguments.remove(0));
Assert.isTrue(output.getName().toLowerCase().endsWith(".jar"), "The output '"
+ output + "' is not a JAR file.");
deleteIfExists(output);
GroovyCompiler compiler = createCompiler(options);