Groovy
  1. Groovy
  2. GROOVY-2422

API for checking version and capabilities of Groovy runtime

    Details

    • Type: Wish Wish
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      All

      Description

      As discussed on the groovy-user mailing list, the idea here is to provide a simple API for checking/asserting the Groovy version that a script is being run under or the "capabilities" it provides. This would allow scripts to ensure that the environment they are running in is able to support their needs and to either halt execution or recover gracefully.

      A potential API would look something like this:

      package groovy.lang
      
      class GroovyRuntime {
          /* Capability checks */
          static void registerCapability(String capability, String description)
      
          static boolean hasCapability(String... capability)
      
          static void assertCapability(String... capability) throws AssertionError
      
          /* Version checks */
          static boolean hasMinimumVersion(String version)
      
          static void assertMinimumVersion(String version) throws AssertionError
      
          static boolean hasVersionInRange(String minVersion, String maxVersion)
      
          static void assertVersionInRange(String minVersion, String maxVersion) throws AssertionError
      }
      

      The version checks would have enough smarts about the Groovy versioning scheme to be able to know about "beta", "rc", and "SNAPSHOT" in addition to standard version string comparison logic. For what it's worth, Perl has similar functionality (e.g. "use v5.8"). The capability checking mechanism would allow capabilities to be registered with a code and description and would allow capabilities to be checked by code. Capabilities would correspond to major features like "joint-compilation", "annotations", "enumerations", etc.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Mike Dillon
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development