Skip to content

Commit

Permalink
refactor(buid): apply the edc build plugin and the version catalog (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood authored Nov 21, 2022
1 parent 67b4ea7 commit 3dc1802
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 447 deletions.
202 changes: 35 additions & 167 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,188 +13,71 @@
*/

plugins {
java
`java-library`
signing
`maven-publish`
checkstyle
id("org.gradle.crypto.checksum") version "1.4.0"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
jacoco
}

repositories {
mavenCentral()
}

val projectGroup: String by project
val swagger: String by project
val rsApi: String by project

// these values are required for the project POM (for publishing)
val edcDeveloperId: String by project
val edcDeveloperName: String by project
val edcDeveloperEmail: String by project
val edcScmConnection: String by project
val edcWebsiteUrl: String by project
val edcScmUrl: String by project
val edcGroup: String by project
val annotationProcessorVersion: String by project
val metaModelVersion: String by project
val javaVersion: String by project

val defaultVersion: String by project

// makes the project version overridable using the "-PidentityHubVersion..." flag. Useful for CI builds
val projectVersion: String = (project.findProperty("identityHubVersion") ?: defaultVersion) as String

var deployUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"

if (projectVersion.contains("SNAPSHOT")) {
deployUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
val actualVersion: String = (project.findProperty("identityHubVersion") ?: defaultVersion) as String

subprojects {
afterEvaluate {
publishing {
publications.forEach { i ->
val mp = (i as MavenPublication)
mp.pom {
name.set(project.name)
description.set("edc :: ${project.name}")
url.set(edcWebsiteUrl)

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(edcDeveloperId)
name.set(edcDeveloperName)
email.set(edcDeveloperEmail)
}
}
scm {
connection.set(edcScmConnection)
url.set(edcScmUrl)
}
}
}
}
}
buildscript {
dependencies {
val edcGradlePluginsVersion: String by project
classpath("org.eclipse.edc.edc-build:org.eclipse.edc.edc-build.gradle.plugin:${edcGradlePluginsVersion}")
}
}

allprojects {
apply(plugin = "maven-publish")
apply(plugin = "checkstyle")

apply(plugin = "java")

version = projectVersion
group = projectGroup

checkstyle {
toolVersion = "9.0"
configFile = rootProject.file("resources/checkstyle-config.xml")
configDirectory.set(rootProject.file("resources"))
maxErrors = 0 // does not tolerate errors
}
allprojects {
apply(plugin = "${edcGroup}.edc-build")

repositories {
mavenCentral()
mavenLocal()
maven {
url = uri("https://maven.iais.fraunhofer.de/artifactory/eis-ids-public/")
}
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
// configure which version of the annotation processor to use. defaults to the same version as the plugin
configure<org.eclipse.edc.plugins.autodoc.AutodocExtension> {
processorVersion.set(annotationProcessorVersion)
outputDirectory.set(project.buildDir)
}

pluginManager.withPlugin("io.swagger.core.v3.swagger-gradle-plugin") {
configure<org.eclipse.edc.plugins.edcbuild.extensions.BuildExtension> {
versions {
// override default dependency versions here
projectVersion.set(actualVersion)
metaModel.set(metaModelVersion)

dependencies {
// this is used to scan the classpath and generate an openapi yaml file
implementation("io.swagger.core.v3:swagger-jaxrs2-jakarta:${swagger}")
implementation("jakarta.ws.rs:jakarta.ws.rs-api:${rsApi}")
}
// this is used to scan the classpath and generate an openapi yaml file
tasks.withType<io.swagger.v3.plugins.gradle.tasks.ResolveTask> {
outputFileName = project.name
outputFormat = io.swagger.v3.plugins.gradle.tasks.ResolveTask.Format.YAML
prettyPrint = true
classpath = java.sourceSets["main"].runtimeClasspath
buildClasspath = classpath
resourcePackages = setOf("org.eclipse.edc")
outputDir = file("${rootProject.projectDir.path}/resources/openapi/yaml")
pom {
projectName.set(project.name)
description.set("edc :: ${project.name}")
projectUrl.set(edcWebsiteUrl)
scmConnection.set(edcScmConnection)
scmUrl.set(edcScmUrl)
}
configurations {
all {
exclude(group = "com.fasterxml.jackson.jaxrs", module = "jackson-jaxrs-json-provider")
}
swagger {
title.set("Identity HUB REST API")
description = "Identity HUB REST APIs - merged by OpenApiMerger"
outputFilename.set(project.name)
outputDirectory.set(file("${rootProject.projectDir.path}/resources/openapi/yaml"))
}
javaLanguageVersion.set(JavaLanguageVersion.of(javaVersion))
}

pluginManager.withPlugin("java-library") {
if (!project.hasProperty("skip.signing")) {

apply(plugin = "signing")
publishing {
repositories {
maven {
name = "OSSRH"
setUrl(deployUrl)
credentials {
username = System.getenv("OSSRH_USER") ?: return@credentials
password = System.getenv("OSSRH_PASSWORD") ?: return@credentials
}
}
}

signing {
useGpgCmd()
sign(publishing.publications)
}
}
}
configure<CheckstyleExtension> {
configFile = rootProject.file("resources/checkstyle-config.xml")
configDirectory.set(rootProject.file("resources"))
}

tasks.test {
// Target all type of test e.g. -DrunAllTests="true"
val runAllTests: String = System.getProperty("runAllTests", "false")
if (runAllTests == "true") {
useJUnitPlatform()
} else {
// Target specific set of tests by specifying junit tags on command-line e.g. -DincludeTags="tag-name1,tag-name2"
val includeTagProperty = System.getProperty("includeTags")
val includeTags: Array<String> = includeTagProperty?.split(",")?.toTypedArray() ?: emptyArray()

if (includeTags.isNotEmpty()) {
useJUnitPlatform {
includeTags(*includeTags)
}
} else {
useJUnitPlatform {
excludeTags("IntegrationTest")
}
}
}
testLogging {
showStandardStreams = true
}
}

if (System.getenv("JACOCO") == "true") {
apply(plugin = "jacoco")
tasks.test {
finalizedBy(tasks.jacocoTestReport)
}
tasks.jacocoTestReport {
reports {
// Generate XML report for codecov.io
xml.required.set(true)
}
}
}

// EdcRuntimeExtension uses this to determine the runtime classpath of the module to run.
tasks.register("printClasspath") {
Expand All @@ -204,19 +87,4 @@ allprojects {
}

}
buildscript {
dependencies {
classpath("io.swagger.core.v3:swagger-gradle-plugin:2.1.13")
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("OSSRH_USER") ?: return@sonatype)
password.set(System.getenv("OSSRH_PASSWORD") ?: return@sonatype)
}
}
}
29 changes: 7 additions & 22 deletions client-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,16 @@ plugins {
`maven-publish`
}

val edcGroup: String by project
val edcVersion: String by project
val jacksonVersion: String by project
val jupiterVersion: String by project
val assertj: String by project
val mockitoVersion: String by project
val okHttpVersion: String by project
val nimbusVersion: String by project
val bouncycastleVersion: String by project
val picoCliVersion: String by project

dependencies {
api("info.picocli:picocli:${picoCliVersion}")
annotationProcessor("info.picocli:picocli-codegen:${picoCliVersion}")
api(libs.picocli.core)
annotationProcessor(libs.picocli.codegen)

implementation(project(":core:identity-hub-client"))
implementation("${edcGroup}:identity-did-spi:${edcVersion}")
implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
implementation("com.squareup.okhttp3:okhttp:${okHttpVersion}")
implementation("com.nimbusds:nimbus-jose-jwt:${nimbusVersion}")
implementation("org.bouncycastle:bcpkix-jdk15on:${bouncycastleVersion}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")
implementation(edc.spi.identity.did)
implementation(libs.jackson.databind)
implementation(libs.okhttp)
implementation(libs.nimbus.jwt)
implementation(libs.bouncycastle.bcpkix.jdk15on)
}
repositories {
mavenCentral()
Expand Down
27 changes: 7 additions & 20 deletions core/identity-hub-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,20 @@ plugins {
`maven-publish`
}

val jacksonVersion: String by project
val okHttpVersion: String by project
val edcVersion: String by project
val edcGroup: String by project
val jupiterVersion: String by project
val assertj: String by project
val nimbusVersion: String by project
val mockitoVersion: String by project

dependencies {
api(project(":spi:identity-hub-spi"))
api(project(":spi:identity-hub-client-spi"))
api("${edcGroup}:core-spi:${edcVersion}")
implementation("${edcGroup}:http:${edcVersion}")
implementation("com.squareup.okhttp3:okhttp:${okHttpVersion}")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("${edcGroup}:core-spi:${edcVersion}")
implementation("com.nimbusds:nimbus-jose-jwt:${nimbusVersion}")
api(edc.spi.core)
implementation(edc.ext.http)
implementation(libs.okhttp)
implementation(libs.jackson.databind)
implementation(edc.spi.core)
implementation(libs.nimbus.jwt)

testImplementation(project(":core:identity-hub"))
testImplementation(project(":extensions:identity-hub-api"))
testImplementation(testFixtures(project(":spi:identity-hub-spi")))
testImplementation("${edcGroup}:junit:${edcVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation(edc.core.junit)
}

publishing {
Expand Down
17 changes: 3 additions & 14 deletions core/identity-hub/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,14 @@ plugins {
`java-library`
`maven-publish`
}
val assertj: String by project
val edcVersion: String by project
val edcGroup: String by project
val jupiterVersion: String by project
val nimbusVersion: String by project
val mockitoVersion: String by project

dependencies {
api(project(":spi:identity-hub-spi"))
implementation(project(":spi:identity-hub-store-spi"))
implementation("com.nimbusds:nimbus-jose-jwt:${nimbusVersion}")
implementation("${edcGroup}:transaction-spi:${edcVersion}")
implementation(libs.nimbus.jwt)
implementation(edc.spi.transaction)

testImplementation("${edcGroup}:junit:${edcVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${jupiterVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation(edc.core.junit)
testImplementation(testFixtures(project(":spi:identity-hub-spi")))
testImplementation(testFixtures(project(":spi:identity-hub-store-spi")))
}
Expand Down
25 changes: 6 additions & 19 deletions extensions/identity-hub-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,19 @@ plugins {
`maven-publish`
}

val edcVersion: String by project
val edcGroup: String by project
val jupiterVersion: String by project
val restAssured: String by project
val mockitoVersion: String by project
val assertj: String by project
val nimbusVersion: String by project

dependencies {
api(project(":spi:identity-hub-spi"))
implementation(project(":spi:identity-hub-store-spi"))
implementation(project(":core:identity-hub"))
implementation("${edcGroup}:http:${edcVersion}")
implementation("${edcGroup}:transaction-spi:${edcVersion}")

implementation(edc.ext.http)
implementation(edc.spi.transaction)

testImplementation("${edcGroup}:junit:${edcVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${jupiterVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")

testImplementation("com.nimbusds:nimbus-jose-jwt:${nimbusVersion}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation("io.rest-assured:rest-assured:${restAssured}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation(edc.core.junit)
testImplementation(libs.nimbus.jwt)
testImplementation(libs.restAssured)
testImplementation(project(":spi:identity-hub-spi"))

testImplementation(testFixtures(project(":spi:identity-hub-spi")))
testImplementation(testFixtures(project(":spi:identity-hub-store-spi")))
}
Expand Down
Loading

0 comments on commit 3dc1802

Please sign in to comment.