Ai
7 Star 19 Fork 6

慕容小草/acp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
commonTask.gradle 4.74 KB
一键复制 编辑 原始数据 按行查看 历史
慕容小草 提交于 2025-09-03 17:27 +08:00 . [Upgrade] 优化脚本
def generateShell = { String appJarName ->
mkdir("${layout.buildDirectory.get()}${File.separator}bin")
def memoryParam = jvmMemoryParam.get('default') as String
// generate linux shell
File templateFile = new File("$rootDir${File.separator}doc${File.separator}script${File.separator}server.model")
List<String> lines = templateFile.readLines("UTF-8")
StringBuilder buffer = new StringBuilder()
for (String line : lines) {
buffer.append(line).append("\n")
}
String shellContent = buffer.toString()
shellContent = shellContent.replaceAll("@appJarName@", appJarName)
shellContent = shellContent.replaceAll("@jvmMemoryParam@", memoryParam)
StringBuilder jvmExtParamBuilder = new StringBuilder()
jvmExtParamBuilder.append("'")
if (project.hasProperty("active") && project.active != null && project.active != "") {
println("${this.name} release finished: active=${this.active}")
def envParam = jvmExtParam.get(project.active)
if (envParam != null) {
jvmExtParamBuilder.append("-Dacp_profile_active=${this.active}" as String)
jvmExtParamBuilder.append(" -Dacp_log_path=" + envParam['acp_log_path'] as String)
}
}
jvmExtParamBuilder.append("'")
shellContent = shellContent.replaceAll("@jvmExtParam@", jvmExtParamBuilder.toString())
File outFile = new File("${layout.buildDirectory.get()}${File.separator}bin${File.separator}server.sh")
Writer writer = new FileWriter(outFile)
writer.write(new String(shellContent.getBytes("UTF-8")))
writer.flush()
writer.close()
} as Object
tasks.register('copyJar', Copy) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(configurations.runtimeClasspath)
into("${layout.buildDirectory.get()}${File.separator}libs${File.separator}dependencies")
}
tasks.register('mapperFileCopy', Copy) {
copy {
from("src${File.separator}main${File.separator}java") {
include("**${File.separator}*.xml")
include("**${File.separator}*.json")
include("**${File.separator}*.properties")
}
into("${layout.buildDirectory.get()}${File.separator}classes${File.separator}main")
}
copy {
from("src${File.separator}test${File.separator}java") {
include("**${File.separator}*.xml")
include("**${File.separator}*.json")
include("**${File.separator}*.properties")
}
into("${layout.buildDirectory.get()}${File.separator}classes${File.separator}test")
}
copy {
from("src${File.separator}main${File.separator}kotlin") {
include("**${File.separator}*.xml")
include("**${File.separator}*.json")
include("**${File.separator}*.properties")
}
into("${layout.buildDirectory.get()}${File.separator}classes${File.separator}main")
}
copy {
from("src${File.separator}test${File.separator}kotlin") {
include("**${File.separator}*.xml")
include("**${File.separator}*.json")
include("**${File.separator}*.properties")
}
into("${layout.buildDirectory.get()}${File.separator}classes${File.separator}test")
}
}
jar {
dependsOn(copyJar)
doFirst {
println("Begin building jar: ${this.name}-${this.version}.jar whith ${this.group}:${this.name}:${this.version} ...")
}
manifest {
attributes('Implementation-Vendor': "${this.group}", 'Implementation-Title': "${this.name}", 'Implementation-Version': "${this.version}", 'Build-By': "Gradle ${gradle.gradleVersion}", 'Jvm-Version': "${projectProperties.getProperty('javaVersion')}", 'Kotlin-Version': "${libs.versions.kotlin.get()}")
}
}
tasks.register('clearPj', Delete) {
dependsOn(clean)
delete 'release', 'build', 'target', 'out'
doLast {
println("${this.group}:${this.name} output cleared!")
}
}
tasks.register('release') {
dependsOn(build, copyJar)
doLast {
def fileName = "${this.name}" + "-" + "${this.version}" + ".jar"
generateShell(fileName)
copy {
from file("${layout.buildDirectory.get()}${File.separator}libs${File.separator}" + fileName)
into "$rootDir${File.separator}release${File.separator}${this.name}"
}
copy {
from("${layout.buildDirectory.get()}${File.separator}bin") {
include("*.sh")
}
into "$rootDir${File.separator}release${File.separator}${this.name}"
}
copy {
from "${layout.buildDirectory.get()}${File.separator}resources${File.separator}main"
into "$rootDir${File.separator}release${File.separator}${this.name}"
}
println("Released [$fileName] into $rootDir${File.separator}release${File.separator}${this.name}")
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Kotlin
1
https://gitee.com/zhangbinhub/acp.git
git@gitee.com:zhangbinhub/acp.git
zhangbinhub
acp
acp
master

搜索帮助