Skip to content

Commit

Permalink
fix: EXPOSED-117 Set jvmToolchain to 8 for all modules (#1855)
Browse files Browse the repository at this point in the history
* fix: EXPOSED-117 Set jvmToolchain to 8 for all modules
  • Loading branch information
e5l authored Sep 15, 2023
1 parent fa73510 commit e1f7ed3
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 2 deletions.
4 changes: 4 additions & 0 deletions exposed-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(kotlin("stdlib"))
api(kotlin("reflect"))
Expand Down
4 changes: 4 additions & 0 deletions exposed-crypt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api("org.springframework.security", "spring-security-crypto", "5.7.3")
Expand Down
4 changes: 4 additions & 0 deletions exposed-dao/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
}
4 changes: 4 additions & 0 deletions exposed-java-time/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
testImplementation(project(":exposed-dao"))
Expand Down
4 changes: 4 additions & 0 deletions exposed-jdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
}
4 changes: 4 additions & 0 deletions exposed-jodatime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api("joda-time", "joda-time", "2.10.13")
Expand Down
4 changes: 4 additions & 0 deletions exposed-json/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api("org.jetbrains.kotlinx", "kotlinx-serialization-json", Versions.kotlinxSerialization)
Expand Down
4 changes: 4 additions & 0 deletions exposed-kotlin-datetime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api("org.jetbrains.kotlinx", "kotlinx-datetime-jvm", "0.4.0")
Expand Down
4 changes: 4 additions & 0 deletions exposed-money/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api(project(":exposed-dao"))
Expand Down
4 changes: 4 additions & 0 deletions exposed-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
api(project(":exposed-dao"))
Expand Down
6 changes: 5 additions & 1 deletion exposed-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ plugins {
kotlin("jvm") apply true
}

kotlin {
jvmToolchain(8)
}

repositories {
mavenCentral()
}
Expand All @@ -28,7 +32,7 @@ dependencies {
implementation("org.apache.logging.log4j", "log4j-api", Versions.log4j2)
implementation("org.apache.logging.log4j", "log4j-core", Versions.log4j2)

implementation("com.zaxxer", "HikariCP", "5.0.1")
implementation("com.zaxxer", "HikariCP", "4.0.3")
testCompileOnly("org.postgresql", "postgresql", Versions.postgre)
testCompileOnly("com.impossibl.pgjdbc-ng", "pgjdbc-ng", Versions.postgreNG)
compileOnly("com.h2database", "h2", Versions.h2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class StatisticsFunctionTests : DatabaseTestsBase() {
private object SampleTestTable : Table("sample_table") {
val number = integer("number").nullable()
}

private val data: List<Int?> = listOf(4, null, 5, null, 6)
private val scale = 4

Expand All @@ -63,7 +64,38 @@ class StatisticsFunctionTests : DatabaseTestsBase() {
}

private fun calculateStandardDeviation(isPopulation: Boolean): BigDecimal {
return calculateVariance(isPopulation).sqrt(MathContext(scale, RoundingMode.HALF_EVEN))
return calculateVariance(isPopulation).simpleSqrt()
}

fun BigDecimal.simpleSqrt(): BigDecimal {
if (this < BigDecimal.ZERO) throw ArithmeticException("Square root of negative number")
if (this == BigDecimal.ZERO) return BigDecimal.ZERO

val TWO = BigDecimal(2)
val EPSILON = BigDecimal(0.1).pow(scale)

var low = BigDecimal.ZERO
var high = max(BigDecimal.ONE)
var result = (low + high).divide(TWO)

while (true) {
val square = result.multiply(result)
val diff = square.subtract(this).abs()
if (diff < EPSILON) {
break
}

if (result.multiply(result) < this) {
low = result
} else {
high = result
}
result = (low + high).divide(TWO)
}

result = result.round(MathContext(scale, RoundingMode.HALF_EVEN))
result = result.setScale(scale)
return result
}

private fun calculateVariance(isPopulation: Boolean): BigDecimal {
Expand Down
4 changes: 4 additions & 0 deletions spring-transaction/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
}

dependencies {
api(project(":exposed-core"))
implementation(project(":exposed-jdbc"))
Expand Down

0 comments on commit e1f7ed3

Please sign in to comment.