diff --git a/build.gradle b/build.gradle index cea2733a..7e96745c 100644 --- a/build.gradle +++ b/build.gradle @@ -98,7 +98,7 @@ if (project.hasProperty('signing.keyId')) { // publish as library in maven centr } javadoc.failOnError = false - tasks.withType(GenerateModuleMetadata) { + tasks.withType(GenerateModuleMetadata).configureEach { enabled = false } @@ -190,7 +190,7 @@ jacocoTestReport { dependsOn(tasks.test) reports { xml.setRequired true - xml.setOutputLocation file("${buildDir}/reports/jacoco/report.xml") + xml.setOutputLocation layout.buildDirectory.file("reports/jacoco/report.xml") html.setRequired true csv.setRequired false } @@ -232,5 +232,5 @@ tasks.register('installGitHooks', Copy) { } tasks.named('wrapper') { - gradleVersion = '8.1.1' + gradleVersion = '8.4' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ccebba77..7f93135c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 79a61d42..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/src/main/java/co/com/bancolombia/Constants.java b/src/main/java/co/com/bancolombia/Constants.java index b54bf8b9..f08e5ae4 100644 --- a/src/main/java/co/com/bancolombia/Constants.java +++ b/src/main/java/co/com/bancolombia/Constants.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PRIVATE) -public class Constants { +public final class Constants { public static final String PLUGIN_TASK_GROUP = "Clean Architecture"; public static final String APP_SERVICE = "app-service"; public static final String PATH_GRAPHQL = "/graphql"; @@ -18,8 +18,8 @@ public class Constants { public static final String RCOMMONS_OBJECT_MAPPER_VERSION = "0.1.0"; public static final String BLOCK_HOUND_VERSION = "1.0.8.RELEASE"; public static final String PLUGIN_VERSION = "3.6.3"; - public static final String GRADLE_WRAPPER_VERSION = "8.2.1"; - public static final String KOTLIN_VERSION = "1.6.10"; + public static final String GRADLE_WRAPPER_VERSION = "8.4"; + public static final String KOTLIN_VERSION = "1.9.20"; public static final String AWS_BOM_VERSION = "2.20.94"; public static final String COMMONS_JMS_VERSION = "1.2.0"; public static final String GRAPHQL_KICKSTART_VERSION = "15.0.0"; diff --git a/src/main/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05Gradle.java b/src/main/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05Gradle.java new file mode 100644 index 00000000..67fe29cf --- /dev/null +++ b/src/main/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05Gradle.java @@ -0,0 +1,54 @@ +package co.com.bancolombia.factory.upgrades.actions; + +import static co.com.bancolombia.Constants.MainFiles.APP_BUILD_GRADLE; +import static co.com.bancolombia.Constants.MainFiles.MAIN_GRADLE; + +import co.com.bancolombia.factory.ModuleBuilder; +import co.com.bancolombia.factory.upgrades.UpdateUtils; +import co.com.bancolombia.factory.upgrades.UpgradeAction; +import lombok.SneakyThrows; + +public class UpgradeY2023M11D05Gradle implements UpgradeAction { + + @Override + @SneakyThrows + public boolean up(ModuleBuilder builder) { + return builder.updateFile( + MAIN_GRADLE, + content -> { + String res = + UpdateUtils.replace( + content, + "xml.setOutputLocation file(\"${buildDir}/reports/jacoco.xml\")", + "xml.setOutputLocation layout.buildDirectory.file(\"reports/jacoco.xml\")"); + res = + UpdateUtils.replace( + res, + "html.setOutputLocation file(\"${buildDir}/reports/jacocoHtml\")", + "html.setOutputLocation layout.buildDirectory.dir(\"reports/jacocoHtml\")"); + res = + UpdateUtils.replace( + res, + "reportsDirectory.set(file(\"$buildDir/reports\"))", + "reportsDirectory.set(layout.buildDirectory.dir(\"reports\"))"); + return res; + }) + | builder.updateFile( + APP_BUILD_GRADLE, + content -> + UpdateUtils.replace( + content, + "into \"${buildDir}/exploded\"", + "into layout.buildDirectory.dir(\"exploded\")")); + } + + @Override + public String name() { + return "3.6.4->3.6.5"; + } + + @Override + public String description() { + return "Update deprecated Project.buildDir with Project.layout.buildDirectory"; + } +} diff --git a/src/main/resources/structure/applications/appservice/build.gradle.kts.mustache b/src/main/resources/structure/applications/appservice/build.gradle.kts.mustache index 20ea9bb9..a3ccc9c2 100644 --- a/src/main/resources/structure/applications/appservice/build.gradle.kts.mustache +++ b/src/main/resources/structure/applications/appservice/build.gradle.kts.mustache @@ -13,5 +13,5 @@ tasks.getByName("jar") { tasks.getByName("bootJar") { // Sets output jar name - this.archiveFileName.set("${project.getParent()?.getName()}.${archiveExtension.get()}") + archiveFileName = "${project.parent?.name}.${archiveExtension.get()}" } diff --git a/src/main/resources/structure/applications/appservice/build.gradle.mustache b/src/main/resources/structure/applications/appservice/build.gradle.mustache index df3c5921..72112684 100644 --- a/src/main/resources/structure/applications/appservice/build.gradle.mustache +++ b/src/main/resources/structure/applications/appservice/build.gradle.mustache @@ -14,7 +14,7 @@ dependencies { tasks.register('explodedJar', Copy) { with jar - into "${buildDir}/exploded" + into layout.buildDirectory.dir("exploded") } jar { diff --git a/src/main/resources/structure/root/build.gradle.kts.mustache b/src/main/resources/structure/root/build.gradle.kts.mustache index 80ed4899..73357f90 100644 --- a/src/main/resources/structure/root/build.gradle.kts.mustache +++ b/src/main/resources/structure/root/build.gradle.kts.mustache @@ -1,7 +1,7 @@ plugins { id("co.com.bancolombia.cleanArchitecture") version "{{pluginVersion}}" - id("io.spring.dependency-management") version "1.0.11.RELEASE" - id("org.springframework.boot") version "{{springBootVersion}}" + id("io.spring.dependency-management") version "1.1.3" + id("org.springframework.boot") version "{{springBootVersion}}" apply false id("org.sonarqube") version "{{sonarVersion}}" apply true {{#jacoco }} id("jacoco") apply true @@ -10,6 +10,25 @@ plugins { kotlin("plugin.spring") version "{{kotlinVersion}}" } +allprojects { + repositories { + mavenCentral() + maven { url = uri("https://repo.spring.io/milestone") } + maven { url = uri("https://repo.spring.io/snapshot") } + } +} + +java { + sourceCompatibility = JavaVersion.{{javaVersion}} +} + +tasks.withType { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + jvmTarget = JavaVersion.{{javaVersion}}.toString() + } +} + sonarqube { val modules = subprojects.map { subproject -> subproject.projectDir.toString().replace(project.projectDir.toString() + "/", "") @@ -21,7 +40,7 @@ sonarqube { "sonar.sources", "src,deployment,settings.gradle.kts,build.gradle.kts,${modules.joinToString(",") { module -> "${module}/build.gradle.kts" }}" ) - property("sonar.exclusions","**/MainApplication.kt") + property("sonar.exclusions", "**/MainApplication.kt") property("sonar.test", "src/test") property("sonar.java.binaries", "{{sonar.java.binaries}}") property("sonar.junit.reportsPath", "{{sonar.junit.reportsPaths}}") @@ -33,14 +52,6 @@ sonarqube { } } -allprojects { - repositories { - mavenCentral() - maven { url = uri("https://repo.spring.io/milestone") } - maven { url = uri("https://repo.spring.io/snapshot") } - } -} - subprojects { apply(plugin = "kotlin") {{#jacoco}} @@ -60,30 +71,31 @@ subprojects { testAnnotationProcessor("org.projectlombok:lombok:{{lombokVersion}}") {{/lombok}} implementation(platform("org.springframework.boot:spring-boot-dependencies:{{springBootVersion}}")) - runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.6.0") implementation("org.springframework.boot:spring-boot-starter") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.7.3") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") testImplementation("org.springframework.boot:spring-boot-starter-test") } {{#jacoco}} - project.tasks.test.get().finalizedBy(project.tasks.jacocoTestReport) - project.tasks.jacocoTestReport { - dependsOn(project.tasks.test) - reports { - xml.required.set(true) - xml.outputLocation.set(file("${buildDir}/reports/jacoco.xml")) - csv.required.set(false) - html.outputLocation.set(file("${buildDir}/reports/jacocoHtml")) - } - } + project.tasks.test.get().finalizedBy(project.tasks.jacocoTestReport) + project.tasks.jacocoTestReport { + dependsOn(project.tasks.test) + reports { + xml.required = true + xml.outputLocation = layout.buildDirectory.file("reports/jacoco.xml") + csv.required = false + html.outputLocation = layout.buildDirectory.dir("reports/jacocoHtml") + } + } {{/jacoco }} } {{#jacoco}} jacoco { toolVersion = "{{jacocoVersion}}" - reportsDirectory.set(file("$buildDir/reports")) + reportsDirectory = layout.buildDirectory.dir("reports") } tasks.withType { @@ -97,9 +109,9 @@ tasks.withType { } ) reports { - xml.required.set(true) - csv.required.set(false) - html.required.set(true) + xml.required = true + csv.required = false + html.required = true } } {{/jacoco}} diff --git a/src/main/resources/structure/root/main.gradle.mustache b/src/main/resources/structure/root/main.gradle.mustache index 7c0cac5b..0ed80dbe 100644 --- a/src/main/resources/structure/root/main.gradle.mustache +++ b/src/main/resources/structure/root/main.gradle.mustache @@ -18,9 +18,11 @@ subprojects { compileJava.dependsOn validateStructure sourceCompatibility = JavaVersion.{{javaVersion}} + test { useJUnitPlatform() } + dependencies { {{#reactive}} implementation 'io.projectreactor:reactor-core' @@ -58,9 +60,9 @@ subprojects { dependsOn test reports { xml.setRequired true - xml.setOutputLocation file("${buildDir}/reports/jacoco.xml") + xml.setOutputLocation layout.buildDirectory.file("reports/jacoco.xml") csv.setRequired false - html.setOutputLocation file("${buildDir}/reports/jacocoHtml") + html.setOutputLocation layout.buildDirectory.dir("reports/jacocoHtml") } } {{/jacoco}} @@ -77,7 +79,7 @@ subprojects { {{#jacoco}} jacoco { toolVersion = "${jacocoVersion}" - reportsDirectory = file("$buildDir/reports") + reportsDirectory.set(layout.buildDirectory.dir("reports")) } tasks.register('jacocoMergedReport', JacocoReport) { @@ -110,6 +112,7 @@ tasks.withType(JavaCompile).configureEach { '-Amapstruct.suppressGeneratorTimestamp=true' ] } + tasks.named('wrapper') { gradleVersion = '{{gradleVersion}}' } diff --git a/src/test/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05GradleTest.java b/src/test/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05GradleTest.java new file mode 100644 index 00000000..5d59968e --- /dev/null +++ b/src/test/java/co/com/bancolombia/factory/upgrades/actions/UpgradeY2023M11D05GradleTest.java @@ -0,0 +1,69 @@ +package co.com.bancolombia.factory.upgrades.actions; + +import static co.com.bancolombia.Constants.MainFiles.APP_BUILD_GRADLE; +import static co.com.bancolombia.Constants.MainFiles.MAIN_GRADLE; +import static org.gradle.internal.impldep.org.testng.Assert.assertNotNull; +import static org.gradle.internal.impldep.org.testng.Assert.assertTrue; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import co.com.bancolombia.factory.ModuleBuilder; +import co.com.bancolombia.factory.upgrades.UpgradeAction; +import co.com.bancolombia.utils.FileUtils; +import com.github.mustachejava.resolver.DefaultResolver; +import java.io.IOException; +import java.nio.file.Files; +import org.gradle.api.Project; +import org.gradle.api.logging.Logger; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class UpgradeY2023M11D05GradleTest { + @Mock private Project project; + @Mock private Logger logger; + private ModuleBuilder builder; + private UpgradeAction updater; + + @Before + public void setup() throws IOException { + when(project.getName()).thenReturn("UtilsTest"); + when(project.getLogger()).thenReturn(logger); + when(project.getProjectDir()).thenReturn(Files.createTempDirectory("sample").toFile()); + builder = spy(new ModuleBuilder(project)); + updater = new UpgradeY2023M11D05Gradle(); + assertNotNull(updater.name()); + assertNotNull(updater.description()); + } + + @Test + public void shouldApplyUpdate() throws IOException { + DefaultResolver resolver = new DefaultResolver(); + // Arrange + builder.addFile( + MAIN_GRADLE, FileUtils.getResourceAsString(resolver, "gradle-8.4-sample/main-before.txt")); + builder.addFile( + APP_BUILD_GRADLE, + FileUtils.getResourceAsString(resolver, "gradle-8.4-sample/app-service-before.txt")); + + // Act + boolean applied = updater.up(builder); + + // Assert + assertTrue(applied); + verify(builder, times(1)) + .addFile( + MAIN_GRADLE, + FileUtils.getResourceAsString(resolver, "gradle-8.4-sample/main-after.txt")); + + verify(builder, times(1)) + .addFile( + APP_BUILD_GRADLE, + FileUtils.getResourceAsString(resolver, "gradle-8.4-sample/app-service-after.txt")); + } +} diff --git a/src/test/java/co/com/bancolombia/task/AbstractCleanArchitectureDefaultTaskTest.java b/src/test/java/co/com/bancolombia/task/AbstractCleanArchitectureDefaultTaskTest.java index 7b619f04..0772d446 100644 --- a/src/test/java/co/com/bancolombia/task/AbstractCleanArchitectureDefaultTaskTest.java +++ b/src/test/java/co/com/bancolombia/task/AbstractCleanArchitectureDefaultTaskTest.java @@ -1,8 +1,16 @@ package co.com.bancolombia.task; import static co.com.bancolombia.utils.FileUtilsTest.deleteStructure; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import co.com.bancolombia.exceptions.CleanException; import co.com.bancolombia.exceptions.InvalidTaskOptionException; @@ -11,7 +19,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.util.List; +import java.util.Map; import javax.inject.Inject; import org.gradle.api.Action; import org.gradle.api.Project; @@ -47,8 +55,9 @@ public void shouldGetTaskDescriptor() { // Arrange // Act OptionReader reader = helperTask.getOptionReader(); + // Assert - assertEquals(1, reader.getOptions(helperTask).size()); + assertEquals(0, reader.getOptions(helperTask).size()); } @Test @@ -57,9 +66,9 @@ public void shouldGetTaskDescriptorWithOptions() { // Act OptionReader reader = task.getOptionReader(); // Assert - List list = reader.getOptions(task); - assertEquals(2, list.size()); - assertEquals("module", list.get(0).getName()); + Map map = reader.getOptions(task); + assertEquals(1, map.size()); + assertTrue(map.containsKey("module")); } @Test diff --git a/src/test/resources/gradle-8.4-sample/app-service-after.txt b/src/test/resources/gradle-8.4-sample/app-service-after.txt new file mode 100644 index 00000000..81152a69 --- /dev/null +++ b/src/test/resources/gradle-8.4-sample/app-service-after.txt @@ -0,0 +1,25 @@ +apply plugin: 'org.springframework.boot' + +dependencies { + implementation project(':model') + implementation project(':usecase') + implementation 'org.springframework.boot:spring-boot-starter' + runtimeOnly('org.springframework.boot:spring-boot-devtools') + testImplementation 'com.tngtech.archunit:archunit:1.1.0' + testImplementation 'com.fasterxml.jackson.core:jackson-databind' +} + +tasks.register('explodedJar', Copy) { + with jar + into layout.buildDirectory.dir("exploded") +} + +jar { + // To disable the *-plain.jar + enabled = false +} + +bootJar { + // Sets output jar name + archiveFileName = "${project.getParent().getName()}.${archiveExtension.get()}" +} diff --git a/src/test/resources/gradle-8.4-sample/app-service-before.txt b/src/test/resources/gradle-8.4-sample/app-service-before.txt new file mode 100644 index 00000000..4e3bfad2 --- /dev/null +++ b/src/test/resources/gradle-8.4-sample/app-service-before.txt @@ -0,0 +1,25 @@ +apply plugin: 'org.springframework.boot' + +dependencies { + implementation project(':model') + implementation project(':usecase') + implementation 'org.springframework.boot:spring-boot-starter' + runtimeOnly('org.springframework.boot:spring-boot-devtools') + testImplementation 'com.tngtech.archunit:archunit:1.1.0' + testImplementation 'com.fasterxml.jackson.core:jackson-databind' +} + +tasks.register('explodedJar', Copy) { + with jar + into "${buildDir}/exploded" +} + +jar { + // To disable the *-plain.jar + enabled = false +} + +bootJar { + // Sets output jar name + archiveFileName = "${project.getParent().getName()}.${archiveExtension.get()}" +} diff --git a/src/test/resources/gradle-8.4-sample/main-after.txt b/src/test/resources/gradle-8.4-sample/main-after.txt new file mode 100644 index 00000000..7f30d704 --- /dev/null +++ b/src/test/resources/gradle-8.4-sample/main-after.txt @@ -0,0 +1,85 @@ +allprojects { + repositories { + mavenCentral() + maven { url "https://repo.spring.io/snapshot" } + maven { url "https://repo.spring.io/milestone" } + } +} + +subprojects { + apply plugin: 'java' + apply plugin: 'jacoco' + apply plugin: 'io.spring.dependency-management' + + compileJava.dependsOn validateStructure + sourceCompatibility = JavaVersion.VERSION_17 + + test { + useJUnitPlatform() + } + + dependencies { + implementation 'io.projectreactor:reactor-core' + implementation 'io.projectreactor.addons:reactor-extra' + + testImplementation 'io.projectreactor.tools:blockhound-junit-platform:1.0.8.RELEASE' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + testImplementation 'io.projectreactor:reactor-test' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + compileOnly "org.projectlombok:lombok:${lombokVersion}" + annotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + } + + tasks.withType(Test).configureEach { + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) { + jvmArgs += [ + "-XX:+AllowRedefinitionToAddDeleteMethods" + ] + } + } + + test.finalizedBy(project.tasks.jacocoTestReport) + + jacocoTestReport { + dependsOn test + reports { + xml.setRequired true + xml.setOutputLocation layout.buildDirectory.file("reports/jacoco.xml") + csv.setRequired false + html.setOutputLocation layout.buildDirectory.dir("reports/jacocoHtml") + } + } + +} + +jacoco { + toolVersion = "${jacocoVersion}" + reportsDirectory.set(layout.buildDirectory.dir("reports")) +} + +tasks.register('jacocoMergedReport', JacocoReport) { + dependsOn = [test, subprojects.jacocoTestReport] + additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs) + sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs) + classDirectories.setFrom files(subprojects.sourceSets.main.output) + executionData.setFrom project.fileTree(dir: '.', include: '**/build/jacoco/test.exec') + reports { + xml.setRequired true + csv.setRequired false + html.setRequired true + } +} + +tasks.withType(JavaCompile).configureEach { + options.compilerArgs = [ + '-Amapstruct.suppressGeneratorTimestamp=true' + ] +} + +tasks.named('wrapper') { + gradleVersion = '8.2.1' +} diff --git a/src/test/resources/gradle-8.4-sample/main-before.txt b/src/test/resources/gradle-8.4-sample/main-before.txt new file mode 100644 index 00000000..70c51523 --- /dev/null +++ b/src/test/resources/gradle-8.4-sample/main-before.txt @@ -0,0 +1,85 @@ +allprojects { + repositories { + mavenCentral() + maven { url "https://repo.spring.io/snapshot" } + maven { url "https://repo.spring.io/milestone" } + } +} + +subprojects { + apply plugin: 'java' + apply plugin: 'jacoco' + apply plugin: 'io.spring.dependency-management' + + compileJava.dependsOn validateStructure + sourceCompatibility = JavaVersion.VERSION_17 + + test { + useJUnitPlatform() + } + + dependencies { + implementation 'io.projectreactor:reactor-core' + implementation 'io.projectreactor.addons:reactor-extra' + + testImplementation 'io.projectreactor.tools:blockhound-junit-platform:1.0.8.RELEASE' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + testImplementation 'io.projectreactor:reactor-test' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + compileOnly "org.projectlombok:lombok:${lombokVersion}" + annotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + } + + tasks.withType(Test).configureEach { + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) { + jvmArgs += [ + "-XX:+AllowRedefinitionToAddDeleteMethods" + ] + } + } + + test.finalizedBy(project.tasks.jacocoTestReport) + + jacocoTestReport { + dependsOn test + reports { + xml.setRequired true + xml.setOutputLocation file("${buildDir}/reports/jacoco.xml") + csv.setRequired false + html.setOutputLocation file("${buildDir}/reports/jacocoHtml") + } + } + +} + +jacoco { + toolVersion = "${jacocoVersion}" + reportsDirectory.set(file("$buildDir/reports")) +} + +tasks.register('jacocoMergedReport', JacocoReport) { + dependsOn = [test, subprojects.jacocoTestReport] + additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs) + sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs) + classDirectories.setFrom files(subprojects.sourceSets.main.output) + executionData.setFrom project.fileTree(dir: '.', include: '**/build/jacoco/test.exec') + reports { + xml.setRequired true + csv.setRequired false + html.setRequired true + } +} + +tasks.withType(JavaCompile).configureEach { + options.compilerArgs = [ + '-Amapstruct.suppressGeneratorTimestamp=true' + ] +} + +tasks.named('wrapper') { + gradleVersion = '8.2.1' +}