Skip to content

Commit

Permalink
Upgrade to Gradle 8.4 (#400)
Browse files Browse the repository at this point in the history
* Update to Gradle 8.4

* Update Kotlin gradle configuration for Spring Boot 3

* Add gradle update action

* fix clean architecture tests

* Add file code format

* fix upgrade actions tests

* fix upgrade gradle actions test
  • Loading branch information
luisgomez29 authored Nov 29, 2023
1 parent 6aa578e commit aad0b65
Show file tree
Hide file tree
Showing 16 changed files with 430 additions and 57 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -232,5 +232,5 @@ tasks.register('installGitHooks', Copy) {
}

tasks.named('wrapper') {
gradleVersion = '8.1.1'
gradleVersion = '8.4'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,26 +131,29 @@ 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.
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
case $MAX_FD in #(
'' | 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
Expand Down Expand Up @@ -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" \
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/co/com/bancolombia/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ tasks.getByName<Jar>("jar") {

tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
// Sets output jar name
this.archiveFileName.set("${project.getParent()?.getName()}.${archiveExtension.get()}")
archiveFileName = "${project.parent?.name}.${archiveExtension.get()}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {

tasks.register('explodedJar', Copy) {
with jar
into "${buildDir}/exploded"
into layout.buildDirectory.dir("exploded")
}

jar {
Expand Down
64 changes: 38 additions & 26 deletions src/main/resources/structure/root/build.gradle.kts.mustache
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = JavaVersion.{{javaVersion}}.toString()
}
}

sonarqube {
val modules = subprojects.map { subproject ->
subproject.projectDir.toString().replace(project.projectDir.toString() + "/", "")
Expand All @@ -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}}")
Expand All @@ -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}}
Expand All @@ -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<JacocoReport> {
Expand All @@ -97,9 +109,9 @@ tasks.withType<JacocoReport> {
}
)
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(true)
xml.required = true
csv.required = false
html.required = true
}
}
{{/jacoco}}
9 changes: 6 additions & 3 deletions src/main/resources/structure/root/main.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ subprojects {

compileJava.dependsOn validateStructure
sourceCompatibility = JavaVersion.{{javaVersion}}

test {
useJUnitPlatform()
}

dependencies {
{{#reactive}}
implementation 'io.projectreactor:reactor-core'
Expand Down Expand Up @@ -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}}
Expand All @@ -77,7 +79,7 @@ subprojects {
{{#jacoco}}
jacoco {
toolVersion = "${jacocoVersion}"
reportsDirectory = file("$buildDir/reports")
reportsDirectory.set(layout.buildDirectory.dir("reports"))
}

tasks.register('jacocoMergedReport', JacocoReport) {
Expand Down Expand Up @@ -110,6 +112,7 @@ tasks.withType(JavaCompile).configureEach {
'-Amapstruct.suppressGeneratorTimestamp=true'
]
}

tasks.named('wrapper') {
gradleVersion = '{{gradleVersion}}'
}
Loading

0 comments on commit aad0b65

Please sign in to comment.