diff --git a/.github/actions/bump-version/action.yml b/.github/actions/bump-version/action.yml index be9090f..a9edc88 100644 --- a/.github/actions/bump-version/action.yml +++ b/.github/actions/bump-version/action.yml @@ -26,7 +26,7 @@ inputs: runs: using: "composite" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: read version from gradle.properties shell: bash run: | diff --git a/.github/workflows/release-tck-common.yml b/.github/workflows/release-tck-build.yml similarity index 79% rename from .github/workflows/release-tck-common.yml rename to .github/workflows/release-tck-build.yml index 44ad47d..a999649 100644 --- a/.github/workflows/release-tck-common.yml +++ b/.github/workflows/release-tck-build.yml @@ -49,21 +49,12 @@ jobs: sha: context.sha }) - # create merge commit main -> releases encoding the version in the commit message - - name: Merge main -> releases - uses: everlytic/branch-merge@1.1.5 - with: - github_token: ${{ github.token }} - source_ref: ${{ github.ref }} - target_branch: 'releases' - commit_message_template: 'Merge commit for release of version v${{ env.TCK_VERSION }}' - outputs: - cvf-version: ${{ env.TCK_VERSION }} + tck-version: ${{ env.TCK_VERSION }} Github-Release: # cannot use the workflow-level env yet as it does not yet exist, must take output from previous job - if: ${{ !endsWith( needs.Prepare-Release.outputs.cvf-version, '-SNAPSHOT') }} + if: ${{ !endsWith( needs.Prepare-Release.outputs.tck-version, '-SNAPSHOT') }} needs: - Prepare-Release runs-on: ubuntu-latest @@ -84,7 +75,7 @@ jobs: Bump-Version: name: 'Update release version' # cannot use the workflow-level env yet as it does not yet exist, must take output from previous job - if: ${{ !endsWith( needs.Prepare-Release.outputs.cvf-version, '-SNAPSHOT') }} + if: ${{ !endsWith( needs.Prepare-Release.outputs.tck-version, '-SNAPSHOT') }} needs: [ Prepare-Release, Github-Release ] runs-on: ubuntu-latest steps: @@ -92,4 +83,4 @@ jobs: - uses: ./.github/actions/bump-version with: target_branch: "main" - base_version: ${{ needs.Prepare-Release.outputs.cvf-version }} \ No newline at end of file + base_version: ${{ needs.Prepare-Release.outputs.tck-version }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 0f466f9..73d0752 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension + /* * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * @@ -15,123 +17,40 @@ plugins { checkstyle `maven-publish` -} - -subprojects { - -// afterEvaluate { -// -// publishing { -// publications.forEach { i -> -// val mp = (i as MavenPublication) -// mp.pom { -// name.set(project.name) -// description.set("Compliance Verification Toolkit") -// url.set("https://projects.eclipse.org/projects/technology.dataspacetck") -// -// licenses { -// license { -// name.set("The Apache License, Version 2.0") -// url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") -// } -// developers { -// developer { -// id.set("JimMarino") -// name.set("Jim Marino") -// email.set("jmarino@metaformsystems.com") -// } -// developer { -// id.set("PaulLatzelsperger") -// name.set("Paul Latzelsperger") -// email.set("paul.latzelsperger@beardyinc.com") -// } -// developer { -// id.set("EnricoRisa") -// name.set("Enrico Risa") -// email.set("enrico.risa@gmail.com") -// } -// } -// scm { -// connection.set("scm:git:git@github.com:eclipse-dataspacetck/cvf.git") -// url.set("https://github.com/eclipse-dataspacetck/cvf.git") -// } -// } -// } -// } -// } -// -// } - + signing + `java-library` + `version-catalog` + alias(libs.plugins.gradle.publish) apply false } // needed for running the dash tool tasks.register("allDependencies", DependencyReportTask::class) -// disallow any errors -checkstyle { - maxErrors = 0 -} -allprojects{ - apply(plugin = "checkstyle") - apply(plugin = "maven-publish") - apply(plugin = "java-library") -} +allprojects { + apply(plugin = "org.eclipse.dataspacetck.tck-build") -subprojects { - publishing { - publications { - if(project.subprojects.isEmpty()) { - create(project.name) { - artifactId = project.name - from(components["java"]) - } - } - } + // for all gradle plugins: + pluginManager.withPlugin("java-gradle-plugin") { + apply(plugin = "com.gradle.plugin-publish") } - afterEvaluate { - publishing { - publications.forEach { i -> - val mp = (i as MavenPublication) - mp.pom { - name.set(project.name) - description.set("Compliance Verification Toolkit") - url.set("https://projects.eclipse.org/projects/technology.dataspacetck") - - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - developers { - developer { - id.set("JimMarino") - name.set("Jim Marino") - email.set("jmarino@metaformsystems.com") - } - developer { - id.set("PaulLatzelsperger") - name.set("Paul Latzelsperger") - email.set("paul.latzelsperger@beardyinc.com") - } - developer { - id.set("EnricoRisa") - name.set("Enrico Risa") - email.set("enrico.risa@gmail.com") - } - } - scm { - connection.set("scm:git:git@github.com:eclipse-dataspacetck/cvf.git") - url.set("https://github.com/eclipse-dataspacetck/cvf.git") - } - } - } - } + // configure POM + configure { + pom { + scmConnection = "https://github.com/eclipse-dataspacetck/dsp-tck.git" + scmUrl = "scm:git:git@github.com:eclipse-dataspacetck/dsp-tck.git" + groupId = "org.eclipse.dataspacetck.build" + projectName = project.name + description = "DSP Technology Compatibility Kit" + projectUrl = "https://projects.eclipse.org/projects/technology.dataspacetck" } } -} - - + // FIXME - workaround for https://github.com/gradle/gradle/issues/26091 + val signingTasks = tasks.withType() + tasks.withType().configureEach { + mustRunAfter(signingTasks) + } +} \ No newline at end of file diff --git a/build/libs/tck-build-0.0.1-SNAPSHOT.jar b/build/libs/tck-build-0.0.1-SNAPSHOT.jar deleted file mode 100644 index 0e1027a..0000000 Binary files a/build/libs/tck-build-0.0.1-SNAPSHOT.jar and /dev/null differ diff --git a/build/tmp/jar/MANIFEST.MF b/build/tmp/jar/MANIFEST.MF deleted file mode 100644 index 58630c0..0000000 --- a/build/tmp/jar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..6f0a1c3 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-gradle-plugin` +} + +group = "org.eclipse.dataspacetck.build" + +repositories { + mavenCentral() + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + } + gradlePluginPortal() + mavenLocal() +} + +dependencies { + + implementation(libs.plugin.nexus.publish) + implementation(libs.plugin.docker.remoteapi) + implementation(libs.plugin.nexus.publish) + + api(libs.tck.common.api) +} + +gradlePlugin { + plugins { + create("tckBuild") { + id = "org.eclipse.dataspacetck.tck-build" + group = "org.eclipse.dataspacetck.build" + implementationClass = "org.eclipse.dataspacetck.gradle.tckbuild.plugins.TckBuildPlugin" + } + } +} + +val generatedSourcesFolder = layout.buildDirectory.asFile.get().resolve("generated").resolve("sources") + +sourceSets { + main { + java { + srcDirs( + generatedSourcesFolder, + "../plugins/tck-build-plugin/src/main" + ) + } + } +} diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties new file mode 100644 index 0000000..15c08f9 --- /dev/null +++ b/buildSrc/gradle.properties @@ -0,0 +1,15 @@ +# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Contributors: +# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation +# +# +group=org.eclipse.dataspacetck.build +version=0.0.1-SNAPSHOT diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..91e8fac --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/gradle.properties b/gradle.properties index 574a662..15c08f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,5 +11,5 @@ # Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation # # -group=org.eclipse.dataspacetck -version=0.0.1 +group=org.eclipse.dataspacetck.build +version=0.0.1-SNAPSHOT diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 15ce66c..cd731ad 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,12 +7,12 @@ jupiter = "5.10.3" tck = "0.0.1-SNAPSHOT" [libraries] -tck-common-api = {module = "org.eclipse.dataspacetck:core-api", version.ref = "tck"} -tck-common-testplan-gen = {module = "org.eclipse.dataspacetck:test-plan-generator", version.ref = "tck"} - +tck-common-api = { module = "org.eclipse.dataspacetck.common:core-api", version.ref = "tck" } +tck-common-testplan-gen = { module = "org.eclipse.dataspacetck.common:test-plan-generator", version.ref = "tck" } junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jupiter" } junit-platform-engine = { module = "org.junit.platform:junit-platform-suite-engine", version.ref = "junit" } - +plugin-docker-remoteapi = { module = "com.bmuschko.docker-remote-api:com.bmuschko.docker-remote-api.gradle.plugin", version = "9.4.0" } +plugin-nexus-publish = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" } [plugins] nexuspublishing = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" } diff --git a/plugins/tck-build-plugin/build.gradle.kts b/plugins/tck-build-plugin/build.gradle.kts index df511eb..bf7d93d 100644 --- a/plugins/tck-build-plugin/build.gradle.kts +++ b/plugins/tck-build-plugin/build.gradle.kts @@ -17,9 +17,14 @@ plugins { alias(libs.plugins.gradle.publish) } +repositories { + gradlePluginPortal() // needed because some plugins are only published to the Plugin Portal +} + dependencies { implementation(gradleApi()) - implementation(libs.tck.common.testplan.gen) + implementation(libs.plugin.docker.remoteapi) + implementation(libs.plugin.nexus.publish) } gradlePlugin { @@ -28,18 +33,12 @@ gradlePlugin { plugins { create("tckBuild") { - id = "org.eclipse.dataspacetck.tck-build" - displayName = "TCK Build" + id = "org.eclipse.dataspacetck.build.tck-build" + group = "org.eclipse.dataspacetck.build" + displayName = "TCK Build Plugin" description = "Gradle Plugin to customize the TCK build" tags = listOf("tags", "dataspace", "dsp", "dcp", "tck", "plugins", "build") - implementationClass = "org.eclipse.dataspacetck.gradle.plugins.tckbuild.TckBuildPlugin" - } - create("tckGen") { - id = "org.eclipse.dataspacetck.tck-generator" - displayName = "TCK Test Plan Generator" - description = "Gradle Plugin to generate a test plan document in Markdown format" - tags = listOf("tags", "dataspace", "dsp", "dcp", "tck", "plugins", "test", "testplan", "markdown") - implementationClass = "org.eclipse.dataspacetck.gradle.plugins.tckgen.TckGeneratorPlugin" + implementationClass = "org.eclipse.dataspacetck.gradle.tckbuild.plugins.TckBuildPlugin" } } } diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/Repositories.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/Repositories.java new file mode 100644 index 0000000..b3fc627 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/Repositories.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle; + +import io.github.gradlenexus.publishplugin.NexusRepository; +import io.github.gradlenexus.publishplugin.NexusRepositoryContainer; +import org.gradle.api.Action; +import org.gradle.api.artifacts.repositories.MavenArtifactRepository; + +import java.net.URI; + +public class Repositories { + + public static final String SNAPSHOT_REPO_URL = "https://oss.sonatype.org/content/repositories/snapshots/"; + public static final String NEXUS_REPO_URL = "https://oss.sonatype.org/service/local/"; + private static final String OSSRH_PASSWORD = "OSSRH_PASSWORD"; + private static final String OSSRH_USER = "OSSRH_USERNAME"; + + public static Action mavenRepo(String repoUrl) { + return repo -> { + repo.setUrl(repoUrl); + }; + } + + public static Action sonatypeRepo() { + return c -> c.sonatype(nexusRepo(NEXUS_REPO_URL, SNAPSHOT_REPO_URL)); + } + + private static Action nexusRepo(String nexusRepoUrl, String snapshotRepoUrl) { + return r -> { + r.getNexusUrl().set(URI.create(nexusRepoUrl)); + r.getSnapshotRepositoryUrl().set(URI.create(snapshotRepoUrl)); + r.getUsername().set(System.getenv(OSSRH_USER)); + r.getPassword().set(System.getenv(OSSRH_PASSWORD)); + }; + } +} \ No newline at end of file diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/DockerConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/DockerConvention.java new file mode 100644 index 0000000..c7abbac --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/DockerConvention.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage; +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.DockerExtension; +import org.gradle.api.Project; +import org.gradle.api.tasks.Copy; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; + +public class DockerConvention { + private final DockerExtension extension; + + public DockerConvention(DockerExtension extension) { + this.extension = extension; + } + + public void apply(Project project) { + var dockerFilePathDefault = Path.of(project.getProjectDir().getAbsolutePath(), DockerExtension.DEFAULT_DOCKERFILE_SUBPATH).toString(); + var dockerfile = extension.getDockerfilePath().convention(dockerFilePathDefault).get(); + + if (Files.exists(Path.of(dockerfile))) { + var copyLegalDocs = createCopyTask(project); + var dockerTask = createDockerizeTask(project, dockerfile, extension); + dockerTask.dependsOn(copyLegalDocs); + dockerTask.dependsOn(project.getTasksByName("shadowJar", true)); + } + } + + + private static DockerBuildImage createDockerizeTask(Project project, String dockerfile, DockerExtension extension) { + return project.getTasks().create("dockerize", DockerBuildImage.class, dbi -> { + + dbi.setGroup("build"); + dbi.setDescription("Task to build a runnable Docker image from a JAR file and a Dockerfile"); + dbi.getDockerFile().set(new File(dockerfile)); + + //set image tags + dbi.getImages().addAll( + project.getName() + ":" + project.getVersion(), + project.getName() + ":latest" + ); + extension.getImageTags().forEach(tag -> dbi.getImages().add(project.getName() + ":" + tag)); + + // set platform + if (extension.getPlatform().isPresent()) { + dbi.getPlatform().set(extension.getPlatform().get()); + } + + // set build args + dbi.getBuildArgs().put("JAR", extension.getJarFilePath().convention("libs/" + project.getName() + ".jar").get()); + dbi.getBuildArgs().put("ADDITIONAL_FILES", extension.getAdditionalFiles()); + dbi.getInputDir().set(project.getProjectDir()); + }); + } + + private static @NotNull Copy createCopyTask(Project project) { + return project.getTasks().create("copyLegalDocs", Copy.class, copy -> { + copy.into(project.getLayout().getBuildDirectory().getAsFile().get() + "/legal") + .from( + project.getRootProject().getProjectDir().getPath() + "/SECURITY.md", + project.getRootProject().getProjectDir().getPath() + "/NOTICE.md", + project.getRootProject().getProjectDir().getPath() + "/DEPENDENCIES", + project.getRootProject().getProjectDir().getPath() + "/LICENSE", + project.getProjectDir().getPath() + "/notice.md" + ); + }); + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JarConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JarConvention.java new file mode 100644 index 0000000..b4d0765 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JarConvention.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Microsoft Corporation + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Microsoft Corporation - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.gradle.api.Project; +import org.gradle.api.file.DuplicatesStrategy; +import org.gradle.jvm.tasks.Jar; + +import java.nio.file.Path; + +/** + * Adds the LICENSE and NOTICE.md file to every JAR + */ +public class JarConvention { + public void apply(Project target) { + var task = target.getTasks().named("jar"); + if (task.isPresent()) { + var jarTask = (Jar) task.get(); + var rootProjectPath = target.getRootProject().getProjectDir().getAbsolutePath(); + var licenseFile = Path.of(rootProjectPath, "LICENSE"); + var noticeFile = Path.of(rootProjectPath, "NOTICE.md"); + var dependenciesFile = Path.of(rootProjectPath, "DEPENDENCIES"); + jarTask.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); + jarTask.metaInf(metaInf -> metaInf.from(licenseFile.toString(), noticeFile.toString(), dependenciesFile.toString())); + } + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JavaConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JavaConvention.java new file mode 100644 index 0000000..95ce4be --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/JavaConvention.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Microsoft Corporation + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Microsoft Corporation - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.jvm.toolchain.JavaLanguageVersion; + +/** + * Enforces the Java version, generates Javadoc jar and Sources jar for publications + */ +public class JavaConvention { + + private static final int DEFAULT_JAVA_VERSION = 17; + + public void apply(Project target) { + var javaPluginExt = target.getExtensions().getByType(JavaPluginExtension.class); + var buildExt = target.getExtensions().getByType(TckBuildExtension.class); + var javaVersion = buildExt.getJavaLanguageVersion() + .getOrElse(JavaLanguageVersion.of(DEFAULT_JAVA_VERSION)); + + // set java version + javaPluginExt.toolchain(tc -> tc.getLanguageVersion().set(javaVersion)); + + // making sure the code does not use any APIs from a more recent version. + // Ref: https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation + target.getTasks().withType(JavaCompile.class, compileTask -> { + var options = compileTask.getOptions(); + options.getRelease().set(javaVersion.asInt()); + options.setFork(true); + options.setIncremental(true); + }); + + + // needed for publishing to maven central + javaPluginExt.withJavadocJar(); + javaPluginExt.withSourcesJar(); + } + +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/NexusPublishingConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/NexusPublishingConvention.java new file mode 100644 index 0000000..a030eaa --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/NexusPublishingConvention.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import io.github.gradlenexus.publishplugin.NexusPublishExtension; +import org.gradle.api.Project; + +import static org.eclipse.dataspacetck.gradle.Repositories.sonatypeRepo; + +public class NexusPublishingConvention { + + public void apply(Project target) { + if (target == target.getRootProject()) { + + + target.getExtensions().configure(NexusPublishExtension.class, nexusPublishExtension -> { + nexusPublishExtension.repositories(sonatypeRepo()); + }); + } + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PomConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PomConvention.java new file mode 100644 index 0000000..471ddd5 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PomConvention.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.PomExtension; +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension; +import org.gradle.api.Project; +import org.gradle.api.publish.PublishingExtension; +import org.gradle.api.publish.maven.MavenPom; +import org.gradle.api.publish.maven.MavenPublication; + +public class PomConvention { + + private static final String PROJECT_URL = "https://projects.eclipse.org/projects/technology.dataspacetck"; + + public void apply(Project project) { + project.afterEvaluate(p -> { + var pomExtension = p.getExtensions().getByType(TckBuildExtension.class).getPom(); + var pubExtension = p.getExtensions().getByType(PublishingExtension.class); + + + pubExtension.getPublications().stream() + .filter(pub -> pub instanceof MavenPublication) + .map(pub -> (MavenPublication) pub) + .forEach(mp -> mp.pom(mavenPom -> setPomInformation(project, pomExtension, mavenPom))); + }); + } + + private void setPomInformation(Project project, PomExtension pomExtension, MavenPom pom) { + // these properties are mandatory! + var projectName = pomExtension.getProjectName().getOrElse(project.getName()); + var description = pomExtension.getDescription().getOrElse("Dataspace TCK :: " + project.getName()); + var projectUrl = pomExtension.getProjectUrl().getOrElse(PROJECT_URL); + pom.getName().set(projectName); + pom.getDescription().set(description); + pom.getUrl().set(projectUrl); + + // we'll provide a sane default for these properties + pom.licenses(l -> l.license(pl -> { + pl.getName().set(pomExtension.getLicenseName().getOrElse("The Apache License, Version 2.0")); + pl.getUrl().set(pomExtension.getLicenseUrl().getOrElse("http://www.apache.org/licenses/LICENSE-2.0.txt")); + })); + + pomExtension.getDeveloper().forEach(developer -> { + pom.developers(l -> l.developer(dev -> { + dev.getName().set(developer.name()); + dev.getId().set(developer.id()); + dev.getEmail().set(developer.email()); + })); + }); + + pom.scm(scm -> { + scm.getUrl().set(pomExtension.getScmUrl()); + scm.getConnection().set(pomExtension.getScmConnection()); + }); + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PublicationConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PublicationConvention.java new file mode 100644 index 0000000..a3c087e --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/PublicationConvention.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension; +import org.gradle.api.Project; +import org.gradle.api.publish.PublishingExtension; +import org.gradle.api.publish.maven.MavenPublication; + +public class PublicationConvention { + /** + * Default setting for publication of a project. + */ + private static final boolean DEFAULT_SHOULD_PUBLISH = true; + + /** + * Checks whether publishing is explicitly set to false for the target project and, if it is + * not, adds a Maven publication to the project, if none exists. This only applies for + * sub-projects that contain a build.gradle.kts file. + * + * @param target The project to which the convention applies + */ + public void apply(Project target) { + // do not publish the root project or modules without a build.gradle.kts + if (target.getRootProject() == target || !target.file("build.gradle.kts").exists()) { + return; + } + + var buildExt = target.getExtensions().getByType(TckBuildExtension.class); + var shouldPublish = buildExt.getPublish().getOrElse(DEFAULT_SHOULD_PUBLISH); + + if (shouldPublish) { + var pe = target.getExtensions().getByType(PublishingExtension.class); + + if (pe.getPublications().findByName(target.getName()) == null) { + pe.publications(publications -> publications.create(target.getName(), MavenPublication.class, + mavenPublication -> { + mavenPublication.from(target.getComponents().getByName("java")); + mavenPublication.setGroupId(buildExt.getPom().getGroupId().get()); + mavenPublication.suppressPomMetadataWarningsFor("testFixturesApiElements"); + mavenPublication.suppressPomMetadataWarningsFor("testFixturesRuntimeElements"); + })); + } + } + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/RootBuildScriptConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/RootBuildScriptConvention.java new file mode 100644 index 0000000..2599e84 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/RootBuildScriptConvention.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Microsoft Corporation + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Microsoft Corporation - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.gradle.api.Project; + +import static org.eclipse.dataspacetck.gradle.Repositories.SNAPSHOT_REPO_URL; +import static org.eclipse.dataspacetck.gradle.Repositories.mavenRepo; + +/** + * Configures the root buildscript, i.e. adds repos + */ +public class RootBuildScriptConvention { + public void apply(Project target) { + if (target == target.getRootProject()) { + // configure buildscript repos + target.getBuildscript().getRepositories().mavenLocal(); + target.getBuildscript().getRepositories().mavenCentral(); + target.getBuildscript().getRepositories().gradlePluginPortal(); + target.getBuildscript().getRepositories().maven(mavenRepo(SNAPSHOT_REPO_URL)); + } + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/SigningConvention.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/SigningConvention.java new file mode 100644 index 0000000..28a5c3c --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/conventions/SigningConvention.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.conventions; + +import org.gradle.api.Project; +import org.gradle.api.publish.PublishingExtension; +import org.gradle.plugins.signing.SigningExtension; +import org.gradle.plugins.signing.SigningPlugin; + +public class SigningConvention { + public void apply(Project project) { + if (project.hasProperty("skip.signing")) { + return; + } + var pubExt = project.getExtensions().getByType(PublishingExtension.class); + var publications = pubExt.getPublications(); + + project.getPlugins().apply(SigningPlugin.class); + + var signExt = project.getExtensions().getByType(SigningExtension.class); + signExt.useGpgCmd(); + signExt.sign(publications); + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckbuild/TckBuildPlugin.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DeveloperContact.java similarity index 57% rename from plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckbuild/TckBuildPlugin.java rename to plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DeveloperContact.java index dde47b2..044737f 100644 --- a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckbuild/TckBuildPlugin.java +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DeveloperContact.java @@ -12,19 +12,12 @@ * */ -package org.eclipse.dataspacetck.gradle.plugins.tckbuild; +package org.eclipse.dataspacetck.gradle.tckbuild.extensions; +import javax.inject.Inject; -import org.gradle.api.Project; -import org.jetbrains.annotations.NotNull; - -/** - * Gradle plugin that customized the build for TCK projects - */ -public class TckBuildPlugin implements org.gradle.api.Plugin { - - - @Override - public void apply(@NotNull Project target) { +public record DeveloperContact(String id, String name, String email) { + @Inject + public DeveloperContact { } } diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DockerExtension.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DockerExtension.java new file mode 100644 index 0000000..350452e --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/DockerExtension.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.extensions; + +import org.gradle.api.provider.Property; + +import java.util.HashSet; +import java.util.Set; + +public abstract class DockerExtension { + public static final String DEFAULT_DOCKERFILE_SUBPATH = "/src/main/docker/Dockerfile"; + + private String additionalFiles = "build/legal/*"; + private final Set imageTags = new HashSet<>(Set.of("latest")); + + public abstract Property getDockerfilePath(); + + public Set getImageTags() { + return imageTags; + } + + public abstract Property getPlatform(); + + public abstract Property getJarFilePath(); + + + public String getAdditionalFiles() { + return additionalFiles; + } + + public void setAdditionalFiles(String additionalFiles) { + this.additionalFiles = additionalFiles; + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/PomExtension.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/PomExtension.java new file mode 100644 index 0000000..5e479b1 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/PomExtension.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.extensions; + +import org.gradle.api.provider.Property; + +import java.util.ArrayList; +import java.util.List; + +public abstract class PomExtension { + private List developerContacts; + + public PomExtension() { + developerContacts = new ArrayList<>(); + developerContacts.add(new DeveloperContact("jimmarino", "Jim Marino", "jmarino@metaformsystems.com")); + developerContacts.add(new DeveloperContact("paullatzelsperger", "Paul Latzelsperger", "paul.latzelsperger@beardyinc.com")); + developerContacts.add(new DeveloperContact("wolf4ood", "Enrico Risa", "enrico.risa@gmail.com")); + } + + public abstract Property getProjectName(); + + public abstract Property getDescription(); + + public abstract Property getProjectUrl(); + + public abstract Property getLicenseName(); + + public abstract Property getLicenseUrl(); + + + public List getDeveloper() { + return developerContacts; + } + + public void setDeveloper(List developer) { + developerContacts = developer; + } + + public abstract Property getScmConnection(); + + public abstract Property getScmUrl(); + + public abstract Property getGroupId(); + +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/TckBuildExtension.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/TckBuildExtension.java new file mode 100644 index 0000000..37a10a1 --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/extensions/TckBuildExtension.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.extensions; + +import org.gradle.api.Action; +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Property; +import org.gradle.jvm.toolchain.JavaLanguageVersion; + +public abstract class TckBuildExtension { + private final PomExtension pom; + + public TckBuildExtension(ObjectFactory objectFactory) { + pom = objectFactory.newInstance(PomExtension.class); + } + + public void pom(Action action) { + action.execute(pom); + } + + + public PomExtension getPom() { + return pom; + } + + public abstract Property getJavaLanguageVersion(); + + public abstract Property getPublish(); +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/plugins/TckBuildPlugin.java b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/plugins/TckBuildPlugin.java new file mode 100644 index 0000000..fa01f9b --- /dev/null +++ b/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tckbuild/plugins/TckBuildPlugin.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.dataspacetck.gradle.tckbuild.plugins; + + +import com.bmuschko.gradle.docker.DockerRemoteApiPlugin; +import io.github.gradlenexus.publishplugin.NexusPublishPlugin; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.DockerConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.JarConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.JavaConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.NexusPublishingConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.PomConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.PublicationConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.RootBuildScriptConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.conventions.SigningConvention; +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.DockerExtension; +import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaLibraryPlugin; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.quality.CheckstylePlugin; +import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; +import org.jetbrains.annotations.NotNull; + +/** + * Gradle plugin that customized the build for TCK projects + */ +public class TckBuildPlugin implements org.gradle.api.Plugin { + + + @Override + public void apply(@NotNull Project target) { + var ext = target.getExtensions().create("dockerExtension", DockerExtension.class); + target.getExtensions().create("tckBuild", TckBuildExtension.class, target.getObjects()); + + target.getPlugins().apply(DockerRemoteApiPlugin.class); + if (target.getRootProject() == target) { + target.getPlugins().apply(NexusPublishPlugin.class); + } + + target.getPlugins().apply(JavaLibraryPlugin.class); + target.getPlugins().apply(CheckstylePlugin.class); + target.getPlugins().apply(MavenPublishPlugin.class); + target.getPlugins().apply(JavaPlugin.class); + + + new NexusPublishingConvention().apply(target); + + target.afterEvaluate(project -> { + new RootBuildScriptConvention().apply(project); + new DockerConvention(ext).apply(project); + new SigningConvention().apply(project); + new PublicationConvention().apply(project); + new PomConvention().apply(project); + new JavaConvention().apply(project); + new JarConvention().apply(project); + }); + + } + +} diff --git a/plugins/tck-generator-plugin/build.gradle.kts b/plugins/tck-generator-plugin/build.gradle.kts new file mode 100644 index 0000000..1e79a21 --- /dev/null +++ b/plugins/tck-generator-plugin/build.gradle.kts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-gradle-plugin` + alias(libs.plugins.gradle.publish) +} + +dependencies { + implementation(gradleApi()) + implementation(libs.tck.common.testplan.gen) +} + +gradlePlugin { + website = "https://projects.eclipse.org/projects/technology.dataspacetck" + vcsUrl = "https://github.com/eclipse-dataspacetck" + + plugins { + create("tckGen") { + id = "org.eclipse.dataspacetck.build.tck-generator" + group = "org.eclipse.dataspacetck.build" + displayName = "TCK Test Plan Generator Plugin" + description = "Gradle Plugin to generate a test plan document in Markdown format" + tags = listOf("tags", "dataspace", "dsp", "dcp", "tck", "plugins", "test", "testplan", "markdown") + implementationClass = "org.eclipse.dataspacetck.gradle.plugins.tckgen.TckGeneratorPlugin" + } + } +} diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorExtension.java b/plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorExtension.java similarity index 100% rename from plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorExtension.java rename to plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorExtension.java diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java b/plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java similarity index 72% rename from plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java rename to plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java index caf6cd5..21ef0df 100644 --- a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java +++ b/plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/plugins/tckgen/TckGeneratorPlugin.java @@ -29,7 +29,7 @@ */ public class TckGeneratorPlugin implements Plugin { - private static final String GENERATOR_GROUP_ARTIFACT = "org.eclipse.dataspacetck:test-plan-generator"; + private static final String GENERATOR_GROUP_ARTIFACT = "org.eclipse.dataspacetck.common:test-plan-generator"; @Override public void apply(@NotNull Project target) { @@ -52,31 +52,11 @@ public void apply(@NotNull Project target) { }); } - private @NotNull String getProcessorVersion(TckGeneratorExtension extension, Project project) { - var processorVersion = extension.getGeneratorVersion(); - - if (processorVersion.isPresent()) { - var version = processorVersion.get(); - project.getLogger().debug("{}: use configured version from AutodocExtension (override) [{}]", project.getName(), version); - return version; - } else { - var version = project.getVersion().toString(); - project.getLogger().info("No explicit configuration value for the annotationProcessor version was found. Project version {} will be used", version); - return version; - } - } /** * callback that is invoked before dependency resolution begins. We need this hook to add the "annotationProcessor" version */ - private class DependencyInjector implements DependencyResolutionListener { - private final Project target; - private final TckGeneratorExtension extension; - - private DependencyInjector(Project target, TckGeneratorExtension extension) { - this.target = target; - this.extension = extension; - } + private record DependencyInjector(Project target, TckGeneratorExtension extension) implements DependencyResolutionListener { @Override public void beforeResolve(@NotNull ResolvableDependencies dependencies) { @@ -91,5 +71,19 @@ public void beforeResolve(@NotNull ResolvableDependencies dependencies) { public void afterResolve(@NotNull ResolvableDependencies dependencies) { //noop } + + private @NotNull String getProcessorVersion(TckGeneratorExtension extension, Project project) { + var processorVersion = extension.getGeneratorVersion(); + + if (processorVersion.isPresent()) { + var version = processorVersion.get(); + project.getLogger().debug("{}: use configured version from AutodocExtension (override) [{}]", project.getName(), version); + return version; + } else { + var version = project.getVersion().toString(); + project.getLogger().info("No explicit configuration value for the annotationProcessor version was found. Project version {} will be used", version); + return version; + } + } } } diff --git a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java b/plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java similarity index 97% rename from plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java rename to plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java index 71274e2..e9df11e 100644 --- a/plugins/tck-build-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java +++ b/plugins/tck-generator-plugin/src/main/java/org/eclipse/dataspacetck/gradle/tasks/GenerateTestPlanTask.java @@ -134,5 +134,6 @@ protected void compile(InputChanges inputs) { ) ); super.compile(inputs); + getLogger().lifecycle("Test plan document generated at {}{}testplan.md", getOutputDir(), File.separator); } } diff --git a/settings.gradle.kts b/settings.gradle.kts index a143d31..6fda948 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -37,4 +37,5 @@ dependencyResolutionManagement { } include(":plugins:tck-build-plugin") +include(":plugins:tck-generator-plugin")