|
| 1 | +/* |
| 2 | + * SonarSource Cloud Native Gradle Modules |
| 3 | + * Copyright (C) 2024-2024 SonarSource SA |
| 4 | + * mailto:info AT sonarsource DOT com |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or |
| 7 | + * modify it under the terms of the GNU Lesser General Public |
| 8 | + * License as published by the Free Software Foundation; either |
| 9 | + * version 3 of the License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | + * Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with this program; if not, write to the Free Software Foundation, |
| 18 | + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | + */ |
| 20 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 21 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED |
| 22 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED |
| 23 | + |
| 24 | +plugins { |
| 25 | + `java-library` |
| 26 | + jacoco |
| 27 | +} |
| 28 | + |
| 29 | +java { |
| 30 | + withSourcesJar() |
| 31 | + withJavadocJar() |
| 32 | + sourceCompatibility = JavaVersion.VERSION_17 |
| 33 | + targetCompatibility = JavaVersion.VERSION_17 |
| 34 | +} |
| 35 | + |
| 36 | +tasks.withType<JavaCompile> { |
| 37 | + options.encoding = "UTF-8" |
| 38 | +} |
| 39 | + |
| 40 | +tasks.withType<Javadoc> { |
| 41 | + options.encoding = "UTF-8" |
| 42 | + options { |
| 43 | + (this as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +tasks.withType<Test> { |
| 48 | + useJUnitPlatform() |
| 49 | + |
| 50 | + testLogging { |
| 51 | + // log the full stack trace (default is the 1st line of the stack trace) |
| 52 | + exceptionFormat = TestExceptionFormat.FULL |
| 53 | + // verbose log for failed and skipped tests (by default the name of the tests are not logged) |
| 54 | + events(SKIPPED, FAILED) |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +jacoco { |
| 59 | + toolVersion = "0.8.12" |
| 60 | +} |
| 61 | + |
| 62 | +tasks.jacocoTestReport { |
| 63 | + dependsOn(tasks.test) |
| 64 | + reports { |
| 65 | + xml.required.set(true) |
| 66 | + csv.required.set(false) |
| 67 | + html.required.set(providers.environmentVariable("CI").map { it.toBoolean().not() }.orElse(true)) |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +plugins.withType<JacocoPlugin> { |
| 72 | + tasks["test"].finalizedBy("jacocoTestReport") |
| 73 | +} |
0 commit comments