Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Jun 14, 2021
1 parent 069da07 commit 56e9dab
Showing 1 changed file with 110 additions and 90 deletions.
200 changes: 110 additions & 90 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -229,120 +229,140 @@ tasks {
copy {
from(zipTree(downloadOmnisharpLinuxZipFile.get().dest))
into(file("$destinationDir/$pluginName/omnisharp/linux"))
exclude("run")
}
// Workaround for https://github.com/OmniSharp/omnisharp-roslyn/pull/1979
copy {
from(zipTree(downloadOmnisharpLinuxZipFile.get().dest))
into(file("$destinationDir/$pluginName/omnisharp/linux"))
include("run")
filter {
it.replace("export MONO_ENV_OPTIONS=\"--assembly-loader=strict --config \${config_file}\"", "export MONO_ENV_OPTIONS=\"--assembly-loader=strict --config \\\"\${config_file}\\\"\"")
}
}
copy {
from(zipTree(downloadOmnisharpOsxZipFile.get().dest))
into(file("$destinationDir/$pluginName/omnisharp/osx"))
exclude("run")
}
// Workaround for https://github.com/OmniSharp/omnisharp-roslyn/pull/1979
copy {
from(zipTree(downloadOmnisharpOsxZipFile.get().dest))
into(file("$destinationDir/$pluginName/omnisharp/osx"))
include("run")
filter {
it.replace("export MONO_ENV_OPTIONS=\"--assembly-loader=strict --config \${config_file}\"", "export MONO_ENV_OPTIONS=\"--assembly-loader=strict --config \\\"\${config_file}\\\"\"")
}
}
copy {
from(zipTree(downloadOmnisharpWindowsZipFile.get().dest))
into(file("$destinationDir/$pluginName/omnisharp/win"))
}
}
}


