mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Refactoring.
This commit is contained in:
parent
3147fe43a1
commit
45001a5104
1 changed files with 11 additions and 12 deletions
|
@ -93,26 +93,25 @@ 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)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue