2 Star 9 Fork 3

慕容小草 / acp-admin-cloud

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
commonTask.gradle 5.49 KB
一键复制 编辑 原始数据 按行查看 历史
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("$project.name release finished: active=$project.active")
def envParam = jvmExtParam.get(project.active)
if (envParam != null) {
jvmExtParamBuilder.append("-Dacp_profile_active=$project.active" as String)
jvmExtParamBuilder.append(" -Dacp_nacos_addr=" + envParam['acp_nacos_addr'] as String)
jvmExtParamBuilder.append(" -Dacp_nacos_username=" + envParam['acp_nacos_username'] as String)
jvmExtParamBuilder.append(" -Dacp_nacos_password=" + envParam['acp_nacos_password'] as String)
jvmExtParamBuilder.append(" -Dacp_nacos_namespace=" + envParam['acp_nacos_namespace'] 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: ${project.name}-${project.version}.jar whith ${project.group}:${project.name}:${project.version} ...")
}
manifest {
attributes('Implementation-Vendor': "${project.group}", 'Implementation-Title': "${project.name}", 'Implementation-Version': "${project.version}", 'Build-By': "Gradle ${projectProperties.getProperty('gradleVersion')}", 'Jvm-Version': "${projectProperties.getProperty('javaVersion')}", 'Kotlin-Version': "$versions.kotlin")
}
}
tasks.register('clearPj', Delete) {
delete 'release', 'build', 'target', 'out'
}
tasks.register('release') {
dependsOn(build, copyJar)
onlyIf {
def excludePath = ["common"]
def needRelease = true
for (subPath in excludePath) {
if ("${projectDir}".startsWith("${rootDir}${File.separator}$subPath")) {
needRelease = false
break
}
}
new File("${projectDir}${File.separator}src").exists() && needRelease
}
doLast {
def fileName = "$project.name" + "-" + "$project.version" + ".jar"
generateShell(fileName)
copy {
from file("${layout.buildDirectory.get()}${File.separator}libs${File.separator}" + fileName)
into "$rootDir${File.separator}release${File.separator}$project.name"
}
copy {
from("${layout.buildDirectory.get()}${File.separator}bin") {
include("*.sh")
}
into "$rootDir${File.separator}release${File.separator}$project.name"
}
copy {
from "${layout.buildDirectory.get()}${File.separator}resources${File.separator}main"
into "$rootDir${File.separator}release${File.separator}$project.name"
}
println("$project.group:$project.name releaseed [$fileName] into $rootDir${File.separator}release${File.separator}$project.name")
}
}
Kotlin
1
https://gitee.com/zhangbinhub/acp-admin-cloud.git
git@gitee.com:zhangbinhub/acp-admin-cloud.git
zhangbinhub
acp-admin-cloud
acp-admin-cloud
master

搜索帮助