Skip to content

Commit eb87c56

Browse files
committed
Add integration tests
1 parent d2c3d8b commit eb87c56

File tree

71 files changed

+10223
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+10223
-95
lines changed

buildSrc/src/main/kotlin/net/kautler/Properties.kt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ sealed class Property<out T> constructor(
105105
project: Project,
106106
propertyName: String
107107
): Property<String?> = OptionalStringProperty(propertyName, project)
108+
109+
fun double(
110+
default: () -> Double = { 0.0 },
111+
propertyName: String? = null,
112+
project: Project? = null
113+
) = PropertyDelegateProvider(
114+
default,
115+
propertyName,
116+
project,
117+
::DoubleProperty
118+
)
119+
120+
fun double(
121+
default: Double,
122+
propertyName: String? = null,
123+
project: Project? = null
124+
) = double({ default }, propertyName, project)
125+
126+
fun double(
127+
project: Project,
128+
propertyName: String,
129+
default: () -> Double = { 0.0 }
130+
): Property<Double> = DoubleProperty(default, propertyName, project)
131+
132+
fun double(
133+
project: Project,
134+
propertyName: String,
135+
default: Double
136+
) = double(project, propertyName) { default }
108137
}
109138
}
110139

@@ -156,10 +185,26 @@ private class BooleanProperty(
156185
findProperty(project, propertyName)?.toBoolean()
157186
}
158187

188+
private class DoubleProperty(
189+
default: () -> Double = { 0.0 },
190+
propertyName: String,
191+
project: Project
192+
) : Property<Double>(default, propertyName, project) {
193+
override fun doGetValue(project: Project, propertyName: String) =
194+
findProperty(project, propertyName)?.let { it.toDoubleOrNull() ?: error("'$it' is not a valid value for double property '$propertyName'") }
195+
}
196+
159197
private fun findProperty(project: Project, propertyName: String): String? {
160198
var result = project.findProperty("${project.rootProject.name}.$propertyName") as String?
161199
if (result.isNullOrBlank()) {
162200
result = project.findProperty(propertyName) as String?
163201
}
164202
return if (result.isNullOrBlank()) null else result
165203
}
204+
205+
fun String?.verifyPropertyIsSet(propertyName: String, rootProjectName: String) {
206+
if (isNullOrBlank()) {
207+
error("Please set the project property '$propertyName' or '$rootProjectName.$propertyName'. " +
208+
"If both are set, the latter will be effective.")
209+
}
210+
}

buildSrc/src/main/kotlin/net/kautler/java.gradle.kts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ plugins {
2424
`java-library`
2525
}
2626

