加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.gradle 4.05 KB
一键复制 编辑 原始数据 按行查看 历史
retanoj 提交于 2020-10-09 10:12 . version x.8
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.21'
id 'io.freefair.aspectj.post-compile-weaving' version '4.1.6'
}
group 'com.immomo.momosec'
version plugin_version
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
dependencies {
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
compileOnly group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.13'
implementation group: 'org.aspectj', name: 'aspectjrt', version: '1.9.3'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}
import groovy.xml.XmlUtil
import groovy.util.XmlSlurper
import org.apache.tools.ant.filters.ReplaceTokens
def plugin_env=project.getProperties().get("MOMO_CODE_SEC_INSPECTOR_ENV", "dev")
println "plugin env: ${plugin_env}"
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version idea_version
pluginName project.name + "-" + plugin_env
println "pluginName change to: ${pluginName}"
def versionParts = version.replace('IU-', '').split('\\.')
if ((Integer.parseInt(versionParts[0] as String) == 2019 && Integer.parseInt(versionParts[1] as String) >= 2) ||
Integer.parseInt(versionParts[0] as String) > 2019
) {
/* since 2019.2 Java is a separate plugin, hence we have to specify it implicitly */
plugins = [
'java',
'git4idea'
]
} else {
plugins = [
'git4idea'
]
}
}
test {
systemProperty "idea.home.path", IDEA_HOME_PATH
}
def htmlFixer = { htmlFile -> file(htmlFile).text.replace('<html>', '').replace('</html>', '') }
def mdToHtml = { mdFile ->
String htmlText = "\n<body>\n"
file(mdFile).eachLine {
if (it.startsWith("# ")) {
htmlText += "<b>" + it.substring(2) + "</b>"
} else if (it.startsWith("## ")) {
htmlText += "<b>> version " + it.substring(3) + "</b>"
} else if (it.startsWith("### ")) {
htmlText += "<b># " + it.substring(4) + "</b>"
} else {
htmlText += it
}
htmlText += "<br/>\n"
}
return htmlText + "</body>\n"
}
patchPluginXml {
sinceBuild = idea_since_build
untilBuild = idea_until_build
pluginDescription = htmlFixer('src/main/resources/META-INF/description.html')
changeNotes = mdToHtml('CHANGELOG.md')
}
task deleteAppProperties(type: Delete) {
delete "${buildDir}/resources/main"
}
task copyProperties(type: Copy, dependsOn: [deleteAppProperties]) {
from("src/main/resources/properties/${plugin_env}.properties") {
filter(ReplaceTokens, tokens: ["plugin_version": plugin_version])
}
rename { _ -> "app.properties" }
into "${buildDir}/resources/main/properties/"
}
processResources.dependsOn(copyProperties)
task addPluginNamePrefix(dependsOn: [processResources]) {
doLast {
if (plugin_env == "prod") {
return
}
def pluginXmlFile = file("${buildDir}/resources/main/META-INF/plugin.xml")
def content = new XmlSlurper().parse(pluginXmlFile)
def oldPluginName = content.name.text()
println "plugin Name replace with: [${oldPluginName} - ${plugin_env}]"
content.name.replaceBody("${oldPluginName} - ${plugin_env}")
pluginXmlFile.write(XmlUtil.serialize(content))
}
}
build.dependsOn(addPluginNamePrefix)
sourceSets {
test {
resources {
srcDir 'src/test/testData'
}
}
}
wrapper {
gradleVersion '6.1.1'
}
test.testLogging.exceptionFormat = 'full'
compileJava.options.encoding = 'UTF-8'
compileJava.ajc.options.compilerArgs += "-showWeaveInfo"
compileJava.ajc.options.compilerArgs += "-verbose"
compileJava.ajc.enabled=false
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化