Skip to content

Commit

Permalink
release: bump version to v0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
uchuhimo committed Jan 30, 2019
1 parent b1182b8 commit e7473b5
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 70 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -64,20 +64,20 @@ This library has been published to [Maven Central](https://search.maven.org/arti
<dependency>
<groupId>com.uchuhimo</groupId>
<artifactId>konf</artifactId>
<version>0.13</version>
<version>0.13.1</version>
</dependency>
```

### Gradle

```groovy
compile 'com.uchuhimo:konf:0.13'
compile 'com.uchuhimo:konf:0.13.1'
```

### Gradle Kotlin DSL

```kotlin
compile(group = "com.uchuhimo", name = "konf", version = "0.13")
compile(group = "com.uchuhimo", name = "konf", version = "0.13.1")
```

### Maven (master snapshot)
Expand Down
98 changes: 55 additions & 43 deletions build.gradle.kts
@@ -1,15 +1,14 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.jfrog.bintray.gradle.BintrayExtension
import com.novoda.gradle.release.PublishExtension
import io.spring.gradle.dependencymanagement.dsl.DependenciesHandler
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import io.spring.gradle.dependencymanagement.dsl.DependencySetHandler
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.LinkMapping
import java.util.Properties
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.util.Properties

val bintrayUserProperty by extra { getPrivateProperty("bintrayUser") }
val bintrayKeyProperty by extra { getPrivateProperty("bintrayKey") }
Expand All @@ -25,7 +24,6 @@ buildscript {
}
dependencies {
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.bintrayPlugin}")
classpath("com.novoda:bintray-release:${Versions.bintrayRelease}")
}
}

Expand All @@ -44,11 +42,10 @@ plugins {
id("org.jetbrains.dokka") version Versions.dokka
}

apply(plugin = "com.novoda.bintray-release")
apply(plugin = "com.jfrog.bintray")

group = "com.uchuhimo"
version = "0.13"
version = "0.13.1"

repositories {
aliyunMaven()
Expand Down Expand Up @@ -245,9 +242,8 @@ val check by tasks.existing {
}

val dokka by tasks.existing(DokkaTask::class) {
outputFormat = "html"
val javadoc: Javadoc by tasks
outputDirectory = javadoc.destinationDir!!.path
outputFormat = "javadoc"
outputDirectory = tasks.javadoc.get().destinationDir!!.path
jdkVersion = 8
linkMapping(delegateClosureOf<LinkMapping> {
dir = project.rootDir.toPath().resolve("src/main/kotlin").toFile().path
Expand All @@ -259,64 +255,81 @@ val dokka by tasks.existing(DokkaTask::class) {
})
}

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(dokka)
}

val projectDescription = "A type-safe cascading configuration library for Kotlin/Java, " +
"supporting most configuration formats"
val projectGroup = project.group as String
val projectName = rootProject.name
val projectVersion = project.version as String
val projectUrl = "https://github.com/uchuhimo/konf"

configure<PublishExtension> {
userOrg = "uchuhimo"
groupId = projectGroup
artifactId = projectName
publishVersion = projectVersion
setLicences("Apache-2.0")
desc = projectDescription
website = projectUrl
bintrayUser = bintrayUserProperty
bintrayKey = bintrayKeyProperty
dryRun = false
override = false
}

publishing {
publications {
afterEvaluate {
getByName<MavenPublication>("maven") {
pom {
name.set(rootProject.name)
description.set(projectDescription)
url.set(projectUrl)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("uchuhimo")
name.set("uchuhimo")
email.set("uchuhimo@outlook.com")
}
create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())

groupId = projectGroup
artifactId = projectName
version = projectVersion
pom {
name.set(rootProject.name)
description.set(projectDescription)
url.set(projectUrl)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
scm {
url.set(projectUrl)
}
developers {
developer {
id.set("uchuhimo")
name.set("uchuhimo")
email.set("uchuhimo@outlook.com")
}
}
scm {
url.set(projectUrl)
}
}
}
}
}

configure<BintrayExtension> {
user = bintrayUserProperty
key = bintrayKeyProperty
publish = true
dryRun = false
override = false
setPublications("maven")

pkg.apply {
setLabels("kotlin", "config")
publicDownloadNumbers = true
repo = "maven"
userOrg = "uchuhimo"
name = projectName
desc = projectDescription
websiteUrl = projectUrl
issueTrackerUrl = "$projectUrl/issues"
vcsUrl = "$projectUrl.git"
setLicenses("Apache-2.0")

//Optional version descriptor
version.apply {
name = projectVersion
vcsTag = "v$projectVersion"
//Optional configuration for GPG signing
gpg.apply {
Expand All @@ -339,7 +352,6 @@ tasks {
afterEvaluate {
val publishToMavenLocal by existing
val bintrayUpload by existing
publishToMavenLocal { dependsOn(dokka) }
install.configure { dependsOn(publishToMavenLocal) }
bintrayUpload { dependsOn(check, install) }
}
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Expand Up @@ -10,7 +10,6 @@ object Versions {
val jacksonMinor = "2.9"
val jackson = "$jacksonMinor.8"
val bintrayPlugin = "1.8.4"
val bintrayRelease = "0.9"
val taskTree = "1.3.1"
val jmh = "1.21"
val jmhPlugin = "0.4.8"
Expand Down
8 changes: 2 additions & 6 deletions src/main/kotlin/com/uchuhimo/konf/BaseConfig.kt
Expand Up @@ -415,9 +415,7 @@ open class BaseConfig(
is RequiredItem -> ValueState.Unset
is LazyItem -> ValueState.Lazy(item.thunk)
}
sources.firstOrNull { path in it }?.let { source ->
loadItem(item, path, source)
}
sources.firstOrNull { loadItem(item, path, it) }
} else {
throw RepeatedItemException(name)
}
Expand Down Expand Up @@ -449,9 +447,7 @@ open class BaseConfig(
is RequiredItem -> ValueState.Unset
is LazyItem -> ValueState.Lazy(item.thunk)
}
sources.firstOrNull { path in it }?.let { source ->
loadItem(item, path, source)
}
sources.firstOrNull { loadItem(item, path, it) }
} else {
throw RepeatedItemException(name)
}
Expand Down
35 changes: 18 additions & 17 deletions src/main/kotlin/com/uchuhimo/konf/source/Source.kt
Expand Up @@ -724,15 +724,25 @@ internal fun Any?.toCompatibleValue(mapper: ObjectMapper): Any {
}
}

internal fun Config.loadItem(item: Item<*>, path: Path, source: Source) {
internal fun Config.loadItem(item: Item<*>, path: Path, source: Source): Boolean {
try {
val itemSource = source[path]
if (item.nullable &&
(itemSource.isNull() ||
(itemSource.isText() && itemSource.toText() == "null"))) {
rawSet(item, null)
val uniformPath = if (source.isEnabled(Feature.LOAD_KEYS_CASE_INSENSITIVELY)) {
path.map { it.toLowerCase() }
} else {
rawSet(item, itemSource.toValue(item.type, mapper))
path
}
val itemSource = source.getOrNull(uniformPath)
if (itemSource != null) {
if (item.nullable &&
(itemSource.isNull() ||
(itemSource.isText() && itemSource.toText() == "null"))) {
rawSet(item, null)
} else {
rawSet(item, itemSource.toValue(item.type, mapper))
}
return true
} else {
return false
}
} catch (cause: SourceException) {
throw LoadException(path, cause)
Expand All @@ -743,16 +753,7 @@ internal fun load(config: Config, source: Source): Config {
return config.apply {
lock {
for (item in this) {
val path = pathOf(item).let { path ->
if (source.isEnabled(Feature.LOAD_KEYS_CASE_INSENSITIVELY)) {
path.map { it.toLowerCase() }
} else {
path
}
}
if (path in source) {
loadItem(item, path, source)
}
loadItem(item, pathOf(item), source)
}
if (source.isEnabled(Feature.FAIL_ON_UNKNOWN_PATH) ||
config.isEnabled(Feature.FAIL_ON_UNKNOWN_PATH)) {
Expand Down
21 changes: 21 additions & 0 deletions src/test/kotlin/com/uchuhimo/konf/source/SourceSpec.kt
Expand Up @@ -26,7 +26,9 @@ import com.uchuhimo.konf.ConfigSpec
import com.uchuhimo.konf.Feature
import com.uchuhimo.konf.NetworkBuffer
import com.uchuhimo.konf.Prefix
import com.uchuhimo.konf.UnsetValueException
import com.uchuhimo.konf.name
import com.uchuhimo.konf.required
import com.uchuhimo.konf.source.base.ValueSource
import com.uchuhimo.konf.source.base.asKVSource
import com.uchuhimo.konf.source.base.asSource
Expand All @@ -35,6 +37,7 @@ import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import org.junit.jupiter.api.assertThrows
import java.math.BigDecimal
import java.math.BigInteger
import java.time.Duration
Expand Down Expand Up @@ -411,6 +414,24 @@ object SourceSpec : Spek({
equalTo(Feature.FAIL_ON_UNKNOWN_PATH.enabledByDefault))
}
}
on("enable LOAD_KEYS_CASE_INSENSITIVELY feature") {
val source = mapOf("somekey" to "value").asSource().enabled(Feature.LOAD_KEYS_CASE_INSENSITIVELY)
val config = Config().withSource(source)
it("should load keys case-insensitively") {
val someKey by config.required<String>()
assertThat(someKey, equalTo("value"))
}
}
on("disable LOAD_KEYS_CASE_INSENSITIVELY feature") {
val source = mapOf("somekey" to "value").asSource().disabled(Feature.LOAD_KEYS_CASE_INSENSITIVELY)
val config = Config().withSource(source)
it("should load keys case-sensitively") {
val someKey by config.required<String>()
assertThrows<UnsetValueException> { someKey }
val somekey by config.required<String>()
assertThat(somekey, equalTo("value"))
}
}
}
group("default implementations") {
val source = DumbSource()
Expand Down
Expand Up @@ -40,6 +40,11 @@ object EnvProviderSpec : SubjectSpek<EnvProvider>({
assertThat(config[SourceSpec.Test.type], equalTo("env"))
assertTrue { config[SourceSpec.camelCase] }
}
it("should return a case-insensitive source") {
val config = Config().withSource(source).apply { addSpec(SourceSpec) }
assertThat(config[SourceSpec.Test.type], equalTo("env"))
assertTrue { config[SourceSpec.camelCase] }
}
}
}
})
Expand Down

0 comments on commit e7473b5

Please sign in to comment.