Ian Springer created MENFORCER-348:
--------------------------------------

             Summary: add a graalvm enforcer rule
                 Key: MENFORCER-348
                 URL: https://issues.apache.org/jira/browse/MENFORCER-348
             Project: Maven Enforcer Plugin
          Issue Type: New Feature
          Components: Standard Rules
            Reporter: Ian Springer

Our project relies on the GraalVM. We currently have a gmavenplus-plugin 
snippet that enforces 1) that the build JDK is GraalVM, and 2) that it has the 
required version. It looks like this:

 
{code:java}
<script><![CDATA[
    import org.apache.tools.ant.BuildLogger
    import org.apache.tools.ant.types.LogLevel

    def currentProjectDir = new File("${basedir}")

    def javaVmName = System.properties['java.vm.name']
    def vmVersion = "${java.vm.version}".tokenize("-")
    def runtimeVer = "${java.runtime.version}".tokenize(".")
    def graalVersion = "${graal.version}";

    if (graalVersion.reverse().take(1) == "0") {
        graalVersion = graalVersion.substring(0, graalVersion.length() - 2)
    }

    if (!(javaVmName =~ "GraalVM") && !(runtimeVer.contains("graal"))) {
        ant.fail "Build JVM is not GraalVM."
    }

    if (!javaVmName.endsWith("${graal.version}") && 
!(vmVersion.contains(graalVersion))) {
        ant.fail "GraalVM version is not ${graal.version}. Found ${vmVersion} 
instead."
    }

    print "Build JVM: ${javaVmName}\n"
]]>
</script>
{code}
 

It would be great if the enforcer plugin had a builtin rule for this that 
looked like this:

 
{code:java}
<requireGraalVmVersion> 
    <version>19.3.1</version>
</requireGraalVmVersion>
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to