Skip to content

Commit

Permalink
Throw exception instead of returning null when Groovy can't be found (c…
Browse files Browse the repository at this point in the history
…loses #210)
  • Loading branch information
keeganwitt committed Feb 15, 2022
1 parent 87fd2ca commit 20e42db
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/org/codehaus/gmavenplus/util/ClassWrangler.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public String getGroovyVersionString() {
if (groovyVersion == null) {
log.warn("Unable to get Groovy version from InvokerHelper or GroovySystem, trying jar name.");
String jar = getGroovyJar();
if (jar == null) {
return null;
}
int idx = Integer.MAX_VALUE;
for (int i = 0; i < 9; i++) {
int newIdx = jar.indexOf("-" + i);
Expand All @@ -141,8 +144,7 @@ public Version getGroovyVersion() {
try {
return Version.parseFromString(getGroovyVersionString());
} catch (Exception e) {
log.error("Unable to determine Groovy version. Is Groovy declared as a dependency?");
return null;
throw new RuntimeException("Unable to determine Groovy version. Is Groovy declared as a dependency?");
}
}

Expand Down Expand Up @@ -279,8 +281,7 @@ protected String getGroovyJar() {

return groovyJar;
} catch (ClassNotFoundException e) {
log.error("Unable to determine Groovy version. Is Groovy declared as a dependency?");
return null;
throw new RuntimeException("Unable to determine Groovy version. Is Groovy declared as a dependency?");
}
}

Expand Down

0 comments on commit 20e42db

Please sign in to comment.