1 Star 0 Fork 1

1a1zy / momo-code-sec-inspector-java

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle 3.62 KB
一键复制 编辑 原始数据 按行查看 历史
retanoj 提交于 2021-05-19 09:55 . clean report
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.5.0'
}
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.commons', name: 'commons-lang3', version: '3.4'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.13'
implementation group: 'me.gosimple', name: 'nbvcxz', version: '1.5.0'
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'
1
https://gitee.com/thiefz/momo-code-sec-inspector-java.git
git@gitee.com:thiefz/momo-code-sec-inspector-java.git
thiefz
momo-code-sec-inspector-java
momo-code-sec-inspector-java
2018.3

搜索帮助