IJI-9: run configuration name fix, build failure message fix, cleanup

This commit is contained in:
Dmitriy.Panov
2018-05-17 13:28:33 +03:00
parent a58352699b
commit e85655fb70
4 changed files with 19 additions and 12 deletions
+6 -3
View File
@@ -10,7 +10,7 @@ import org.jetbrains.jps.util.JpsPathUtil
import java.nio.file.Paths
target('default': 'Check icons in repositories') {
target('default': 'Check icons in IntelliJIcons repository') {
def root = Paths.get(
System.getProperty('teamcity.build.checkoutDir') ?: '.'
).normalize().toAbsolutePath().toString()
@@ -43,7 +43,7 @@ target('default': 'Check icons in repositories') {
def sync = 'sync'
String[] repos = System.properties."$repoArg"?.toString()?.split(/,/) ?: []
if (repos.length < 2) {
context.messages.error("Usage: -D$repoArg=<codeRepoDir>,<iconsRepoDir> [-D$patternArg=...] [-D$sync=false|true]")
context.messages.error("Usage: -D$repoArg=<devRepoDir>,<iconsRepoDir> [-D$patternArg=...] [-D$sync=false|true]")
System.exit(1)
}
def skipDirsPattern = System.properties."$patternArg"?.toString() ?: null
@@ -51,7 +51,10 @@ target('default': 'Check icons in repositories') {
Class.forName('org.jetbrains.intellij.build.images.sync.CheckIconsKt').checkIcons(
repos[0], repos[1], skipDirsPattern, Boolean.parseBoolean(System.properties[sync] as String),
{ String msg -> msg.split(/\n/).each { context.messages.info(it) } },
{ String msg -> context.messages.buildStatus(msg); System.exit(1) }
{ String msg ->
context.messages.buildStatus("To sync icons use 'Sync icons in IntelliJIcons repository' run configuration from IDEA Ultimate repository. $msg")
System.exit(1)
}
)
}
catch (Exception e) {
@@ -88,7 +88,7 @@ internal fun findGitRepoRoot(path: String): File = File(path).let {
internal fun addChangesToGit(files: List<String>, repo: File) {
// OS has argument length limit
files.split(1000).forEach {
"$GIT add ${it.joinToString(" ")}".execute(repo, true)
(listOf(GIT, "add") + it).execute(repo, true)
}
}
@@ -22,14 +22,15 @@ private fun doSyncAdded(added: Collection<String>,
devIcons: Map<String, GitObject>,
iconsDir: String) {
val iconsRepo = findGitRepoRoot(iconsDir)
val iconsRoot = File(iconsRepo, iconsDir.removePrefix(iconsRepo.path))
val unversioned = mutableListOf<String>()
added.forEach {
val target = File(iconsRoot, it)
val target = File("$iconsDir/$it")
if (target.exists()) log("$it already exists in icons repo!")
val source = devIcons[it]!!.getFile()
source.copyTo(target, overwrite = true)
unversioned += target.relativeTo(iconsRepo).path
unversioned += target.relativeTo(iconsRepo).path.let {
if (it.contains(" ")) "\"$it\"" else it
}
}
addChangesToGit(unversioned, iconsRepo)
}
@@ -38,8 +39,8 @@ private fun doSyncModified(modified: Collection<String>,
icons: Map<String, GitObject>,
devIcons: Map<String, GitObject>) {
modified.forEach {
val dest = icons[it]!!.getFile()
val target = icons[it]!!.getFile()
val source = devIcons[it]!!.getFile()
source.copyTo(dest, overwrite = true)
source.copyTo(target, overwrite = true)
}
}
@@ -14,11 +14,14 @@ internal fun String.splitWithTab(): List<String> = this.split("\t".toRegex())
internal fun String.execute(workingDir: String): String = execute(File(workingDir))
internal fun String.execute(workingDir: File?, silent: Boolean = false): String {
if (!silent) log("Executing command $this")
internal fun String.execute(workingDir: File?, silent: Boolean = false): String =
this.splitWithSpace().execute(workingDir, silent)
internal fun List<String>.execute(workingDir: File?, silent: Boolean = false): String {
if (!silent) log("Executing command ${this.joinToString(" ")}")
val start = System.currentTimeMillis()
return try {
val process = ProcessBuilder(*this.splitWithSpace().toTypedArray())
val process = ProcessBuilder(*this.toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)