What I ended up doing was loading the MANIFEST resource and parsing out the file names from there. This works fine when it's part of a war file and built using with embedded jar files that have the library version in the jar filename.
Get installed dependency versions at runtime
-
05-10-2022 - |
Pregunta
I'm trying to get some information about specific libraries at runtime. So far what I have is a controller that has the following action
def getAboutInfo() {
Resource resource = grailsApplication.mainContext.getResource('/WEB-INF/resources/jenkinsBuildInfo')
def config = new ConfigSlurper().parse(resource.getFile().toURI().toURL())
def sysData = [
"Application Name": grailsApplication.metadata['app.name'],
"App Version": grailsApplication.metadata['app.version'],
"Grails Version": grailsApplication.metadata['app.grails.version'],
"SVN Revision": config.SVN_REVISION,
"Build Number": config.BUILD_NUMBER,
"Build Id": config.BUILD_ID,
"Java Version": System.getProperty("java.version")
]
def libraryInfo = []
render([success:true, applicationProperties:sysData,libraryInfo:libraryInfo] as JSON)
}
What I'd like to build is a list of information about each library that would look something like this...
def libraryInfo = []
['tomcat','joda-time','hibernate','group_id:artifact_id'].each{ name->
def libInfo = // look up information
libraryInfo << [
"Name":name,
Version:libInfo.version,
"Build Date":libInfo.build_date,
"Build Number":libInfo.build_number
]
}
Does anyone know if this is possible?
Solución 2
Otros consejos
You can use build-info plugin, which will work with your SCM (Git and SVN). It will give you the following information:
date/time the war file was built
Source Control Revision Number (Git and Subversion)
application version number
grails version
grails environment (currently running, not necessarily the environment used to build the war file)
plugins installed (and which version)
Source: build-info plugin
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow