Use Version Catalog in Samples, Build Files and Plugins

This commit is contained in:
Marcus Hert Da Coregio
2023-11-27 09:33:26 -03:00
parent 03eaf7da3a
commit aa9e18f8c5
6 changed files with 18 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ buildscript {
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
classpath libs.org.springframework.boot.spring.boot.gradle.plugin
}
}

View File

@@ -17,6 +17,7 @@
package io.spring.gradle.convention;
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.sonarqube.gradle.SonarQubePlugin;
/**
@@ -33,16 +34,16 @@ public class SpringSamplePlugin extends AbstractSpringJavaPlugin {
@Override
protected void initialPlugins(Project project) {
if (project.hasProperty('springBootVersion')) {
String springBootVersion = project.springBootVersion
def versionCatalog = project.rootProject.extensions.getByType(VersionCatalogsExtension.class)
.named("libs")
def version = versionCatalog.findVersion("org-springframework-boot")
version.ifPresent {
def springBootVersion = it.displayName
if (Utils.isSnapshot(springBootVersion)) {
project.ext.forceMavenRepositories = 'snapshot'
}
else if (Utils.isMilestone(springBootVersion)) {
} else if (Utils.isMilestone(springBootVersion)) {
project.ext.forceMavenRepositories = 'milestone'
}
}
}
}

View File

@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
version=3.0.5-SNAPSHOT
springBootVersion=3.0.7

View File

@@ -9,6 +9,7 @@ org-mockito = "4.8.1"
org-mongodb = "4.8.2"
org-slf4j = "2.0.9"
org-springframework = "6.0.14"
org-springframework-boot = "3.0.7"
org-testcontainers = "1.17.6"
org-junit = "5.8.2"
@@ -67,6 +68,8 @@ org-slf4j-slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "org-slf4j
org-springframework-data-spring-data-bom = "org.springframework.data:spring-data-bom:2022.0.12"
org-springframework-security-spring-security-bom = "org.springframework.security:spring-security-bom:6.0.8"
org-springframework-spring-framework-bom = { module = "org.springframework:spring-framework-bom", version.ref = "org-springframework"}
org-springframework-boot-spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "org-springframework-boot" }
org-springframework-boot-spring-boot-gradle-plugin = { module = "org.springframework.boot:spring-boot-gradle-plugin", version.ref = "org-springframework-boot" }
org-testcontainers-testcontainers-bom = { module = "org.testcontainers:testcontainers-bom", version.ref = "org-testcontainers" }
org-thymeleaf-extras-thymeleaf-extras-springsecurity6 = "org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.2.RELEASE"
org-webjars-bootstrap = "org.webjars:bootstrap:2.3.2"

View File

@@ -49,6 +49,10 @@ tasks.named("generateAntoraYml") {
def generateAttributes() {
def springBootVersion = libs.versions.org.springframework.boot.get()
springBootVersion = springBootVersion.contains("-")
? springBootVersion.substring(0, springBootVersion.indexOf("-"))
: springBootVersion
def ghTag = snapshotBuild ? 'main' : project.version
def springBootRefDocs = "https://docs.spring.io/spring-boot/docs/${springBootVersion}/reference/html"
return ['gh-tag':ghTag,

View File

@@ -1,3 +1,6 @@
def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("libs")
def springBootVersion = versionCatalog.findVersion("org-springframework-boot").get().displayName
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:$springBootVersion"