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
  • 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 with
      parentClassLoader - the parent for the new ClassLoader used to use to load classes
      pluginLog - the Maven log to use for logging
      Throws:
      MalformedURLException - when a classpath element provides a malformed URL
  • Method Details

    • 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
    • groovyAtLeast

      public static boolean groovyAtLeast(Version detectedVersion, Version compareToVersion)
      Determines whether the detected Groovy version is the specified version or newer.
      Parameters:
      detectedVersion - the detected Groovy version
      compareToVersion - 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

      public static boolean groovyIs(Version detectedVersion, Version compareToVersion)
      Determines whether the detected Groovy version is the specified version.
      Parameters:
      detectedVersion - the detected Groovy version
      compareToVersion - the version to compare the detected Groovy version to
      Returns:
      true if the detected Groovy version is the specified version, false otherwise
    • groovyNewerThan

      public static boolean groovyNewerThan(Version detectedVersion, Version compareToVersion)
      Determines whether the detected Groovy version is newer than the specified version.
      Parameters:
      detectedVersion - the detected Groovy version
      compareToVersion - 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

      public static boolean groovyOlderThan(Version detectedVersion, Version compareToVersion)
      Determines whether the detected Groovy version is older than the specified version.
      Parameters:
      detectedVersion - the detected Groovy version
      compareToVersion - 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

      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
    • 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
    • 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 loader
      classLoader - 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

      protected 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 Groovy couldn't be found on the classpath