-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($spring-boot-admin): migrate from Maven to Gradle
- Loading branch information
1 parent
06ca634
commit 39e5ebc
Showing
4 changed files
with
112 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
spring-boot-admin/spring-boot-admin-bootstrap/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,78 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
import com.palantir.gradle.gitversion.VersionDetails | ||
import groovy.lang.Closure | ||
import org.springframework.boot.gradle.tasks.bundling.BootJar | ||
import org.springframework.boot.gradle.tasks.run.BootRun | ||
import java.time.LocalDateTime | ||
|
||
description = "Muscle and Fitness Server :: Spring Boot Admin - Bootstrap" | ||
|
||
plugins { | ||
id("com.google.cloud.tools.jib") | ||
} | ||
|
||
val versionDetails: Closure<VersionDetails> by extra | ||
val gitVersionDetails = versionDetails() | ||
|
||
dependencies { | ||
// MAF dependencies | ||
implementation(project(":spring-cloud-starter")){ | ||
exclude("de.codecentric", "spring-boot-admin-starter-client") | ||
} | ||
val springBootAdminStarterVersion: String by project | ||
implementation("de.codecentric:spring-boot-admin-starter-server:$springBootAdminStarterVersion") | ||
} | ||
|
||
tasks.withType<BootJar> { | ||
this.enabled = true | ||
// archiveFileName = [baseName]-[gitHash]-[version]-[classifier].[extension] | ||
this.archiveFileName.set("${archiveBaseName.get()}-${gitVersionDetails.gitHash}-${archiveVersion.get()}.${archiveExtension.get()}") | ||
logger.info("Building Spring Boot executable jar: ${this.archiveFileName.get()}") | ||
} | ||
|
||
tasks.withType<BootRun> { | ||
if (project.hasProperty("jvmArgs")) { | ||
val jvmArgsProperty = (project.properties["jvmArgs"] as String) | ||
logger.info("jvmArgsProperty for the app [${project.name}] (before split): `$jvmArgsProperty`") | ||
jvmArgs = jvmArgsProperty.split(Regex("\\s+")) | ||
logger.info("allJvmArgs for the app [${project.name}] (after split): $allJvmArgs") | ||
} | ||
} | ||
|
||
// https://www.baeldung.com/spring-boot-auto-property-expansion | ||
// https://github.com/gradle/kotlin-dsl-samples/blob/master/samples/copy/build.gradle.kts | ||
// https://www.tristanfarmer.dev/blog/gradle_property_expansion_spring_boot | ||
tasks.withType<ProcessResources> { | ||
// Only expand the file `application.yml` | ||
filesMatching("**/application.yml") { | ||
expand(project.properties) | ||
} | ||
} | ||
|
||
springBoot { | ||
buildInfo() | ||
} | ||
|
||
// https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin | ||
jib { | ||
pluginExtensions { | ||
pluginExtension { | ||
implementation = "com.google.cloud.tools.jib.gradle.extension.springboot.JibSpringBootExtension" | ||
properties = mapOf("useDeprecatedExcludeDevtoolsOption" to "true") | ||
} | ||
} | ||
val temurinTag: String by properties | ||
from.image = "eclipse-temurin:${temurinTag}" | ||
val dockerHubRepositoryPrefix: String by properties | ||
val projectArtifactId: String by properties | ||
val springBootAdminArtifactId: String by properties | ||
to.image = "$dockerHubRepositoryPrefix$projectArtifactId.$springBootAdminArtifactId" | ||
to.tags = setOf("${gitVersionDetails.gitHash}-${project.version}") | ||
container.appRoot = "/$springBootAdminArtifactId" | ||
val projectBuildSourceEncoding: String by properties | ||
container.jvmFlags = listOf("-Dfile.encoding=$projectBuildSourceEncoding") | ||
val springBootAdminPort: String by properties | ||
container.ports = listOf(springBootAdminPort) | ||
container.creationTime = LocalDateTime.now().toString() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters