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
ConstructorDescriptionClassWrangler
(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 ClassLoader
createNewClassLoader
(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 String
Returns 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 String
Returns the path of the Groovy jar on the classpath.static boolean
groovyAtLeast
(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is the specified version or newer.static boolean
Determines whether the detected Groovy version is the specified version.static boolean
groovyNewerThan
(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is newer than the specified version.static boolean
groovyOlderThan
(Version detectedVersion, Version compareToVersion) Determines whether the detected Groovy version is older than the specified version.boolean
Gets whether the version of Groovy on the classpath supports invokedynamic.void
logGroovyVersion
(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:
true
if the detected Groovy version is the specified version or newer,false
otherwise
-
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:
true
if the detected Groovy version is the specified version,false
otherwise
-
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:
true
if the detected Groovy version is newer than the specified version,false
otherwise
-
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:
true
if the detected Groovy version is older than the specified version,false
otherwise
-
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.
-
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
-