diff --git a/.gitignore b/.gitignore index c27b62494c..0f3ff9d2aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build .gradle +.kotlin classes *.iml *.ipr diff --git a/build.gradle.kts b/build.gradle.kts index 81c827c43a..563d0de110 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent import pl.allegro.tech.build.axion.release.domain.PredefinedVersionCreator +import pl.allegro.tech.hermes.findIntProperty +import pl.allegro.tech.hermes.findLongProperty import java.time.Duration plugins { @@ -25,8 +27,8 @@ java { } nexusPublishing { - connectTimeout = Duration.ofMinutes(getLongProperty("publishingTimeoutInMin", 10)) - clientTimeout = Duration.ofMinutes(getLongProperty("publishingTimeoutInMin", 10)) + connectTimeout = Duration.ofMinutes(project.findLongProperty("publishingTimeoutInMin", 10)) + clientTimeout = Duration.ofMinutes(project.findLongProperty("publishingTimeoutInMin", 10)) repositories { sonatype { @@ -36,8 +38,8 @@ nexusPublishing { } } transitionCheckOptions { - maxRetries = getIntProperty("attemptsToCloseStagingRepository", 30) - delayBetween = Duration.ofSeconds(getLongProperty("delayInSecBetweenCloseStagingRepositoryAttempts", 45)) + maxRetries = project.findIntProperty("attemptsToCloseStagingRepository", 30) + delayBetween = Duration.ofSeconds(project.findLongProperty("delayInSecBetweenCloseStagingRepositoryAttempts", 45)) } } @@ -190,18 +192,16 @@ configure(subprojects.filter { it != project(":integration-tests") }) { } subprojects { - val versions = rootProject.extra["versions"] as Map<*, *> - configurations.all { exclude(group = "org.slf4j", module = "slf4j-log4j12") exclude(group = "log4j", module = "log4j") resolutionStrategy { force("org.jboss.logging:jboss-logging:3.2.1.Final") - force("com.google.guava:guava:${versions["guava"] as String}") - force("com.fasterxml.jackson.core:jackson-databind:${versions["jackson"] as String}") - force("com.fasterxml.jackson.core:jackson-annotations:${versions["jackson"] as String}") - force("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${versions["jackson"] as String}") + force("com.google.guava:guava:${rootProject.libs.versions.guava.get()}") + force("com.fasterxml.jackson.core:jackson-databind:${rootProject.libs.versions.jackson.get()}") + force("com.fasterxml.jackson.core:jackson-annotations:${rootProject.libs.versions.jackson.get()}") + force("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${rootProject.libs.versions.jackson.get()}") } } @@ -226,11 +226,3 @@ subprojects { } } } - -fun getIntProperty(name: String, defaultValue: Int): Int { - return (project.findProperty(name) as? String)?.toIntOrNull() ?: defaultValue -} - -fun getLongProperty(name: String, defaultValue: Long): Long { - return (project.findProperty(name) as? String)?.toLongOrNull() ?: defaultValue -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..876c922b22 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} diff --git a/buildSrc/src/main/kotlin/pl/allegro/tech/hermes/properties.kt b/buildSrc/src/main/kotlin/pl/allegro/tech/hermes/properties.kt new file mode 100644 index 0000000000..e550324562 --- /dev/null +++ b/buildSrc/src/main/kotlin/pl/allegro/tech/hermes/properties.kt @@ -0,0 +1,18 @@ +package pl.allegro.tech.hermes + +import org.gradle.api.Project + +fun Project.findBooleanProperty(property: String, defaultValue: Boolean): Boolean = + (findProperty(property) as? String)?.toBooleanStrictOrNull() ?: defaultValue + +fun Project.findIntProperty(property: String, defaultValue: Int): Int = + (findProperty(property) as? String)?.toIntOrNull() ?: defaultValue + +fun Project.findListProperty(property: String, defaultValue: List): List = + (findProperty(property) as? String)?.split(' ') ?: defaultValue + +fun Project.findLongProperty(name: String, defaultValue: Long): Long = + (findProperty(name) as? String)?.toLongOrNull() ?: defaultValue + +fun Project.findStringProperty(property: String, defaultValue: String): String = + (findProperty(property) as? String) ?: defaultValue diff --git a/hermes-benchmark/build.gradle.kts b/hermes-benchmark/build.gradle.kts index 60c6932365..1ebc5c02eb 100644 --- a/hermes-benchmark/build.gradle.kts +++ b/hermes-benchmark/build.gradle.kts @@ -1,3 +1,8 @@ +import pl.allegro.tech.hermes.findBooleanProperty +import pl.allegro.tech.hermes.findIntProperty +import pl.allegro.tech.hermes.findListProperty +import pl.allegro.tech.hermes.findStringProperty + plugins { alias(libs.plugins.jmh) } @@ -14,14 +19,14 @@ jmh { jmhVersion = "1.36" zip64 = true verbosity = "NORMAL" - iterations = intProperty("jmh.iterations", 4) - timeOnIteration = stringProperty("jmh.timeOnIteration", "80s") - fork = intProperty("jmh.fork", 1) - warmupIterations = intProperty("jmh.warmupIterations", 4) - warmup = stringProperty("jmh.timeOnWarmupIteration", "80s") - jvmArgs = listProperty("jmh.jvmArgs", listOf("-Xmx1g", "-Xms1g", "-XX:+UseG1GC") + chronicleMapJvmArgs) - failOnError = booleanProperty("jmh.failOnError", true) - threads = intProperty("jmh.threads", 4) + iterations = project.findIntProperty("jmh.iterations", 4) + timeOnIteration = project.findStringProperty("jmh.timeOnIteration", "80s") + fork = project.findIntProperty("jmh.fork", 1) + warmupIterations = project.findIntProperty("jmh.warmupIterations", 4) + warmup = project.findStringProperty("jmh.timeOnWarmupIteration", "80s") + jvmArgs = project.findListProperty("jmh.jvmArgs", listOf("-Xmx1g", "-Xms1g", "-XX:+UseG1GC") + chronicleMapJvmArgs) + failOnError = project.findBooleanProperty("jmh.failOnError", true) + threads = project.findIntProperty("jmh.threads", 4) synchronizeIterations = false forceGC = false duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE @@ -51,15 +56,3 @@ tasks.named("processJmhResources") { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } } - -fun stringProperty(property: String, defaultValue: String): String = - (project.findProperty(property) as? String) ?: defaultValue - -fun listProperty(property: String, defaultValue: List): List = - (project.findProperty(property) as? String)?.split(' ') ?: defaultValue - -fun intProperty(property: String, defaultValue: Int): Int = - (project.findProperty(property) as? String)?.toIntOrNull() ?: defaultValue - -fun booleanProperty(property: String, defaultValue: Boolean): Boolean = - (project.findProperty(property) as? String)?.toBooleanStrictOrNull() ?: defaultValue diff --git a/hermes-tracker/build.gradle.kts b/hermes-tracker/build.gradle.kts index ad041d4089..5862167ef1 100644 --- a/hermes-tracker/build.gradle.kts +++ b/hermes-tracker/build.gradle.kts @@ -4,7 +4,7 @@ dependencies { implementation(project(":hermes-api")) implementation(project(":hermes-metrics")) testImplementation(project(path = ":hermes-test-helper")) - testRuntimeOnly(group = "org.junit.vintage", name = "junit-vintage-engine", version = versions["junit_jupiter"] as String) + testRuntimeOnly(libs.junit.vintage.engine) } val testArtifacts: Configuration by configurations.creating