gpt4 book ai didi

java - 在运行时获取安装的依赖版本

转载 作者:行者123 更新时间:2023-12-01 13:32:50 27 4
gpt4 key购买 nike

我正在尝试在运行时获取有关特定库的一些信息。到目前为止,我拥有的是一个具有以下操作的 Controller

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)
}

我想要构建的是有关每个库的信息列表,看起来像这样......

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
]
}

有人知道这是否可行吗?

最佳答案

您可以使用 build-info 插件,它将与您的 SCM(Git 和 SVN)配合使用。它将为您提供以下信息:

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)

来源:build-info plugin

关于java - 在运行时获取安装的依赖版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21466456/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com