Package org.codehaus.gmavenplus.util
Class ClassWrangler
- java.lang.Object
-
- org.codehaus.gmavenplus.util.ClassWrangler
-
public class ClassWrangler extends Object
Handles getting Groovy classes and version from the specified classpath.- Since:
- 1.2
- Author:
- Keegan Witt
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassLoader
classLoader
ClassLoader to use for class wrangling.protected String
groovyVersion
Cached Groovy version.protected Boolean
isIndy
Cached whether Groovy supports invokedynamic (indy jar).protected org.apache.maven.plugin.logging.Log
log
Plugin log.
-
Constructor Summary
Constructors Constructor Description ClassWrangler(ClassLoader classLoaderForLoading, org.apache.maven.plugin.logging.Log pluginLog)
Creates a new ClassWrangler using the specified ClassLoader.ClassWrangler(List classpath, org.apache.maven.plugin.logging.Log pluginLog)
Creates a new ClassWrangler using a new ClassLoader, loaded with the items from the specified classpath.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassLoader
createNewClassLoader(List classpath)
Creates a new ClassLoader with the specified classpath.Class
getClass(String className)
Gets a class for the given class name.ClassLoader
getClassLoader()
Returns the classloader used for loading classes.String
getGroovyJar()
Returns the filename of the Groovy jar on the classpath.Version
getGroovyVersion()
Gets the version of Groovy used from the classpath.String
getGroovyVersionString()
Gets the version string of Groovy used from classpath.protected String
getJarPath()
Returns the path of the Groovy jar on the classpath.boolean
isGroovyIndy()
Gets whether the version of Groovy on the classpath supports invokedynamic.void
logGroovyVersion(String goal)
Logs the version of groovy used by this mojo.
-
-
-
Field Detail
-
groovyVersion
protected String groovyVersion
Cached Groovy version.
-
isIndy
protected Boolean isIndy
Cached whether Groovy supports invokedynamic (indy jar).
-
classLoader
protected ClassLoader classLoader
ClassLoader to use for class wrangling.
-
log
protected org.apache.maven.plugin.logging.Log log
Plugin log.
-
-
Constructor Detail
-
ClassWrangler
public ClassWrangler(ClassLoader classLoaderForLoading, org.apache.maven.plugin.logging.Log pluginLog)
Creates a new ClassWrangler using the specified ClassLoader.- Parameters:
classLoaderForLoading
- the ClassLoader to use to load classespluginLog
- the Maven log to use for logging
-
ClassWrangler
public ClassWrangler(List classpath, org.apache.maven.plugin.logging.Log pluginLog) throws MalformedURLException
Creates a new ClassWrangler using a new ClassLoader, loaded with the items from the specified classpath.- Parameters:
classpath
- the classpath to load the new ClassLoader withpluginLog
- the Maven log to use for logging- Throws:
MalformedURLException
-
-
Method Detail
-
getGroovyVersionString
public String getGroovyVersionString()
Gets the version string of Groovy used from classpath.- Returns:
- The version string of Groovy used by the project
-
getGroovyVersion
public Version getGroovyVersion()
Gets the version of Groovy used from the classpath.- Returns:
- The version of Groovy used by the project
-
isGroovyIndy
public boolean isGroovyIndy()
Gets whether the version of Groovy on the classpath supports invokedynamic.- Returns:
true
if the version of Groovy uses invokedynamic,false
if not or Groovy dependency cannot be found.
-
getGroovyJar
public String getGroovyJar()
Returns the filename of the Groovy jar on the classpath.- Returns:
- the Groovy jar filename
-
getJarPath
protected String getJarPath() throws ClassNotFoundException
Returns the path of the Groovy jar on the classpath.- Returns:
- the path of the Groovy jar
- Throws:
ClassNotFoundException
- when Groovu couldn't be found on the classpath
-
logGroovyVersion
public void logGroovyVersion(String goal)
Logs the version of groovy used by this mojo.- Parameters:
goal
- The goal to mention in the log statement showing Groovy version
-
createNewClassLoader
public ClassLoader createNewClassLoader(List classpath) throws MalformedURLException
Creates a new ClassLoader with the specified classpath.- Parameters:
classpath
- the classpath (a list of file path Strings) to include in the new loader- Returns:
- the new ClassLoader
- Throws:
MalformedURLException
- when a classpath element provides a malformed URL
-
getClass
public Class getClass(String className) throws ClassNotFoundException
Gets a class for the given class name.- Parameters:
className
- the class name to retrieve the class for- Returns:
- the class for the given class name
- Throws:
ClassNotFoundException
- when a class for the specified class name cannot be found
-
getClassLoader
public ClassLoader getClassLoader()
Returns the classloader used for loading classes.- Returns:
- the classloader used for loading classes
-
-