|
| 1 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 2 | + |
| 3 | +plugins { |
| 4 | + `java-library` |
| 5 | + |
| 6 | + checkstyle |
| 7 | + eclipse |
| 8 | + idea |
| 9 | + |
| 10 | + id("otel.spotless-conventions") |
| 11 | +} |
| 12 | + |
| 13 | +java { |
| 14 | + toolchain { |
| 15 | + languageVersion.set(JavaLanguageVersion.of(17)) |
| 16 | + } |
| 17 | + |
| 18 | + withJavadocJar() |
| 19 | + withSourcesJar() |
| 20 | +} |
| 21 | + |
| 22 | +checkstyle { |
| 23 | + configDirectory.set(file("$rootDir/buildscripts/")) |
| 24 | + toolVersion = "8.12" |
| 25 | + isIgnoreFailures = false |
| 26 | + configProperties["rootDir"] = rootDir |
| 27 | +} |
| 28 | + |
| 29 | +val testJavaVersion = gradle.startParameter.projectProperties.get("testJavaVersion")?.let(JavaVersion::toVersion) |
| 30 | + |
| 31 | +tasks { |
| 32 | + withType<JavaCompile>().configureEach { |
| 33 | + with(options) { |
| 34 | + release.set(8) |
| 35 | + |
| 36 | + //disable deprecation warnings for the protobuf module |
| 37 | + compilerArgs.addAll( |
| 38 | + listOf( |
| 39 | + // Fail build on any warning |
| 40 | + "-Werror" |
| 41 | + ) |
| 42 | + ) |
| 43 | + |
| 44 | + encoding = "UTF-8" |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + withType<Test>().configureEach { |
| 49 | + useJUnitPlatform() |
| 50 | + |
| 51 | + if (testJavaVersion != null) { |
| 52 | + javaLauncher.set( |
| 53 | + javaToolchains.launcherFor { |
| 54 | + languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion)) |
| 55 | + }, |
| 56 | + ) |
| 57 | + } |
| 58 | + |
| 59 | + testLogging { |
| 60 | + exceptionFormat = TestExceptionFormat.FULL |
| 61 | + showExceptions = true |
| 62 | + showCauses = true |
| 63 | + showStackTraces = true |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + withType<Javadoc>().configureEach { |
| 68 | + exclude("io/opentelemetry/**/internal/**") |
| 69 | + |
| 70 | + with(options as StandardJavadocDocletOptions) { |
| 71 | + source = "8" |
| 72 | + encoding = "UTF-8" |
| 73 | + docEncoding = "UTF-8" |
| 74 | + breakIterator(true) |
| 75 | + |
| 76 | + addBooleanOption("html5", true) |
| 77 | + |
| 78 | + links("https://docs.oracle.com/javase/8/docs/api/") |
| 79 | + addBooleanOption("Xdoclint:all,-missing", true) |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + withType<Jar>().configureEach { |
| 84 | + manifest { |
| 85 | + attributes( |
| 86 | + "Automatic-Module-Name" to "io.opentelemetry.semconv", |
| 87 | + "Built-By" to System.getProperty("user.name"), |
| 88 | + "Built-JDK" to System.getProperty("java.version"), |
| 89 | + "Implementation-Title" to project.name, |
| 90 | + "Implementation-Version" to project.version) |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + afterEvaluate { |
| 95 | + withType<Javadoc>().configureEach { |
| 96 | + with(options as StandardJavadocDocletOptions) { |
| 97 | + val title = "${project.description}" |
| 98 | + docTitle = title |
| 99 | + windowTitle = title |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +configurations.configureEach { |
| 106 | + resolutionStrategy { |
| 107 | + failOnVersionConflict() |
| 108 | + } |
| 109 | +} |
0 commit comments