Skip to content

Commit

Permalink
feat: implement build and generator plugins (#6)
Browse files Browse the repository at this point in the history
* split buid and test-gen plugins

* build plugin - dockerize task

* fix copy-legal-doc

* add dependency onto shadowJar

* use conventions

* add more conventions

* add gh workflows, publishing

* set jdk version

* update workflow

* feat: implement TCK build and generator plugins
  • Loading branch information
paullatzelsperger authored Dec 3, 2024
1 parent 8bb309e commit 3ec70dc
Show file tree
Hide file tree
Showing 30 changed files with 880 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bump-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand All @@ -84,12 +75,12 @@ 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:
- uses: actions/checkout@v4
- uses: ./.github/actions/bump-version
with:
target_branch: "main"
base_version: ${{ needs.Prepare-Release.outputs.cvf-version }}
base_version: ${{ needs.Prepare-Release.outputs.tck-version }}
133 changes: 26 additions & 107 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.eclipse.dataspacetck.gradle.tckbuild.extensions.TckBuildExtension

/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
Expand All @@ -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("[email protected]")
// }
// developer {
// id.set("PaulLatzelsperger")
// name.set("Paul Latzelsperger")
// email.set("[email protected]")
// }
// developer {
// id.set("EnricoRisa")
// name.set("Enrico Risa")
// email.set("[email protected]")
// }
// }
// scm {
// connection.set("scm:git:[email protected]: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<MavenPublication>(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("[email protected]")
}
developer {
id.set("PaulLatzelsperger")
name.set("Paul Latzelsperger")
email.set("[email protected]")
}
developer {
id.set("EnricoRisa")
name.set("Enrico Risa")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:[email protected]:eclipse-dataspacetck/cvf.git")
url.set("https://github.com/eclipse-dataspacetck/cvf.git")
}
}
}
}
// configure POM
configure<TckBuildExtension> {
pom {
scmConnection = "https://github.com/eclipse-dataspacetck/dsp-tck.git"
scmUrl = "scm:git:[email protected]: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<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(signingTasks)
}
}
Binary file removed build/libs/tck-build-0.0.1-SNAPSHOT.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions build/tmp/jar/MANIFEST.MF

This file was deleted.

60 changes: 60 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
)
}
}
}
15 changes: 15 additions & 0 deletions buildSrc/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"))
}
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
21 changes: 10 additions & 11 deletions plugins/tck-build-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
}
}
}
Loading

0 comments on commit 3ec70dc

Please sign in to comment.