Skip to content

Commit c474a53

Browse files
authored
Merge pull request #96 from groovy/fix-log-order
Fixed NPE when calling mojo without Groovy dependency
2 parents ecc7346 + 87adb71 commit c474a53

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ protected synchronized void doCompile(final Set<File> sources, final List classp
165165
throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, MalformedURLException {
166166
classWrangler = new ClassWrangler(classpath, getLog());
167167

168-
logPluginClasspath();
169-
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
170-
171168
if (sources == null || sources.isEmpty()) {
172169
getLog().info("No sources specified for compilation. Skipping.");
173170
return;
174171
}
175172

173+
logPluginClasspath();
174+
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
175+
176176
if (groovyVersionSupportsAction()) {
177177
verifyGroovyVersionSupportsTargetBytecode();
178178
} else {

src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
140140
protected synchronized void doStubGeneration(final Set<File> stubSources, final List classpath, final File outputDirectory) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, MalformedURLException {
141141
classWrangler = new ClassWrangler(classpath, getLog());
142142

143-
logPluginClasspath();
144-
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
145-
146143
if (stubSources == null || stubSources.isEmpty()) {
147144
getLog().info("No sources specified for stub generation. Skipping.");
148145
return;
149146
}
150147

148+
logPluginClasspath();
149+
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
150+
151151
if (!groovyVersionSupportsAction()) {
152152
getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support stub generation. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping stub generation.");
153153
return;

src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,16 @@ protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirector
191191
getLog().info("Skipping generation of GroovyDoc because ${maven.groovydoc.skip} was set to true.");
192192
return;
193193
}
194+
194195
if (sourceDirectories == null || sourceDirectories.length == 0) {
195196
getLog().info("No source directories specified for GroovyDoc generation. Skipping.");
196197
return;
197198
}
199+
200+
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
201+
logPluginClasspath();
202+
198203
if (groovyVersionSupportsAction()) {
199-
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
200-
logPluginClasspath();
201204
try {
202205
getLog().debug("Project compile classpath:\n" + project.getCompileClasspathElements());
203206
} catch (DependencyResolutionRequiredException e) {

src/main/java/org/codehaus/gmavenplus/mojo/ConsoleMojo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
6161

6262
logPluginClasspath();
6363
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
64+
6465
try {
6566
getLog().debug("Project test classpath:\n" + project.getTestClasspathElements());
6667
} catch (DependencyResolutionRequiredException e) {

src/main/java/org/codehaus/gmavenplus/mojo/ExecuteMojo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,21 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9595
protected synchronized void doExecute() throws MojoExecutionException, MojoFailureException {
9696
classWrangler = new ClassWrangler(Thread.currentThread().getContextClassLoader(), getLog());
9797

98+
if (scripts == null || scripts.length == 0) {
99+
getLog().info("No scripts specified for execution. Skipping.");
100+
return;
101+
}
102+
98103
logPluginClasspath();
99104
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
105+
100106
try {
101107
getLog().debug("Project test classpath:\n" + project.getTestClasspathElements());
102108
} catch (DependencyResolutionRequiredException e) {
103109
getLog().warn("Unable to log project test classpath", e);
104110
}
105111

106112
if (groovyVersionSupportsAction()) {
107-
if (scripts == null || scripts.length == 0) {
108-
getLog().info("No scripts specified for execution. Skipping.");
109-
return;
110-
}
111-
112113
final SecurityManager sm = System.getSecurityManager();
113114
try {
114115
if (!allowSystemExits) {

src/main/java/org/codehaus/gmavenplus/mojo/ShellMojo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7373

7474
logPluginClasspath();
7575
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
76+
7677
try {
7778
getLog().debug("Project test classpath:\n" + project.getTestClasspathElements());
7879
} catch (DependencyResolutionRequiredException e) {

0 commit comments

Comments
 (0)