val buildPluginBlockmap by registering {
inputs.file(buildPlugin.get().archiveFile)
doLast {
val distribZip = buildPlugin.get().archiveFile.get().asFile
val blockMapBytes =
com.fasterxml.jackson.databind.ObjectMapper().writeValueAsBytes(BlockMap(distribZip.inputStream()))
val blockMapFile = File(distribZip.parentFile, "blockmap.json")
blockMapFile.writeBytes(blockMapBytes)
val blockMapFileZipFile = file(distribZip.absolutePath + ".blockmap.zip")
val blockMapFileZip = ZipOutputStream(BufferedOutputStream(FileOutputStream(blockMapFileZipFile)))
val fi = FileInputStream(blockMapFile)
val origin = BufferedInputStream(fi)
val entry = ZipEntry(blockMapFile.name)
blockMapFileZip.putNextEntry(entry)
origin.copyTo(blockMapFileZip, 1024)
origin.close()
blockMapFileZip.close()
artifacts.add("archives", blockMapFileZipFile) {
name = project.name
extension = "zip.blockmap.zip"
type = "zip"
builtBy("buildPluginBlockmap")
}
val fileHash = com.fasterxml.jackson.databind.ObjectMapper()
.writeValueAsString(com.jetbrains.plugin.blockmap.core.FileHash(distribZip.inputStream()))
val fileHashJsonFile = file(distribZip.absolutePath + ".hash.json")
fileHashJsonFile.writeText(fileHash)
artifacts.add("archives", fileHashJsonFile) {
name = project.name
extension = "zip.hash.json"
type = "json"
builtBy("buildPluginBlockmap")
val buildPluginBlockmap by registering {
inputs.file(buildPlugin.get().archiveFile)
doLast {
val distribZip = buildPlugin.get().archiveFile.get().asFile
val blockMapBytes =
com.fasterxml.jackson.databind.ObjectMapper().writeValueAsBytes(BlockMap(distribZip.inputStream()))
val blockMapFile = File(distribZip.parentFile, "blockmap.json")
blockMapFile.writeBytes(blockMapBytes)
val blockMapFileZipFile = file(distribZip.absolutePath + ".blockmap.zip")
val blockMapFileZip = ZipOutputStream(BufferedOutputStream(FileOutputStream(blockMapFileZipFile)))
val fi = FileInputStream(blockMapFile)
val origin = BufferedInputStream(fi)
val entry = ZipEntry(blockMapFile.name)
blockMapFileZip.putNextEntry(entry)
origin.copyTo(blockMapFileZip, 1024)
origin.close()
blockMapFileZip.close()
artifacts.add("archives", blockMapFileZipFile) {
name = project.name
extension = "zip.blockmap.zip"
type = "zip"
builtBy("buildPluginBlockmap")
}
val fileHash = com.fasterxml.jackson.databind.ObjectMapper()
.writeValueAsString(com.jetbrains.plugin.blockmap.core.FileHash(distribZip.inputStream()))
val fileHashJsonFile = file(distribZip.absolutePath + ".hash.json")
fileHashJsonFile.writeText(fileHash)
artifacts.add("archives", fileHashJsonFile) {
name = project.name
extension = "zip.hash.json"
type = "json"
builtBy("buildPluginBlockmap")
}
}
}
}

buildPlugin {
finalizedBy(buildPluginBlockmap)
}
buildPlugin {
finalizedBy(buildPluginBlockmap)
}

jacocoTestReport {
classDirectories.setFrom(files("build/classes/java/main-instrumented"))
reports {
xml.setEnabled(true)
jacocoTestReport {
classDirectories.setFrom(files("build/classes/java/main-instrumented"))
reports {
xml.setEnabled(true)
}
}
}
}


sonarqube {
properties {
property("sonar.projectName", "SonarLint for IntelliJ IDEA")
sonarqube {
properties {
property("sonar.projectName", "SonarLint for IntelliJ IDEA")
}
}
}

license {
mapping(
mapOf(
"java" to "SLASHSTAR_STYLE",
"kt" to "SLASHSTAR_STYLE"
license {
mapping(
mapOf(
"java" to "SLASHSTAR_STYLE",
"kt" to "SLASHSTAR_STYLE"
)
)
)
strictCheck = true
}
strictCheck = true
}

artifactory {
clientConfig.info.setBuildName("sonarlint-intellij")
clientConfig.info.setBuildNumber(System.getenv("BUILD_BUILDID"))
clientConfig.setIncludeEnvVars(true)
clientConfig.setEnvVarsExcludePatterns("*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*PASSPHRASE*,*signing*")
clientConfig.info.addEnvironmentProperty(
"ARTIFACTS_TO_DOWNLOAD",
"org.sonarsource.sonarlint.intellij:sonarlint-intellij:zip"
)
setContextUrl(System.getenv("ARTIFACTORY_URL"))
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
setProperty("repoKey", System.getenv("ARTIFACTORY_DEPLOY_REPO"))
setProperty("username", System.getenv("ARTIFACTORY_DEPLOY_USERNAME"))
setProperty("password", System.getenv("ARTIFACTORY_DEPLOY_PASSWORD"))
})
defaults(delegateClosureOf<GroovyObject> {
setProperty(
"properties", mapOf(
"vcs.revision" to System.getenv("BUILD_SOURCEVERSION"),
"vcs.branch" to (System.getenv("SYSTEM_PULLREQUEST_TARGETBRANCH")
?: System.getenv("BUILD_SOURCEBRANCHNAME")),
"build.name" to "sonarlint-intellij",
"build.number" to System.getenv("BUILD_BUILDID")
)
)
invokeMethod("publishConfigs", "archives")
setProperty("publishPom", true) // Publish generated POM files to Artifactory (true by default)
setProperty("publishIvy", false) // Publish generated Ivy descriptor files to Artifactory (true by default)
artifactory {
clientConfig.info.setBuildName("sonarlint-intellij")
clientConfig.info.setBuildNumber(System.getenv("BUILD_BUILDID"))
clientConfig.setIncludeEnvVars(true)
clientConfig.setEnvVarsExcludePatterns("*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*PASSPHRASE*,*signing*")
clientConfig.info.addEnvironmentProperty(
"ARTIFACTS_TO_DOWNLOAD",
"org.sonarsource.sonarlint.intellij:sonarlint-intellij:zip"
)
setContextUrl(System.getenv("ARTIFACTORY_URL"))
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
setProperty("repoKey", System.getenv("ARTIFACTORY_DEPLOY_REPO"))
setProperty("username", System.getenv("ARTIFACTORY_DEPLOY_USERNAME"))
setProperty("password", System.getenv("ARTIFACTORY_DEPLOY_PASSWORD"))
})
defaults(delegateClosureOf<GroovyObject> {
setProperty(
"properties", mapOf(
"vcs.revision" to System.getenv("BUILD_SOURCEVERSION"),
"vcs.branch" to (System.getenv("SYSTEM_PULLREQUEST_TARGETBRANCH")
?: System.getenv("BUILD_SOURCEBRANCHNAME")),
"build.name" to "sonarlint-intellij",
"build.number" to System.getenv("BUILD_BUILDID")
)
)
invokeMethod("publishConfigs", "archives")
setProperty("publishPom", true) // Publish generated POM files to Artifactory (true by default)
setProperty("publishIvy", false) // Publish generated Ivy descriptor files to Artifactory (true by default)
})
})
})
}
}

signing {
setRequired({
gradle.taskGraph.hasTask(":artifactoryPublish") && System.getenv("SYSTEM_PULLREQUEST_TARGETBRANCH") == null;
})
sign(configurations.archives.get())
signing {
setRequired({
gradle.taskGraph.hasTask(":artifactoryPublish") && System.getenv("SYSTEM_PULLREQUEST_TARGETBRANCH") == null;
})
sign(configurations.archives.get())
}
}

0 comments on commit 56e9dab

Please sign in to comment.