Package org.codehaus.gmavenplus.util
Class ClassWrangler
java.lang.Object
org.codehaus.gmavenplus.util.ClassWrangler
Handles getting Groovy classes and version from the specified classpath.
- Since:
- 1.2
- Author:
- Keegan Witt
-
Constructor Summary
ConstructorsConstructorDescriptionClassWrangler(List<?> classpath, ClassLoader parentClassLoader, org.apache.maven.plugin.logging.Log pluginLog) Creates a new ClassWrangler using the specified parent ClassLoader, loaded with the items from the specified classpath. -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassLoadercreateNewClassLoader(List<?> classpath, ClassLoader classLoader) Creates a new ClassLoader with the specified classpath.Class<?> Gets a class for the given class name.Returns the classloader used for loading classes.protected StringReturns the filename of the Groovy jar on the classpath.Gets the version of Groovy used from the classpath.Gets the version string of Groovy used from classpath.protected StringReturns the path of the Groovy jar on the classpath.static booleangroovyAtLeast(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is the specified version or newer.static booleanDetermines whether the detected Groovy version is the specified version.static booleangroovyNewerThan(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is newer than the specified version.static booleangroovyOlderThan(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is older than the specified version.booleanGets whether the version of Groovy on the classpath supports invokedynamic.voidlogGroovyVersion(String goal) Logs the version of groovy used by this mojo.
-
Constructor Details
-
ClassWrangler
public ClassWrangler(List<?> classpath, ClassLoader parentClassLoader, org.apache.maven.plugin.logging.Log pluginLog) throws MalformedURLException Creates a new ClassWrangler using the specified parent ClassLoader, loaded with the items from the specified classpath.- Parameters:
classpath- the classpath to load the new ClassLoader withparentClassLoader- the parent for the new ClassLoader used to use to load classespluginLog- the Maven log to use for logging- Throws:
MalformedURLException- when a classpath element provides a malformed URL
-
-
Method Details
-
getGroovyVersionString
Gets the version string of Groovy used from classpath.- Returns:
- The version string of Groovy used by the project
-
getGroovyVersion
Gets the version of Groovy used from the classpath.- Returns:
- The version of Groovy used by the project
-
groovyAtLeast
Determines whether the detected Groovy version is the specified version or newer.- Parameters:
detectedVersion- the detected Groovy versioncompareToVersion- the version to compare the detected Groovy version to- Returns:
trueif the detected Groovy version is the specified version or newer,falseotherwise
-
groovyIs
Determines whether the detected Groovy version is the specified version.- Parameters:
detectedVersion- the detected Groovy versioncompareToVersion- the version to compare the detected Groovy version to- Returns:
trueif the detected Groovy version is the specified version,falseotherwise
-
groovyNewerThan
Determines whether the detected Groovy version is newer than the specified version.- Parameters:
detectedVersion- the detected Groovy versioncompareToVersion- the version to compare the detected Groovy version to- Returns:
trueif the detected Groovy version is newer than the specified version,falseotherwise
-
groovyOlderThan
Determines whether the detected Groovy version is older than the specified version.- Parameters:
detectedVersion- the detected Groovy versioncompareToVersion- the version to compare the detected Groovy version to- Returns:
trueif the detected Groovy version is older than the specified version,falseotherwise
-
isGroovyIndy
public boolean isGroovyIndy()Gets whether the version of Groovy on the classpath supports invokedynamic.- Returns:
trueif the version of Groovy uses invokedynamic,falseif not or Groovy dependency cannot be found.
-
logGroovyVersion
Logs the version of groovy used by this mojo.- Parameters:
goal- The goal to mention in the log statement showing Groovy version
-
getClass
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
Returns the classloader used for loading classes.- Returns:
- the classloader used for loading classes
-
createNewClassLoader
protected ClassLoader createNewClassLoader(List<?> classpath, ClassLoader classLoader) 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 loaderclassLoader- the ClassLoader to use as the parent for the new CLassLoader- Returns:
- the new ClassLoader
- Throws:
MalformedURLException- when a classpath element provides a malformed URL
-
getGroovyJar
Returns the filename of the Groovy jar on the classpath.- Returns:
- the Groovy jar filename
-
getJarPath
Returns the path of the Groovy jar on the classpath.- Returns:
- the path of the Groovy jar
- Throws:
ClassNotFoundException- when Groovy couldn't be found on the classpath
-