diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index 6bf697b..12ef297 100644 --- a/.github/workflows/build-and-publish.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -9,6 +9,8 @@ jobs: build-and-publish: name: Java Gradle uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.43.0 + with: + java-version: 17 secrets: sonar-token: ${{ secrets.SONARCLOUD_TOKEN }} sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 84bacfd..845bc07 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,6 +18,7 @@ jobs: name: Java Gradle uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.43.0 with: + java-version: 17 release-type: "${{ inputs.release-type }}" secrets: diff --git a/build.gradle.kts b/build.gradle.kts index c604f6a..eff4b5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,8 @@ plugins { id("com.bakdata.release") version "1.3.0" // eat your own dog food - apply the plugins to this plugin project id("com.bakdata.sonar") version "1.1.17" - id("com.bakdata.sonatype") version "1.3.1" - id("org.gradle.kotlin.kotlin-dsl") version "2.1.6" apply false + id("com.bakdata.sonatype") version "1.3.2" + id("org.gradle.kotlin.kotlin-dsl") version "4.1.2" apply false id("com.gradle.plugin-publish") version "1.2.1" apply false } @@ -41,8 +41,9 @@ subprojects { apply(plugin = "java") configure { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } } apply(plugin = "java-gradle-plugin") @@ -55,31 +56,24 @@ subprojects { // description is only ready after evaluation afterEvaluate { configure { + website.set("https://github.com/bakdata/gradle-plugins") + vcsUrl.set("https://github.com/bakdata/gradle-plugins") plugins { create("${project.name.capitalize()}Plugin") { id = "com.bakdata.${project.name}" implementationClass = "com.bakdata.gradle.${project.name.capitalize()}Plugin" description = project.description displayName = "Bakdata $name plugin" + tags = listOf("bakdata", name) } } } - - extensions.findByType(com.gradle.publish.PluginBundleExtension::class)?.apply { - // actual block of plugin portal config, need to be done on each subproject as the plugin does not support multi-module projects yet... - website = "https://github.com/bakdata/gradle-plugins" - vcsUrl = "https://github.com/bakdata/gradle-plugins" - tags = listOf("bakdata", name) - } } dependencies { - "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.3.0") - "testImplementation"("org.junit.jupiter:junit-jupiter-api:5.3.0") - "testImplementation"("org.assertj", "assertj-core", "3.11.1") - "testImplementation"("org.junit-pioneer", "junit-pioneer", "0.3.0") + val junitVersion = "5.10.2" + "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:$junitVersion") + "testImplementation"("org.junit.jupiter:junit-jupiter-api:$junitVersion") + "testImplementation"("org.assertj", "assertj-core", "3.25.3") } } - -val sonarqube by tasks -sonarqube.enabled = false //FIXME requires Java 17 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0f7639..fce403e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/release/build.gradle.kts b/release/build.gradle.kts index 5021820..c23c342 100644 --- a/release/build.gradle.kts +++ b/release/build.gradle.kts @@ -8,5 +8,5 @@ description = "Configures Gradle Release plugin for usage in CI" dependencies { implementation("net.researchgate", "gradle-release", "3.0.2") - implementation("gradle.plugin.org.hildan.gradle", "gradle-github-changelog", "1.12.1") + implementation("org.hildan.gradle", "gradle-github-changelog", "2.2.0") } diff --git a/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt b/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt index 9fba2f9..9f25b4c 100644 --- a/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt +++ b/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt @@ -33,6 +33,7 @@ import net.researchgate.release.ReleaseExtension import net.researchgate.release.ReleasePlugin import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatCode +import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.Condition import org.assertj.core.api.SoftAssertions import org.gradle.api.Project @@ -43,6 +44,7 @@ import org.gradle.testfixtures.ProjectBuilder import org.hildan.github.changelog.plugin.GitHubChangelogExtension import org.hildan.github.changelog.plugin.GitHubChangelogPlugin import org.junit.jupiter.api.Test +import java.util.function.Consumer internal class ReleasePluginTest { @@ -64,16 +66,16 @@ internal class ReleasePluginTest { .haveExactly(1, Condition({ it is ReleasePlugin }, "Has release plugin")) .haveExactly(1, Condition({ it is GitHubChangelogPlugin }, "Has changelog plugin")) softly.assertThat(project.extensions.findByType()?.git) - .satisfies { + .satisfies(Consumer { // TODO remove explicit Consumer once https://github.com/assertj/assertj/issues/2357 is resolved softly.assertThat(it?.pushToRemote?.get()).isEqualTo("origin") softly.assertThat(it?.requireBranch?.get()).isEqualTo("main") - } + }) softly.assertThat(project.extensions.findByType()) - .satisfies { + .satisfies(Consumer { // TODO remove explicit Consumer once https://github.com/assertj/assertj/issues/2357 is resolved softly.assertThat(it?.githubRepository).isNull() softly.assertThat(it?.futureVersionTag).isNull() softly.assertThat(it?.sinceTag).isNull() - } + }) } } @@ -178,7 +180,7 @@ internal class ReleasePluginTest { val parent = ProjectBuilder.builder().withName("parent").build() val child1 = ProjectBuilder.builder().withName("child1").withParent(parent).build() - assertThatCode { child1.pluginManager.apply("com.bakdata.release") } - .satisfies { assertThat(it.cause).hasMessageContaining("top-level project") } + assertThatThrownBy { child1.pluginManager.apply("com.bakdata.release") } + .satisfies(Consumer { assertThat(it.cause).hasMessageContaining("top-level project") }) // TODO remove explicit Consumer once https://github.com/assertj/assertj/issues/2357 is resolved } } diff --git a/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginIT.kt b/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginIT.kt index 943187c..4626e50 100644 --- a/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginIT.kt +++ b/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginIT.kt @@ -30,14 +30,11 @@ import org.gradle.testkit.runner.BuildTask import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -import org.junitpioneer.jupiter.TempDirectory -import org.junitpioneer.jupiter.TempDirectory.TempDir +import org.junit.jupiter.api.io.TempDir import java.io.File import java.nio.file.Files import java.nio.file.Path -@ExtendWith(TempDirectory::class) internal class SonarPluginIT { private fun taskWithPathAndOutcome(path: String, outcome: TaskOutcome): Condition = Condition({ it.path == path && it.outcome == outcome }, "Task $path=$outcome") diff --git a/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginTest.kt b/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginTest.kt index 20f046e..e49f77f 100644 --- a/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginTest.kt +++ b/sonar/src/test/kotlin/com/bakdata/gradle/SonarPluginTest.kt @@ -26,14 +26,16 @@ package com.bakdata.gradle import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatCode +import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.Condition import org.assertj.core.api.SoftAssertions +import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.internal.project.DefaultProject import org.gradle.testfixtures.ProjectBuilder import org.junit.jupiter.api.Test +import java.util.function.Consumer internal class SonarPluginTest { fun taskWithName(name: String): Condition = Condition({ it.name == name }, "Task with name $name") @@ -53,7 +55,7 @@ internal class SonarPluginTest { }.doesNotThrowAnyException() SoftAssertions.assertSoftly { softly -> - softly.assertThat(project.tasks) + softly.assertThat(project.collectTasks()) .haveExactly(1, taskWithName("jacocoTestReport")) .haveExactly(1, taskWithName("sonarqube")) } @@ -70,7 +72,7 @@ internal class SonarPluginTest { }.doesNotThrowAnyException() SoftAssertions.assertSoftly { softly -> - softly.assertThat(project.tasks) + softly.assertThat(project.collectTasks()) .haveExactly(1, taskWithName("jacocoTestReport")) .haveExactly(1, taskWithName("sonarqube")) } @@ -98,7 +100,7 @@ internal class SonarPluginTest { } SoftAssertions.assertSoftly { softly -> - softly.assertThat(parent.tasks) + softly.assertThat(parent.collectTasks()) .haveExactly(0, taskWithName("jacocoTestReport")) .haveExactly(1, taskWithName("sonarqube")) } @@ -126,7 +128,7 @@ internal class SonarPluginTest { } SoftAssertions.assertSoftly { softly -> - softly.assertThat(parent.tasks) + softly.assertThat(parent.collectTasks()) .haveExactly(0, taskWithName("jacocoTestReport")) .haveExactly(1, taskWithName("sonarqube")) } @@ -137,7 +139,14 @@ internal class SonarPluginTest { val parent = ProjectBuilder.builder().withName("parent").build() val child1 = ProjectBuilder.builder().withName("child1").withParent(parent).build() - assertThatCode { child1.pluginManager.apply("com.bakdata.sonar") } - .satisfies { assertThat(it.cause).hasMessageContaining("top-level project") } + assertThatThrownBy { child1.pluginManager.apply("com.bakdata.sonar") } + .satisfies(Consumer { assertThat(it.cause).hasMessageContaining("top-level project") }) // TODO remove explicit Consumer once https://github.com/assertj/assertj/issues/2357 is resolved + } + + private fun Project.collectTasks(): List = try { + tasks.toList() + } catch (e: GradleException) { + // FIXME bug since Gradle 7.3 https://github.com/gradle/gradle/issues/20301 + if (e.message.equals("Could not create task ':init'.")) tasks.toList() else throw e } } diff --git a/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginIT.kt b/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginIT.kt index f6b0ba0..ae22a02 100644 --- a/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginIT.kt +++ b/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginIT.kt @@ -36,8 +36,7 @@ import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith -import org.junitpioneer.jupiter.TempDirectory -import org.junitpioneer.jupiter.TempDirectory.TempDir +import org.junit.jupiter.api.io.TempDir import ru.lanwen.wiremock.ext.WiremockResolver import ru.lanwen.wiremock.ext.WiremockResolver.Wiremock import java.io.File @@ -45,7 +44,7 @@ import java.nio.file.Files import java.nio.file.Path -@ExtendWith(TempDirectory::class, WiremockResolver::class) +@ExtendWith(WiremockResolver::class) internal class SonatypePluginIT { private fun taskWithPathAndOutcome(path: String, outcome: TaskOutcome): Condition = Condition({ it.path == path && it.outcome == outcome }, "Task $path=$outcome") diff --git a/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginTest.kt b/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginTest.kt index 8b9ec7f..8c7aae6 100644 --- a/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginTest.kt +++ b/sonatype/src/test/kotlin/com/bakdata/gradle/SonatypePluginTest.kt @@ -26,7 +26,9 @@ package com.bakdata.gradle import org.assertj.core.api.Assertions import org.assertj.core.api.Condition import org.assertj.core.api.SoftAssertions.assertSoftly +import org.gradle.api.GradleException import org.gradle.api.Project +import org.gradle.api.ProjectConfigurationException import org.gradle.api.Task import org.gradle.api.internal.project.DefaultProject import org.gradle.kotlin.dsl.apply @@ -34,11 +36,20 @@ import org.gradle.testfixtures.ProjectBuilder import org.junit.jupiter.api.Test import java.io.File import java.nio.file.Files +import java.util.function.Consumer internal class SonatypePluginTest { fun Project.evaluate() { - (this as DefaultProject).evaluate() + val defaultProject: DefaultProject = this as DefaultProject + try { + defaultProject.evaluate() + } catch (e: ProjectConfigurationException) { + // FIXME bug since Gradle 7.3 https://github.com/gradle/gradle/issues/20301 + if (e.message.equals("Failed to apply plugin 'org.gradle.build-init'.")) { + defaultProject.evaluate() + } + } } fun taskWithName(name: String): Condition = Condition({ it.name == name }, "Task with name $name") @@ -99,7 +110,7 @@ internal class SonatypePluginTest { } assertSoftly { softly -> - softly.assertThat(parent.tasks) + softly.assertThat(parent.collectTasks()) .haveExactly(0, taskWithName("signSonatypePublication")) .haveExactly(0, taskWithName("publish")) .haveExactly(0, taskWithName("publishToNexus")) @@ -112,8 +123,17 @@ internal class SonatypePluginTest { val parent = ProjectBuilder.builder().withName("parent").build() val child1 = ProjectBuilder.builder().withName("child1").withParent(parent).build() - Assertions.assertThatCode { child1.apply(plugin = "com.bakdata.sonatype") } - .satisfies { Assertions.assertThat(it.cause).hasMessageContaining("top-level project") } + Assertions.assertThatThrownBy { child1.apply(plugin = "com.bakdata.sonatype") } + .satisfies(Consumer { + Assertions.assertThat(it.cause).hasMessageContaining("top-level project") + }) // TODO remove explicit Consumer once https://github.com/assertj/assertj/issues/2357 is resolved + } + + private fun Project.collectTasks(): List = try { + tasks.toList() + } catch (e: GradleException) { + // FIXME bug since Gradle 7.3 https://github.com/gradle/gradle/issues/20301 + if (e.message.equals("Could not create task ':init'.")) tasks.toList() else throw e } }