1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Refactoring.

This commit is contained in:
Cedric Beust 2015-10-06 22:15:10 -07:00
parent 3147fe43a1
commit 45001a5104

View file

@ -93,27 +93,26 @@ public class ProjectGenerator : KobaltLogger {
testDeps.addAll(partition.second) testDeps.addAll(partition.second)
} }
private fun updateVersion(dep: Dependency, mapped: Map<String, String>): Dependency { private fun updateVersion(dep: Dependency, mapped: Map<String, String>) =
if ( dep.version.startsWith("\${")) { if ( dep.version.startsWith("\${")) {
val property = dep.version.substring(2, dep.version.length() - 1) val property = dep.version.substring(2, dep.version.length() - 1)
return Dependency(dep.groupId, dep.artifactId, "\${${mapped.get(property)}}", dep.optional, dep.scope) Dependency(dep.groupId, dep.artifactId, "\${${mapped.get(property)}}", dep.optional, dep.scope)
} else { } else {
return dep dep
} }
}
private fun translate(key: String) : String { /**
val split = key.split('.') * Turns a dot property into a proper Kotlin identifier, e.g. common.version -> commonVersion
return split.mapIndexed( { index, value -> if (index == 0) value else value.upperFirst() }).join("") */
} private fun translate(key: String) =
key.split('.').mapIndexed( { index, value -> if (index == 0) value else value.upperFirst() }).join("")
private fun String.upperFirst(): String { private fun String.upperFirst() =
if (this.isBlank()) { if (this.isBlank()) {
return this this
} else { } else {
return this.substring(0, 1).toUpperCase() + this.substring(1) this.substring(0, 1).toUpperCase() + this.substring(1)
} }
}
/** /**
* Detect all the languages contained in this project. * Detect all the languages contained in this project.