snowe
05/21/2019, 2:55 PMStringGroovyMethods#getAt(Matcher matcher, int idx)
method?hho
05/21/2019, 4:12 PMsnowe
05/21/2019, 4:44 PMrelease {
failOnPublishNeeded = true
failOnSnapshotDependencies = true
failOnCommitNeeded = true
useAutomaticVersion = true
git {
requireBranch = 'develop'
pushToRemote = 'origin'
pushToBranchPrefix = 'release/'
}
// Using `useAutomaticVersion` this increments the release to the next 'minor' version.
versionPatterns = [
/(\d+)\.(\d+)\.(\d+)([^\d]*$)/: { Matcher m, Project p ->
m.replaceAll("${m[0][1]}.${(m[0][2] as int) + 1}.${m[0][3]}${m[0][4]}")
}
]
}
needs to be converted to kotlin.val release = extensions.findByType<ReleaseExtension>()
release?.failOnPublishNeeded = true
release?.failOnSnapshotDependencies = true
release?.failOnCommitNeeded = true
release?.useAutomaticVersion = true
release?.closureOf<GitAdapter.GitConfig> {
this.requireBranch = 'develop'
this.pushToRemote = 'origin'
this.pushToBranchPrefix = 'release/'
}
// release?.versionPatterns = mapOf("(\\d+)\\.(\\d+)\\.(\\d+)([^\\d]*\$)" to closureOf<String>{ m: Matcher, p: Project -> m.replaceAll("${m[0][1]}.${(m[0][2] as int) + 1}.${m[0][3]}${m[0][4]}") })
release?.versionPatterns = mapOf("(\\d+)\\.(\\d+)\\.(\\d+)([^\\d]*\$)" to KotlinClosure2({ m: Matcher, p: Project -> m.replaceAll("${m[0][1]}") }))
fun Matcher.get(idx: Int): Any? {
var idx = idx
try {
val count = getCount(this)
if (idx >= -count && idx < count) {
idx = normaliseIndex(idx, count)
val iter = iterator(this)
var result: Any? = null
for (i in 0..idx) {
result = iter.next()
}
return result
} else {
throw IndexOutOfBoundsException("index is out of range " + -count + ".." + (count - 1) + " (index = " + idx + ")")
}
} catch (var6: IllegalStateException) {
return null
}
}
private fun normaliseIndex(i: Int, size: Int): Int {
var i = i
val temp = i
if (i < 0) {
i += size
}
return if (i < 0) {
throw ArrayIndexOutOfBoundsException("Negative array index [$temp] too large for array size $size")
} else {
i
}
}
private fun getCount(matcher: Matcher): Int {
var counter = 0
matcher.reset()
while (matcher.find()) {
++counter
}
return counter
}
fun iterator(matcher: Matcher): Iterator<*> {
matcher.reset()
return object : Iterator<Any> {
private var found: Boolean = false
private var done: Boolean = false
override operator fun hasNext(): Boolean {
if (this.done) {
return false
} else {
if (!this.found) {
this.found = matcher.find()
if (!this.found) {
this.done = true
}
}
return this.found
}
}
override operator fun next(): Any {
if (!this.found && !this.hasNext()) {
throw NoSuchElementException()
} else {
this.found = false
if (!StringGroovyMethods.hasGroup(matcher)) {
return matcher.group()
} else {
val list = ArrayList(matcher.groupCount())
for (i in 0..matcher.groupCount()) {
list.add(matcher.group(i))
}
return list
}
}
}
}
}
[]
working, but that's actually a second call... DefaultGroovyMethods#getAt
ughhhh