Skip to content

Commit

Permalink
Merge pull request #126 from groovy/120
Browse files Browse the repository at this point in the history
rename parameters to be unique between mojos where appropriate (#120)
  • Loading branch information
keeganwitt authored May 5, 2019
2 parents db438cf + cde4804 commit 6e63ae9
Show file tree
Hide file tree
Showing 44 changed files with 404 additions and 390 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.gmavenplus.model.Version;
import org.codehaus.gmavenplus.util.ClassWrangler;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -177,23 +176,32 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
/**
* Whether to support invokeDynamic (requires Java 7 or greater and Groovy indy 2.0.0-beta-3 or greater).
*/
@Parameter(property = "invokeDynamic", defaultValue = "false")
@Parameter(defaultValue = "false")
protected boolean invokeDynamic;

/**
* A <a href="http://groovy-lang.org/dsls.html#compilation-customizers">script</a> for tweaking the configuration options
* (requires Groovy 2.1.0-beta-1 or greater). Note that its encoding must match your source encoding.
*/
@Parameter(property = "configScript")
@Parameter
protected File configScript;

/**
* Generate metadata for reflection on method parameter names using the functionality provided by JEP 118
* (requires Java 8 or greater and Groovy 2.5.0-alpha-1 or greater).
*/
@Parameter(property = "parameters", defaultValue = "false")
@Parameter(defaultValue = "false")
protected boolean parameters;

/**
* Whether to use a shared classloader that includes both the project classpath and plugin classpath.
* Use only if you know what you're doing.
*
* @since 1.6.3
*/
@Parameter(defaultValue = "false")
protected boolean useSharedClassLoader;

/**
* Performs compilation of compile mojos.
*
Expand All @@ -214,11 +222,7 @@ protected synchronized void doCompile(final Set<File> sources, final List classp
return;
}

if (useSharedClassLoader) {
classWrangler = new ClassWrangler(Thread.currentThread().getContextClassLoader(), getLog());
} else {
classWrangler = new ClassWrangler(classpath, getLog());
}
setupClassWrangler(classpath, useSharedClassLoader);

logPluginClasspath();
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.gmavenplus.groovyworkarounds.DotGroovyFile;
import org.codehaus.gmavenplus.model.Version;
import org.codehaus.gmavenplus.util.ClassWrangler;
import org.codehaus.gmavenplus.util.FileUtils;

import java.io.File;
Expand All @@ -40,9 +39,8 @@
public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSourcesMojo {
/*
* TODO: support Groovy 1.5.0 - 1.8.1?
* For some reason, the JavaStubCompilationUnit is silently not creating my
* stubs (although it does create the target directory) when I use other
* versions.
* For some reason, the JavaStubCompilationUnit is silently not creating my stubs
* (although it does create the target directory) when I use other versions.
*/

/**
Expand Down Expand Up @@ -181,6 +179,15 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
@Parameter(defaultValue = "0")
protected int tolerance;

/**
* Whether to use a shared classloader that includes both the project classpath and plugin classpath.
* Use only if you know what you're doing.
*
* @since 1.6.3
*/
@Parameter(defaultValue = "false")
protected boolean useSharedClassLoader;

/**
* Performs the stub generation on the specified source files.
*
Expand All @@ -199,11 +206,7 @@ protected synchronized void doStubGeneration(final Set<File> stubSources, final
return;
}

if (useSharedClassLoader) {
classWrangler = new ClassWrangler(Thread.currentThread().getContextClassLoader(), getLog());
} else {
classWrangler = new ClassWrangler(classpath, getLog());
}
setupClassWrangler(classpath, useSharedClassLoader);

logPluginClasspath();
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
Expand Down Expand Up @@ -287,8 +290,7 @@ protected void addGroovySources(final Set<File> stubSources, final Class<?> comp
if (supportsSettingExtensions()) {
invokeMethod(addSource, javaStubCompilationUnit, stubSource);
} else {
DotGroovyFile dotGroovyFile = new DotGroovyFile(stubSource)
.setScriptExtensions(scriptExtensions);
DotGroovyFile dotGroovyFile = new DotGroovyFile(stubSource).setScriptExtensions(scriptExtensions);
invokeMethod(addSource, javaStubCompilationUnit, dotGroovyFile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.codehaus.gmavenplus.groovyworkarounds.GroovyDocTemplateInfo;
import org.codehaus.gmavenplus.model.Scopes;
import org.codehaus.gmavenplus.model.Version;
import org.codehaus.gmavenplus.util.ClassWrangler;
import org.codehaus.gmavenplus.util.FileUtils;

import java.io.*;
Expand Down Expand Up @@ -64,18 +63,6 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo {
*/
protected static final Version GROOVY_1_5_2 = new Version(1, 5, 2);

/**
* The location for the generated API docs.
*/
@Parameter(defaultValue = "${project.build.directory}/gapidocs")
protected File groovyDocOutputDirectory;

/**
* The location for the generated test API docs.
*/
@Parameter(defaultValue = "${project.build.directory}/testgapidocs")
protected File testGroovyDocOutputDirectory;

/**
* The window title.
*/
Expand Down Expand Up @@ -144,14 +131,6 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo {
@Parameter
protected List<Link> links;

/**
* Whether to include Java sources in GroovyDoc generation.
*
* @since 1.0-beta-2
*/
@Parameter(defaultValue = "true")
protected boolean groovyDocJavaSources;

/**
* Flag to allow GroovyDoc generation to be skipped.
*
Expand All @@ -160,6 +139,15 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo {
@Parameter(property = "maven.groovydoc.skip", defaultValue = "false")
protected boolean skipGroovyDoc;

/**
* Whether to use a shared classloader that includes both the project classpath and plugin classpath.
* Use only if you know what you're doing.
*
* @since 1.6.3
*/
@Parameter(defaultValue = "false")
protected boolean useSharedClassLoader;

/**
* Generates the GroovyDoc for the specified sources.
*
Expand All @@ -183,11 +171,7 @@ protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirector
return;
}

if (useSharedClassLoader) {
classWrangler = new ClassWrangler(Thread.currentThread().getContextClassLoader(), getLog());
} else {
classWrangler = new ClassWrangler(classpath, getLog());
}
setupClassWrangler(classpath, useSharedClassLoader);

classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
logPluginClasspath();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.codehaus.gmavenplus.util.ClassWrangler;

import java.io.File;
import java.net.MalformedURLException;
import java.util.List;


Expand Down Expand Up @@ -207,4 +208,18 @@ protected boolean isGroovyIndy() {
return classWrangler.isGroovyIndy();
}

/**
* Instantiate a ClassWrangler.
*
* @param classpath the classpath to load onto a new classloader (if useSharedClassLoader if <code>false</code>)
* @param useSharedClassLoader whether to use a shared classloader that includes both the project classpath and plugin classpath.
* @throws MalformedURLException when a classpath element provides a malformed URL
*/
protected void setupClassWrangler(List<?> classpath, boolean useSharedClassLoader) throws MalformedURLException {
if (useSharedClassLoader) {
classWrangler = new ClassWrangler(Thread.currentThread().getContextClassLoader(), getLog());
} else {
classWrangler = new ClassWrangler(classpath, getLog());
}
}
}
Loading

0 comments on commit 6e63ae9

Please sign in to comment.