From cc0438aeebd850ad32e862b0942da3741216c16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Miller=20=28=E9=94=BA=E4=BF=8A=29?= Date: Sun, 31 Jul 2022 18:50:26 +0800 Subject: [PATCH] feat($maf-mis): migrate from Maven to Gradle --- .../auth-center-message/build.gradle.kts | 5 - auth-center/auth-center-web/build.gradle.kts | 5 - gradle.properties | 4 + maf-mis/maf-mis-biz/build.gradle.kts | 7 +- maf-mis/maf-mis-biz/pom.xml | 23 --- maf-mis/maf-mis-bootstrap/build.gradle.kts | 71 ++++++++- maf-mis/maf-mis-bootstrap/pom.xml | 125 --------------- .../src/main/resources/application.yml | 60 ++++---- maf-mis/maf-mis-domain/build.gradle.kts | 7 +- maf-mis/maf-mis-domain/pom.xml | 23 --- maf-mis/maf-mis-infra/build.gradle.kts | 51 +++++++ maf-mis/maf-mis-infra/pom.xml | 16 -- maf-mis/maf-mis-message/build.gradle.kts | 7 +- maf-mis/maf-mis-message/pom.xml | 23 --- maf-mis/maf-mis-web/build.gradle.kts | 7 +- maf-mis/maf-mis-web/pom.xml | 23 --- maf-mis/pom.xml | 143 ------------------ 17 files changed, 171 insertions(+), 429 deletions(-) delete mode 100644 maf-mis/maf-mis-biz/pom.xml delete mode 100644 maf-mis/maf-mis-bootstrap/pom.xml delete mode 100644 maf-mis/maf-mis-domain/pom.xml delete mode 100644 maf-mis/maf-mis-infra/pom.xml delete mode 100644 maf-mis/maf-mis-message/pom.xml delete mode 100644 maf-mis/maf-mis-web/pom.xml delete mode 100644 maf-mis/pom.xml diff --git a/auth-center/auth-center-message/build.gradle.kts b/auth-center/auth-center-message/build.gradle.kts index 75dc6858..c7dfcc6f 100644 --- a/auth-center/auth-center-message/build.gradle.kts +++ b/auth-center/auth-center-message/build.gradle.kts @@ -1,10 +1,5 @@ description = "Muscle and Fitness Server :: Auth Center - Message" -val projectGroupId: String by project -group = projectGroupId -val projectVersion: String by project -version = projectVersion - dependencies { // MAF dependencies api(project(":auth-center-biz")) diff --git a/auth-center/auth-center-web/build.gradle.kts b/auth-center/auth-center-web/build.gradle.kts index 31875709..a32d9183 100644 --- a/auth-center/auth-center-web/build.gradle.kts +++ b/auth-center/auth-center-web/build.gradle.kts @@ -1,10 +1,5 @@ description = "Muscle and Fitness Server :: Auth Center - Web" -val projectGroupId: String by project -group = projectGroupId -val projectVersion: String by project -version = projectVersion - dependencies { // MAF dependencies api(project(":auth-center-biz")) diff --git a/gradle.properties b/gradle.properties index 0031fa99..88981486 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,3 +49,7 @@ poiVersion=5.2.2 # Auth Center constants authCenterPort=8800 authCenterArtifactId=auth-center + +# MAF MIS constants +mafMisPort=8800 +mafMisArtifactId=maf-mis diff --git a/maf-mis/maf-mis-biz/build.gradle.kts b/maf-mis/maf-mis-biz/build.gradle.kts index fb430203..3948f5e2 100644 --- a/maf-mis/maf-mis-biz/build.gradle.kts +++ b/maf-mis/maf-mis-biz/build.gradle.kts @@ -1,5 +1,6 @@ +description = "Muscle and Fitness Server :: MAF MIS - Biz" + dependencies { - implementation(project(":maf-mis-domain")) + // MAF + api(project(":maf-mis-domain")) } - -description = "Muscle and Fitness Server :: MAF MIS - Biz" diff --git a/maf-mis/maf-mis-biz/pom.xml b/maf-mis/maf-mis-biz/pom.xml deleted file mode 100644 index 469fa396..00000000 --- a/maf-mis/maf-mis-biz/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - maf-mis-biz - Muscle and Fitness Server :: MAF MIS - Biz - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - - - - com.jmsoftware.maf - maf-mis-domain - - - diff --git a/maf-mis/maf-mis-bootstrap/build.gradle.kts b/maf-mis/maf-mis-bootstrap/build.gradle.kts index 57e93852..870d980f 100644 --- a/maf-mis/maf-mis-bootstrap/build.gradle.kts +++ b/maf-mis/maf-mis-bootstrap/build.gradle.kts @@ -1,6 +1,75 @@ +@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 :: MAF MIS - Bootstrap" + +plugins { + id("com.google.cloud.tools.jib") +} + +val versionDetails: Closure by extra +val gitVersionDetails = versionDetails() + dependencies { implementation(project(":maf-mis-web")) implementation(project(":maf-mis-message")) } -description = "Muscle and Fitness Server :: MAF MIS - Bootstrap" +tasks.withType { + 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 { + 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 { + // 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 mafMisArtifactId: String by properties + to.image = "$dockerHubRepositoryPrefix$projectArtifactId.$mafMisArtifactId" + to.tags = setOf("${gitVersionDetails.gitHash}-${project.version}") + container.appRoot = "/$mafMisArtifactId" + val projectBuildSourceEncoding: String by properties + container.jvmFlags = listOf("-Dfile.encoding=$projectBuildSourceEncoding") + val mafMisPort: String by properties + container.ports = listOf(mafMisPort) + container.creationTime = LocalDateTime.now().toString() +} + diff --git a/maf-mis/maf-mis-bootstrap/pom.xml b/maf-mis/maf-mis-bootstrap/pom.xml deleted file mode 100644 index 50fa5c11..00000000 --- a/maf-mis/maf-mis-bootstrap/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - 4.0.0 - - - maf-mis-bootstrap - Muscle and Fitness Server :: MAF MIS - Bootstrap - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - build-info - compile - - build-info - - - - - - - - com.google.cloud.tools - jib-maven-plugin - ${jib-maven-plugin.version} - - - com.google.cloud.tools - jib-spring-boot-extension-maven - ${jib-spring-boot-extension-maven.version} - - - - - - - buildAndPushDockerImagePhase - install - - build - - - - - - - eclipse-temurin:${temurin.tag} - - - docker.io/ijohnnymiller/${project.baseArtifactId}.${project.parent.artifactId} - - - ${git.commit.id.abbrev}-${project.version} - - - - - /${project.parent.artifactId} - - -Dfile.encoding=${project.build.sourceEncoding} - - - ${maf-mis.port} - - USE_CURRENT_TIMESTAMP - - - - - com.google.cloud.tools.jib.maven.extension.springboot.JibSpringBootExtension - - - true - - - - - - - - - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.3 - - - - - - - com.jmsoftware.maf - maf-mis-web - - - com.jmsoftware.maf - maf-mis-message - - - diff --git a/maf-mis/maf-mis-bootstrap/src/main/resources/application.yml b/maf-mis/maf-mis-bootstrap/src/main/resources/application.yml index 1f641da6..080529ec 100644 --- a/maf-mis/maf-mis-bootstrap/src/main/resources/application.yml +++ b/maf-mis/maf-mis-bootstrap/src/main/resources/application.yml @@ -1,18 +1,18 @@ server: - port: @maf-mis.port@ + port: ${mafMisPort} tomcat: - uri-encoding: @project.build.sourceEncoding@ + uri-encoding: ${projectBuildSourceEncoding} shutdown: GRACEFUL servlet: context-path: spring: application: - name: @project.parent.artifactId@ + name: ${mafMisArtifactId} profiles: - active: @environment@ + active: ${environment} config: - import: consul:${spring.cloud.consul.host}:${spring.cloud.consul.port} + import: consul:\${spring.cloud.consul.host}:\${spring.cloud.consul.port} cloud: # https://docs.spring.io/spring-cloud-consul/docs/current/reference/html/index.html#spring-cloud-consul-config consul: @@ -32,42 +32,42 @@ spring: - shardingsphere discovery: register: true - instance-id: ${spring.application.name}-${spring.cloud.client.hostname}-${vcap.application.instance_id:${spring.application.instance_id:${random.value}}} - service-name: ${spring.application.name} - port: ${server.port} + instance-id: \${spring.application.name}-\${spring.cloud.client.hostname}-\${vcap.application.instance_id:\${spring.application.instance_id:\${random.value}}} + service-name: \${spring.application.name} + port: \${server.port} prefer-ip-address: true - ip-address: ${spring.cloud.client.ip-address} + ip-address: \${spring.cloud.client.ip-address} health-check-critical-timeout: 15s servlet: multipart: - location: @project.parent.artifactId@/${spring.application.name}/temprary-file + location: ${projectArtifactId}/\${spring.application.name}/temporary-file max-file-size: 64MB max-request-size: 70MB file-size-threshold: 0 logging: - config: classpath:logback-configuration/logback-${spring.profiles.active}.xml + config: classpath:logback-configuration/logback-\${spring.profiles.active}.xml maf: project-properties: - base-package: @project.groupId@ - context-path: ${server.servlet.context-path} - group-id: @project.groupId@ - project-parent-artifact-id: @project.parent.artifactId@ - project-artifact-id: @project.parent.artifactId@ - version: @project.version@ - description: @project.description@ - jdk-version: @java.version@ - environment: ${spring.profiles.active} - url: @project.url@ - inception-year: @inceptionYear@ - organization-name: @project.organization.name@ - organization-url: @project.organization.url@ - issue-management-system: @project.issueManagement.system@ - issue-management-url: @project.issueManagement.url@ - developer-name: @developerName@ - developer-email: @developerEmail@ - developer-url: @developerUrl@ + base-package: ${projectGroupId} + context-path: \${server.servlet.context-path} + group-id: ${projectGroupId} + project-parent-artifact-id: ${projectArtifactId} + project-artifact-id: ${mafMisArtifactId} + version: ${projectVersion} + description: "${description}" + jdk-version: ${javaVersion} + environment: \${spring.profiles.active} + url: ${projectUrl} + inception-year: ${inceptionYear} + organization-name: ${projectOrganizationName} + organization-url: ${projectOrganizationUrl} + issue-management-system: ${projectIssueManagementSystem} + issue-management-url: ${projectIssueManagementUrl} + developer-name: ${developerName} + developer-email: ${developerEmail} + developer-url: ${developerUrl} configuration: ignored-url: pattern: @@ -79,4 +79,4 @@ maf: - "/*/v2/api-docs/**" - "/webjars/**" - "/doc.html" - included-package-for-http-api-scan: ${maf.project-properties.base-package} + included-package-for-http-api-scan: \${maf.project-properties.base-package} diff --git a/maf-mis/maf-mis-domain/build.gradle.kts b/maf-mis/maf-mis-domain/build.gradle.kts index d540ccd8..829b8f41 100644 --- a/maf-mis/maf-mis-domain/build.gradle.kts +++ b/maf-mis/maf-mis-domain/build.gradle.kts @@ -1,5 +1,6 @@ +description = "Muscle and Fitness Server :: MAF MIS - Domain" + dependencies { - implementation(project(":maf-mis-infra")) + // MAF dependencies + api(project(":maf-mis-infra")) } - -description = "Muscle and Fitness Server :: MAF MIS - Domain" diff --git a/maf-mis/maf-mis-domain/pom.xml b/maf-mis/maf-mis-domain/pom.xml deleted file mode 100644 index 20769042..00000000 --- a/maf-mis/maf-mis-domain/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - maf-mis-domain - Muscle and Fitness Server :: MAF MIS - Domain - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - - - - com.jmsoftware.maf - maf-mis-infra - - - diff --git a/maf-mis/maf-mis-infra/build.gradle.kts b/maf-mis/maf-mis-infra/build.gradle.kts index 2ba7e2f2..c596d2df 100644 --- a/maf-mis/maf-mis-infra/build.gradle.kts +++ b/maf-mis/maf-mis-infra/build.gradle.kts @@ -1 +1,52 @@ description = "Muscle and Fitness Server :: MAF MIS - Infra" + +configurations.implementation { + isTransitive = true +} +configurations.runtimeOnly { + isTransitive = true +} +configurations.testImplementation { + isTransitive = true +} + +dependencies { + // MAF dependencies + api(project(":spring-cloud-starter")) + + // Spring dependencies + api("org.springframework.boot:spring-boot-starter-data-redis") + api("org.springframework.boot:spring-boot-starter-data-elasticsearch") + api("org.springframework.boot:spring-boot-starter-amqp") + api("org.springframework.boot:spring-boot-starter-quartz") + api("org.springframework.boot:spring-boot-starter-websocket") + api("org.springframework.boot:spring-boot-starter-reactor-netty") + api("org.springframework:spring-test") + + // Spring integration + api("org.springframework.integration:spring-integration-redis") + + // ORM Libraries + // runtimeOnly libraries are the opposite, they are available at runtime but not at compile-time. + runtimeOnly("mysql:mysql-connector-java") + val mybatisPlusBootStarterVersion: String by project + api("com.baomidou:mybatis-plus-boot-starter:$mybatisPlusBootStarterVersion") + val shardingsphereVersion: String by project + api("org.apache.shardingsphere:shardingsphere-jdbc-core-spring-boot-starter:$shardingsphereVersion") + + // JWT, https://github.com/jwtk/jjwt + // Cannot Remove jjwt dependencies, cuz the login process is in here `auth-center`, and the auth process is in `api-gateway` + val jjwtVersion: String by project + api("io.jsonwebtoken:jjwt-api:$jjwtVersion") + api("io.jsonwebtoken:jjwt-impl:$jjwtVersion") + runtimeOnly("io.jsonwebtoken:jjwt-jackson:$jjwtVersion") + + // Apache POI - Java API To Access Microsoft Format Files + val poiVersion: String by project + api("org.apache.poi:poi:$poiVersion") + api("org.apache.poi:poi-ooxml:$poiVersion") + + // Testing + testImplementation("org.springframework.amqp:spring-rabbit-test") + testImplementation("org.mockito:mockito-inline") +} diff --git a/maf-mis/maf-mis-infra/pom.xml b/maf-mis/maf-mis-infra/pom.xml deleted file mode 100644 index 7ea808bc..00000000 --- a/maf-mis/maf-mis-infra/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - - maf-mis-infra - Muscle and Fitness Server :: MAF MIS - Infra - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - diff --git a/maf-mis/maf-mis-message/build.gradle.kts b/maf-mis/maf-mis-message/build.gradle.kts index b94e4789..486bf52c 100644 --- a/maf-mis/maf-mis-message/build.gradle.kts +++ b/maf-mis/maf-mis-message/build.gradle.kts @@ -1,5 +1,6 @@ +description = "Muscle and Fitness Server :: MAF MIS - Message" + dependencies { - implementation(project(":maf-mis-biz")) + // MAF dependencies + api(project(":maf-mis-biz")) } - -description = "Muscle and Fitness Server :: MAF MIS - Message" diff --git a/maf-mis/maf-mis-message/pom.xml b/maf-mis/maf-mis-message/pom.xml deleted file mode 100644 index 7a3d40a5..00000000 --- a/maf-mis/maf-mis-message/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - maf-mis-message - Muscle and Fitness Server :: MAF MIS - Message - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - - - - com.jmsoftware.maf - maf-mis-biz - - - diff --git a/maf-mis/maf-mis-web/build.gradle.kts b/maf-mis/maf-mis-web/build.gradle.kts index 45c6347f..bb52f664 100644 --- a/maf-mis/maf-mis-web/build.gradle.kts +++ b/maf-mis/maf-mis-web/build.gradle.kts @@ -1,5 +1,6 @@ +description = "Muscle and Fitness Server :: MAF MIS - Web" + dependencies { - implementation(project(":maf-mis-biz")) + // MAF dependencies + api(project(":maf-mis-biz")) } - -description = "Muscle and Fitness Server :: MAF MIS - Web" diff --git a/maf-mis/maf-mis-web/pom.xml b/maf-mis/maf-mis-web/pom.xml deleted file mode 100644 index 0c1d62a7..00000000 --- a/maf-mis/maf-mis-web/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - maf-mis-web - Muscle and Fitness Server :: MAF MIS - Web - Exercise Management Information Service. - - com.jmsoftware.maf - maf-mis - 0.0.9.1-SNAPSHOT - - - - - com.jmsoftware.maf - maf-mis-biz - - - diff --git a/maf-mis/pom.xml b/maf-mis/pom.xml deleted file mode 100644 index 81af0492..00000000 --- a/maf-mis/pom.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - 4.0.0 - - - maf-mis - Muscle and Fitness Server :: MAF MIS - Exercise Management Information Service. - - com.jmsoftware.maf - muscle-and-fitness-server - 0.0.9.1-SNAPSHOT - - pom - - - - maf-mis-bootstrap - maf-mis-web - maf-mis-message - maf-mis-biz - maf-mis-domain - maf-mis-infra - - - - - - com.jmsoftware.maf - maf-mis-bootstrap - ${project.version} - - - com.jmsoftware.maf - maf-mis-web - ${project.version} - - - com.jmsoftware.maf - maf-mis-message - ${project.version} - - - com.jmsoftware.maf - maf-mis-biz - ${project.version} - - - com.jmsoftware.maf - maf-mis-domain - ${project.version} - - - com.jmsoftware.maf - maf-mis-infra - ${project.version} - - - - - - - - com.jmsoftware.maf - spring-cloud-starter - - - com.jmsoftware.maf - universal-ui - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.boot - spring-boot-starter-data-elasticsearch - - - org.springframework.boot - spring-boot-starter-amqp - - - org.springframework.amqp - spring-rabbit-test - test - - - org.springframework.boot - spring-boot-starter-quartz - - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework.boot - spring-boot-starter-reactor-netty - - - org.springframework - spring-test - - - - - org.springframework.integration - spring-integration-redis - - - - - mysql - mysql-connector-java - runtime - - - com.baomidou - mybatis-plus-boot-starter - ${mybatis-plus-boot-starter.version} - - - org.apache.shardingsphere - shardingsphere-jdbc-core-spring-boot-starter - ${shardingsphere.version} - - - - - org.apache.poi - poi - ${poi.version} - - - org.apache.poi - poi-ooxml - ${poi.version} - - -