代码拉取完成,页面将自动刷新
def runShellCommand(cmd, theargs) {
def os = new ByteArrayOutputStream()
exec {
executable cmd
args theargs
standardOutput = os
}
return os.toString().replace("\n", "");
}
import java.text.SimpleDateFormat
def buildTime(){
def df = new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
def genBuildInfo(String czName, String pkgName, String baseDir) {
String header = "// " + czName + ".java generated by build script"
def commit = runShellCommand('git', ['rev-parse', 'HEAD'])
def branch = runShellCommand('git', ['rev-parse', '--abbrev-ref', 'HEAD'])
def tag = runShellCommand('git', ['name-rev', '--tags', '--name-only', commit])
def commitinfo = runShellCommand('git', ['show-branch', 'HEAD'])
def server = InetAddress.getLocalHost().getHostName()
def builder = System.getProperty('user.name')
def buildos = System.getProperty('os.name')
def buildtime = buildTime()
String modif = " public static final String "
String fname = baseDir + pkgName.replace(".", "/") + "/" + czName + ".java"
println "Generating build information to " + fname
new File(fname).withWriter { out ->
out.writeLine(header)
out.writeLine("package " + pkgName + ";")
out.writeLine("public final class " + czName + " {")
out.writeLine(modif + "VERSION = \"$version\";");
out.writeLine(modif + "BRANCH = \"$branch\";");
out.writeLine(modif + "TAG = \"$tag\";");
out.writeLine(modif + "COMMIT = \"$commit\";");
out.writeLine(modif + "COMMIT_INFO = \"$commitinfo\";");
out.writeLine(modif + "BUILD_SERVER = \"$server\";");
out.writeLine(modif + "BUILD_OS = \"$buildos\";");
out.writeLine(modif + "BUILD_USER = \"$builder\";");
out.writeLine(modif + "BUILD_TIME = \"$buildtime\";");
out.writeLine("}")
}
/*
exec {
executable 'cat'
args fname
}
*/
}
task genBuildInfo << {
String pkgName = 'feiw'
String gendir = '/generated-sources/'
new File(project.buildDir.toString() + gendir + pkgName.replace(".", "/")).mkdirs();
genBuildInfo('BuildInfo', pkgName, project.buildDir.toString() + gendir)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。