|
| 1 | +plugins { |
| 2 | + id 'java' |
| 3 | + id 'maven-publish' |
| 4 | + id 'idea' |
| 5 | + id 'eclipse' |
| 6 | + |
| 7 | + id 'com.diffplug.spotless' version '6.21.0' |
| 8 | +} |
| 9 | + |
| 10 | + |
| 11 | +allprojects { |
| 12 | + apply plugin: 'com.diffplug.spotless' |
| 13 | + |
| 14 | + repositories { |
| 15 | + mavenCentral() |
| 16 | + } |
| 17 | + |
| 18 | + javadoc { |
| 19 | + options.tags = [ |
| 20 | + "http.response.details:a:Http Response Details" |
| 21 | + ] |
| 22 | + } |
| 23 | + |
| 24 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 25 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 26 | + |
| 27 | + tasks.withType(JavaCompile) { |
| 28 | + options.encoding = 'UTF-8' |
| 29 | + } |
| 30 | + |
| 31 | + spotless { |
| 32 | + groovyGradle { |
| 33 | + greclipse() |
| 34 | + |
| 35 | + trimTrailingWhitespace() |
| 36 | + indentWithTabs() |
| 37 | + endWithNewline() |
| 38 | + } |
| 39 | + format 'misc', { |
| 40 | + target '.gitattributes', '.gitignore' |
| 41 | + |
| 42 | + trimTrailingWhitespace() |
| 43 | + indentWithTabs() |
| 44 | + endWithNewline() |
| 45 | + } |
| 46 | + java { |
| 47 | + googleJavaFormat().aosp() |
| 48 | + |
| 49 | + removeUnusedImports() |
| 50 | + importOrder() |
| 51 | + formatAnnotations() |
| 52 | + trimTrailingWhitespace() |
| 53 | + indentWithTabs() |
| 54 | + endWithNewline() |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +subprojects { |
| 60 | + apply plugin: 'java' |
| 61 | + apply plugin: 'maven-publish' |
| 62 | + apply plugin: 'idea' |
| 63 | + apply plugin: 'eclipse' |
| 64 | + |
| 65 | + group = 'cloud.stackit' |
| 66 | + version = 'SNAPSHOT' |
| 67 | + |
| 68 | + afterEvaluate { project -> |
| 69 | + // only apply to service sub-projects and core |
| 70 | + if (project.path.startsWith(':services:') || project.name == "core" ) { |
| 71 | + |
| 72 | + // override the version of each service with the ones obtained from the VERSION files |
| 73 | + def versionFile = project.file("VERSION") |
| 74 | + if (versionFile.exists()) { |
| 75 | + try { |
| 76 | + version = versionFile.text.trim() |
| 77 | + } catch (IOException e) { |
| 78 | + logger.error("Could not read VERSION file for project '${project.name}': ${e.message}") |
| 79 | + } |
| 80 | + } else { |
| 81 | + logger.warn("VERSION file not found in project '${project.name}'. Skipping version setting.") |
| 82 | + } |
| 83 | + |
| 84 | + |
| 85 | + publishing { |
| 86 | + publications { |
| 87 | + maven(MavenPublication) { |
| 88 | + artifactId = "stackit-sdk-${project.name}" |
| 89 | + from components.java |
| 90 | + |
| 91 | + pom { |
| 92 | + name.set(project.name) |
| 93 | + description.set("STACKIT Java SDK for the ${project.name} service") |
| 94 | + url.set("https://github.com/stackitcloud/stackit-sdk-java/tree/main/services/${rootProject.name}") |
| 95 | + licenses { |
| 96 | + license { |
| 97 | + name.set("Apache License, Version 2.0") |
| 98 | + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
| 99 | + } |
| 100 | + } |
| 101 | + developers { |
| 102 | + developer { |
| 103 | + id.set("stackitcloud") // TODO: not clear which value must be placed here, check this when setting up publishment to Maven Central |
| 104 | + name.set("STACKIT Developer Tools") |
| 105 | + |
| 106 | + } |
| 107 | + } |
| 108 | + scm { |
| 109 | + connection.set("scm:git:git://github.com/stackitcloud/${rootProject.name}.git") |
| 110 | + developerConnection.set("scm:git:ssh://github.com/stackitcloud/${rootProject.name}.git") |
| 111 | + url.set("https://github.com/stackitcloud/${rootProject.name}") |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + repositories { |
| 117 | + mavenLocal() |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + tasks.withType(Test) { |
| 124 | + // Enable JUnit 5 (Gradle 4.6+). |
| 125 | + useJUnitPlatform() |
| 126 | + |
| 127 | + // Always run tests, even when nothing changed. |
| 128 | + dependsOn 'cleanTest' |
| 129 | + |
| 130 | + // Show test results. |
| 131 | + testLogging { |
| 132 | + events "passed", "skipped", "failed" |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + dependencies { |
| 137 | + if (project.path != ':core') { |
| 138 | + // prevent circular dependency |
| 139 | + implementation project(':core') |
| 140 | + } |
| 141 | + } |
| 142 | +} |
0 commit comments