Skip to content

Commit

Permalink
Gradle 脚本优化 (#17)
Browse files Browse the repository at this point in the history
* 使用 libs.versions.toml 统一管理 Gradle 依赖信息

* 将 jandex 封装为插件,便于使用

* chore: 移除未使用的 gradle.properties

* chore: 统一管理 Quarkus 版本号
  • Loading branch information
gtn1024 authored Jul 31, 2024
1 parent 5bdda4b commit 5343c81
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 43 deletions.
14 changes: 14 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id 'groovy-gradle-plugin'
id 'java-library'
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation gradleApi()
implementation 'org.kordamp.gradle:jandex-gradle-plugin:2.0.0'
}
7 changes: 7 additions & 0 deletions buildSrc/src/main/groovy/configure-jandex.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id 'org.kordamp.gradle.jandex'
}

tasks.named('checkstyleMain').configure {
dependsOn 'jandex'
}
6 changes: 0 additions & 6 deletions gradle.properties

This file was deleted.

7 changes: 7 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[versions]
testcontainers = "1.20.0"

quarkus = "3.12.3"

[libraries]
testcontainers-postgresql = { module = "org.testcontainers:postgresql", version.ref = "testcontainers" }

quarkus-platform-bom = { module = "io.quarkus.platform:quarkus-bom", version.ref = "quarkus" }

[plugins]
quarkus = { id = "io.quarkus", version.ref = "quarkus" }
4 changes: 2 additions & 2 deletions my-boot/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'java'
id 'io.quarkus'
id 'checkstyle'
alias libs.plugins.quarkus
}


dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation enforcedPlatform(libs.quarkus.platform.bom)
implementation project(":my-core")
implementation project(":my-platform")
// implementation project(":my-msg")
Expand Down
9 changes: 2 additions & 7 deletions my-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
plugins {
id 'java'
id 'java-library'
id 'org.kordamp.gradle.jandex' version '2.0.0'
id 'checkstyle'
id 'configure-jandex'
}


dependencies {
api enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
api enforcedPlatform(libs.quarkus.platform.bom)

api project(':my-database')

api 'io.quarkus:quarkus-rest'
api 'io.quarkus:quarkus-arc'
api 'io.quarkus:quarkus-rest-jackson'


testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}

tasks.named('checkstyleMain').configure {
dependsOn 'jandex'
}
8 changes: 2 additions & 6 deletions my-database-standard/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
plugins {
id 'java'
id 'java-library'
id 'org.kordamp.gradle.jandex' version '2.0.0'
id 'checkstyle'
id 'configure-jandex'
}


dependencies {
api enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
api enforcedPlatform(libs.quarkus.platform.bom)
implementation project(':my-database')

api "io.quarkus:quarkus-jdbc-postgresql"
}

tasks.named('checkstyleMain').configure {
dependsOn 'jandex'
}
6 changes: 1 addition & 5 deletions my-database-uni/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
plugins {
id 'java'
id 'org.kordamp.gradle.jandex' version '2.0.0'
id 'checkstyle'
id 'configure-jandex'
}


dependencies {
implementation project(':my-database')
// implementation project(':my-core-uni')
}

tasks.named('checkstyleMain').configure {
dependsOn 'jandex'
}
2 changes: 1 addition & 1 deletion my-database/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {


dependencies {
api enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
api enforcedPlatform(libs.quarkus.platform.bom)
// implementation project(':my-core')
// implementation project(':my-core-uni')

Expand Down
6 changes: 1 addition & 5 deletions my-platform/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.kordamp.gradle.jandex' version '2.0.0'
id 'checkstyle'
id 'configure-jandex'
}


Expand All @@ -10,7 +10,3 @@ dependencies {
implementation project(':my-database-standard')
// implementation project(':my-core-uni')
}

tasks.named('checkstyleMain').configure {
dependsOn 'jandex'
}
11 changes: 0 additions & 11 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenLocal()
}
plugins {
id "${quarkusPluginId}" version "${quarkusPluginVersion}"
}
}

plugins {
id "com.gradle.develocity" version "3.17.5"
}
Expand Down

0 comments on commit 5343c81

Please sign in to comment.