27+
val messageFrameworkVersions: Map<String, List<String>> by project
28+
2729
java {
2830
sourceCompatibility = VERSION_1_8
2931
val main by sourceSets
30-
registerFeature("javacordSupport") {
31-
usingSourceSet(main)
32-
}
33-
registerFeature("jdaSupport") {
34-
usingSourceSet(main)
32+
messageFrameworkVersions.keys.forEach {
33+
registerFeature("${it}Support") {
34+
usingSourceSet(main)
35+
}
3536
}
3637
}
3738

@@ -47,9 +48,9 @@ dependencies {
4748

4849
implementation("org.apache.logging.log4j:log4j-api:${versions["log4j"]}")
4950

50-
"javacordSupportImplementation"("org.javacord:javacord-api:${versions["javacord"]}")
51+
"javacordSupportImplementation"("org.javacord:javacord-api:${messageFrameworkVersions.safeGet("javacord").first()}")
5152

52-
"jdaSupportImplementation"("net.dv8tion:JDA:${versions["jda"]}") {
53+
"jdaSupportImplementation"("net.dv8tion:JDA:${messageFrameworkVersions.safeGet("jda").first()}") {
5354
exclude("club.minnced", "opus-java")
5455
exclude("com.google.code.findbugs", "jsr305")
5556
}

buildSrc/src/main/kotlin/net/kautler/javadoc.gradle.kts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package net.kautler
1818

1919
import org.gradle.api.JavaVersion.VERSION_1_8
20-
import javax.naming.ConfigurationException
2120
import kotlin.text.Charsets.UTF_8
2221

2322
plugins {
@@ -37,9 +36,8 @@ tasks.withType<Javadoc>().configureEach {
3736
if (allowJava8Javadoc?.toBoolean() == true) {
3837
logger.warn("JavaDoc ($javadocTask) is built with Java 8, no search box will be available!")
3938
} else {
40-
throw ConfigurationException(
41-
"JavaDoc ($javadocTask) should be built with Java 9 at least " +
42-
"(set Gradle project property allowJava8Javadoc=true to allow building with Java 8)")
39+
error("JavaDoc ($javadocTask) should be built with Java 9 at least " +
40+
"(set Gradle project property allowJava8Javadoc=true to allow building with Java 8)")
4341
}
4442
}
4543
}
@@ -50,14 +48,15 @@ tasks.withType<Javadoc>().configureEach {
5048
encoding = UTF_8.name()
5149
links!!.apply {
5250
val versions: Map<String, String> by project
51+
val messageFrameworkVersions: Map<String, List<String>> by project
5352
if (java.targetCompatibility != VERSION_1_8) {
54-
throw ConfigurationException("JavaDoc URL for JRE needs to be adapted to new target compatibility ${java.targetCompatibility}")
53+
error("JavaDoc URL for JRE needs to be adapted to new target compatibility ${java.targetCompatibility}")
5554
}
5655
add("https://docs.oracle.com/javase/8/docs/api/")
5756
add("https://static.javadoc.io/javax.enterprise/cdi-api/${versions["cdi"]}/")
5857
add("https://static.javadoc.io/javax.inject/javax.inject/${versions["javax.inject"]}/")
59-
add("https://static.javadoc.io/org.javacord/javacord-api/${versions["javacord"]}/")
60-
add("https://static.javadoc.io/net.dv8tion/JDA/${versions["jda"]}/")
58+
add("https://static.javadoc.io/org.javacord/javacord-api/${messageFrameworkVersions.safeGet("javacord").first()}/")
59+
add("https://static.javadoc.io/net.dv8tion/JDA/${messageFrameworkVersions.safeGet("jda").first()}/")
6160
}
6261
isUse = true
6362
isVersion = true

buildSrc/src/main/kotlin/net/kautler/publishing.gradle.kts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import wooga.gradle.github.publish.PublishMethod.update
2828
import wooga.gradle.github.publish.tasks.GithubPublish
2929
import java.awt.GraphicsEnvironment.isHeadless
3030
import java.util.concurrent.CompletableFuture
31-
import javax.naming.ConfigurationException
3231
import javax.swing.JButton
3332
import javax.swing.JFrame
3433
import javax.swing.JOptionPane.DEFAULT_OPTION
@@ -74,18 +73,8 @@ extra["github.token"] = optionalString(project, "github.token").getValue()
7473

7574
tasks.withType<PublishToMavenRepository>().configureEach {
7675
doFirst("verify username and password are set") {
77-
if (sonatypeUsername.isNullOrBlank()) {
78-
throw ConfigurationException(
79-
"Please set the Sonatype username with project property 'sonatype.username' " +
80-
"or '${rootProject.name}.sonatype.username'. " +
81-
"If both are set, the latter will be effective.")
82-
}
83-
if (sonatypePassword.isNullOrBlank()) {
84-
throw ConfigurationException(
85-
"Please set the Sonatype password with project property 'sonatype.password' " +
86-
"or '${rootProject.name}.sonatype.password'. " +
87-
"If both are set, the latter will be effective.")
88-
}
76+
sonatypeUsername.verifyPropertyIsSet("sonatypeUsername", rootProject.name)
77+
sonatypePassword.verifyPropertyIsSet("sonatypePassword", rootProject.name)
8978
}
9079
}
9180

@@ -190,25 +179,10 @@ tasks.withType<BaseStagingTask>().configureEach {
190179

191180
doFirst("verify username, password and staging profile id are set") {
192181
if (this !is GetStagingProfileTask) {
193-
if (sonatypeStagingProfileId.isNullOrBlank()) {
194-
throw ConfigurationException(
195-
"Please set the Sonatype staging profile id with project property 'sonatype.stagingProfileId' " +
196-
"or '${rootProject.name}.sonatype.stagingProfileId'. " +
197-
"If both are set, the latter will be effective.")
198-
}
199-
}
200-
if (sonatypeUsername.isNullOrBlank()) {
201-
throw ConfigurationException(
202-
"Please set the Sonatype username with project property 'sonatype.username' " +
203-
"or '${rootProject.name}.sonatype.username'. " +
204-
"If both are set, the latter will be effective.")
205-
}
206-
if (sonatypePassword.isNullOrBlank()) {
207-
throw ConfigurationException(
208-
"Please set the Sonatype password with project property 'sonatype.password' " +
209-
"or '${rootProject.name}.sonatype.password'. " +
210-
"If both are set, the latter will be effective.")
182+
sonatypeStagingProfileId.verifyPropertyIsSet("sonatypeStagingProfileId", rootProject.name)
211183
}
184+
sonatypeUsername.verifyPropertyIsSet("sonatypeUsername", rootProject.name)
185+
sonatypePassword.verifyPropertyIsSet("sonatypePassword", rootProject.name)
212186
}
213187
}
214188

@@ -354,6 +328,7 @@ val finishMilestone by tasks.registering {
354328
}
355329

356330
tasks.beforeReleaseBuild {
331+
dependsOn(tasks.named("integTest"))
357332
dependsOn(tasks.named("pitest"))
358333
}
359334

buildSrc/src/main/kotlin/net/kautler/readme.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ tasks.check {
4949

5050
tasks.register("updateReadme") {
5151
val versions: Map<String, String> by project
52+
val messageFrameworkVersions: Map<String, List<String>> by project
53+
54+
val testedJavacordVersions = "* `${messageFrameworkVersions.safeGet("javacord").joinToString("`\n* `")}`"
55+
val testedJdaVersions = "* `${messageFrameworkVersions.safeGet("jda").joinToString("`\n* `")}`"
5256

5357
dependsOn(verifyReadme)
5458
inputs.property("version", version)
5559
inputs.property("cdiVersion", versions["cdi"])
5660
inputs.property("antlrVersion", versions["antlr"])
61+
inputs.property("testedJavacordVersions", testedJavacordVersions)
62+
inputs.property("testedJdaVersions", testedJdaVersions)
5763
inputs.file(readmeTemplateFilePath).withPropertyName("readmeTemplate")
5864
outputs.file(readmeFilePath).withPropertyName("readme")
5965
outputs.file(readmeChecksumFilePath).withPropertyName("readmeChecksum")
@@ -68,7 +74,9 @@ tasks.register("updateReadme") {
6874
expand(
6975
"version" to version,
7076
"cdiVersion" to versions["cdi"],
71-
"antlrVersion" to versions["antlr"]
77+
"antlrVersion" to versions["antlr"],
78+
"testedJavacordVersions" to testedJavacordVersions,
79+
"testedJdaVersions" to testedJdaVersions
7280
)
7381
}
7482
file(readmeChecksumFilePath).writeText(calculateReadmeChecksum())

0 commit comments

Comments
 (0)