Skip to content

Commit

Permalink
Releasing KTX 1.9.8-b5. #159
Browse files Browse the repository at this point in the history
  • Loading branch information
czyzby committed Sep 20, 2018
2 parents 14c86ab + b7f27c3 commit 76ae5c4
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Project contributors listed chronologically.
* Started the [graphics module](../graphics).
* [@nukesz](https://github.com/nukesz)
* Refactored legacy tests of the [collections module](../collections).
* [@DavidPartouche](https://github.com/DavidPartouche)
* Added KTX project template to the alternative [gdx-setup](https://github.com/czyzby/gdx-setup) application.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#### 1.9.8-b5

- **[UPDATE]** Updated to Kotlin 1.2.70.
- **[UPDATE]** Updated to Kotlin Coroutines 0.25.0.
- **[UPDATE]** Updated to Gradle 4.10.2.
- **[FIX]** (`ktx-ashley`) Component classes without a default no-arg constructors could not have been initiated
by the Ashley engine. This is still the case, but now an exception with a meaningful message is thrown.

#### 1.9.8-b4

- **[UPDATE]** Updated to Kotlin 1.2.51.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Travis CI](https://travis-ci.org/libktx/ktx.svg?branch=master)](https://travis-ci.org/libktx/ktx)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.libktx/ktx-async.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.libktx%22)
[![Kotlin](https://img.shields.io/badge/kotlin-1.2.51-orange.svg)](http://kotlinlang.org/)
[![Kotlin](https://img.shields.io/badge/kotlin-1.2.70-orange.svg)](http://kotlinlang.org/)
[![LibGDX](https://img.shields.io/badge/libgdx-1.9.8-red.svg)](https://libgdx.badlogicgames.com/)

[![KTX](.github/ktx-logo.png "KTX")](http://libktx.github.io)
Expand Down
14 changes: 9 additions & 5 deletions ashley/src/main/kotlin/ktx/ashley/engines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class EngineEntity(
*/
inline fun <reified T : Component> Engine.create(configure: T.() -> Unit = {}): T {
return try {
createComponent(T::class.java)
} catch (e: Exception) {
throw CreateComponentException(T::class, e)
}?.apply(configure)?:throw CreateComponentException(T::class)
createComponent(T::class.java) ?: throw NullPointerException("The component of ${T::class.java} type is null.")
} catch (exception: Throwable) {
throw CreateComponentException(T::class, exception)
}.apply(configure)
}

/**
Expand All @@ -74,4 +74,8 @@ inline fun Engine.entity(configure: EngineEntity.() -> Unit = {}): Entity {
return entity
}

class CreateComponentException(type: KClass<*>, cause: Throwable? = null): RuntimeException("Could not instantiate component ${type::java.name} - the component must have a visible no-arg constructor", cause)
/**
* Thrown when unable to create a component of given type.
*/
class CreateComponentException(type: KClass<*>, cause: Throwable? = null): RuntimeException(
"Could not create component ${type.javaObjectType} - is a visible no-arg constructor available?", cause)
27 changes: 23 additions & 4 deletions ashley/src/test/kotlin/ktx/ashley/EnginesSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,42 @@ object EnginesSpec : Spek({
assertThat(component.y).isEqualTo(0f)
}
}
describe("creating a component that has no no-arg constructor") {
describe("creating a component without a no-arg constructor") {
@Suppress("UNUSED_PARAMETER")
class NoNoArgConstructorComponent(body: String): Component
class MissingNoArgConstructorComponent(body: String): Component

it("should throw an exception if the non-pooled engine was unable to create the component") {
val nonPooledEngine = Engine()
assertThatExceptionOfType(CreateComponentException::class.java).isThrownBy {
nonPooledEngine.create<NoNoArgConstructorComponent>()
nonPooledEngine.create<MissingNoArgConstructorComponent>()
}
}

it("should throw an exception if the pooled engine was unable to create the component") {
assertThatExceptionOfType(CreateComponentException::class.java).isThrownBy {
engine.create<NoNoArgConstructorComponent>()
engine.create<MissingNoArgConstructorComponent>()
}
}
}
describe("creating a corrupted component that throws an exception") {
class CorruptedComponent : Component {
init {
throw IllegalStateException()
}
}
it("should throw an exception if the non-pooled engine was unable to create the corrupted component") {
val nonPooledEngine = Engine()
assertThatExceptionOfType(CreateComponentException::class.java).isThrownBy {
nonPooledEngine.create<CorruptedComponent>()
}.withRootCauseInstanceOf(IllegalStateException::class.java)
}

it("should throw an exception if the pooled engine was unable to create the corrupted component") {
assertThatExceptionOfType(CreateComponentException::class.java).isThrownBy {
engine.create<CorruptedComponent>()
}.withRootCauseInstanceOf(IllegalStateException::class.java)
}
}
describe("creating a component with configuration") {
val component = engine.create<Transform> {
x = 1f
Expand Down
2 changes: 1 addition & 1 deletion async/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Kotlin](https://img.shields.io/badge/kotlin--coroutines-0.24.0-orange.svg)](http://kotlinlang.org/)
[![Kotlin](https://img.shields.io/badge/kotlin--coroutines-0.26.1-orange.svg)](http://kotlinlang.org/)

# KTX: coroutines support and threading utilities

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
libGroup=io.github.libktx
gdxVersion=1.9.8
kotlinVersion=1.2.51
kotlinCoroutinesVersion=0.24.0
kotlinVersion=1.2.70
kotlinCoroutinesVersion=0.26.1

ashleyVersion=1.7.3
visUiVersion=1.4.0
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.8-b4
1.9.8-b5

0 comments on commit 76ae5c4

Please sign in to comment.