Skip to content

Commit

Permalink
Merge pull request #226 from grails/add-jvm-version-info
Browse files Browse the repository at this point in the history
Add JVM version info to Grails CLI
  • Loading branch information
puneetbehl authored Nov 7, 2023
2 parents ef8ce00 + e257710 commit 7158db8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class GrailsVersionProvider implements IVersionProvider {

public String[] getVersion() {
return new String[] {
"Grails Version: " + VersionInfo.getGrailsVersion()
"Grails Version: " + VersionInfo.getGrailsVersion(),
"JVM Version: " + System.getProperty("java.version")
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.grails.forge.cli.command

import io.micronaut.configuration.picocli.PicocliRunner
import io.micronaut.context.ApplicationContext
import io.micronaut.context.env.Environment
import org.grails.forge.cli.Application
import org.grails.forge.cli.CommandFixture
import org.grails.forge.cli.CommandSpec
import org.grails.forge.util.VersionInfo
import spock.lang.AutoCleanup
import spock.lang.Shared

class ApplicationCommandSpec extends CommandSpec implements CommandFixture {

@Shared
@AutoCleanup
ApplicationContext ctx = ApplicationContext.run(Environment.CLI)

@Shared
@AutoCleanup
ApplicationContext beanContext = ApplicationContext.run()

void "print version info via: grails #args"() {
given:
ByteArrayOutputStream out = new ByteArrayOutputStream()
System.setOut(new PrintStream(out))

when:
PicocliRunner.run(Application, ctx, args)

then:
noExceptionThrown()
out.toString().contains("Grails Version: " + VersionInfo.getGrailsVersion())
out.toString().contains("JVM Version: " + System.getProperty("java.version"))

where:
args | _
"--version" | _
"-V" | _
}
}

0 comments on commit 7158db8

Please sign in to comment.