halo/application/build.gradle

156 lines
4.3 KiB
Groovy
Raw Normal View History

import de.undercouch.gradle.tasks.download.Download
import org.gradle.crypto.checksum.Checksum
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id "com.gorylenko.gradle-git-properties"
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
id "checkstyle"
id 'java'
id 'jacoco'
id "de.undercouch.download"
id "io.freefair.lombok"
id 'org.gradle.crypto.checksum'
id 'org.springdoc.openapi-gradle-plugin'
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
}
group = 'run.halo.app'
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
checkstyle {
toolVersion = "9.3"
showViolations = false
ignoreFailures = false
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
springBoot {
buildInfo {
properties {
artifact = 'halo'
name = 'halo'
}
}
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
}
bootJar {
archiveBaseName = 'halo'
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
manifest {
attributes 'Implementation-Title': 'Halo Application',
'Implementation-Vendor': 'Halo OSS Team'
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
}
}
tasks.named('jar') {
enabled = false
}
dependencies {
implementation project(':api')
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
annotationProcessor "org.springframework:spring-context-indexer"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'io.projectreactor:reactor-test'
}
tasks.register('createChecksums', Checksum) {
dependsOn tasks.named('bootJar')
inputFiles.setFrom(layout.buildDirectory.files('libs'))
outputDirectory = layout.buildDirectory.dir("libs")
checksumAlgorithm = Checksum.Algorithm.SHA256
}
tasks.named('processResources', ProcessResources) {
from project(':ui').layout.buildDirectory.dir('dist')
into layout.buildDirectory.dir('resources/main')
configure {
mustRunAfter project(':ui').tasks.named('build')
}
}
tasks.named('build') {
dependsOn tasks.named('createChecksums')
}
tasks.named('test', Test) {
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
useJUnitPlatform()
finalizedBy jacocoTestReport
}
tasks.named('jacocoTestReport', JacocoReport) {
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
reports {
xml.required = true
html.required = false
}
}
ext.presetPluginUrls = [
'https://github.com/halo-dev/plugin-comment-widget/releases/download/v2.1.0/plugin-comment-widget-2.1.0.jar' : 'plugin-comment-widget.jar',
'https://github.com/halo-dev/plugin-search-widget/releases/download/v1.4.0/plugin-search-widget-1.4.0.jar' : 'plugin-search-widget.jar',
'https://github.com/halo-dev/plugin-sitemap/releases/download/v1.1.1/plugin-sitemap-1.1.1.jar' : 'plugin-sitemap.jar',
'https://github.com/halo-dev/plugin-feed/releases/download/v1.2.2/plugin-feed-1.2.2.jar' : 'plugin-feed.jar',
// Currently, plugin-app-store is not open source, so we need to download it from the official website.
// Please see https://github.com/halo-dev/plugin-app-store/issues/55
// https://www.halo.run/store/apps/app-VYJbF
'https://www.halo.run/store/apps/app-VYJbF/releases/download/app-release-yfjXe/assets/app-release-yfjXe-kOzZZ': 'appstore.jar',
]
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
tasks.register('downloadPluginPresets', Download) {
doFirst {
delete 'src/main/resources/presets/plugins'
}
src presetPluginUrls.keySet()
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
dest 'src/main/resources/presets/plugins'
eachFile { f ->
f.name = presetPluginUrls[f.sourceURL.toString()]
}
Refactor project structure for a better development (#3552) #### What type of PR is this? /kind cleanup /area core #### What this PR does / why we need it: This PR totally refactor project structure for a better plugin development. Now we can maintain and publish api and platform modules at Halo application side, which will be references by plugins. Currently, we can execute command `./gradlew clean publish` to publish api and platform modules into **local** Maven repository, so that we can refer these dependencies (`run.halo.tools.platform:plugin:2.4.0-SNAPSHOT` and `run.halo.app:api:2.4.0-SNAPSHOT`) in plugin projects. I will make another pull request to publish api library and platforms into Maven central repository. **Modules explanation**: - API module contains common classes which might be used by plugins. - Plugin Platform module contains dependency declarations of other plugin API modules. - Application Platform module contains dependency declarations application module might uses. If we want to build application only(exclude check and jar), we have to execute the command below: ```bash ./gradlew clean :application:build -x :application:check -x :application:jar ``` The executable Jar will be generated at folder `application/build/libs/`. If we want to build a Docker image, we could execute the command below: ```bash docker build -t johnniang/halo:project-structure . # Test the Docker image docker run -it --rm -p8090:8090 johnniang/halo:project-structure ``` #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
2023-03-23 08:02:33 +00:00
}
openApi {
outputDir = file("$rootDir/api-docs/openapi/v3_0")
groupedApiMappings = [
'http://localhost:8091/v3/api-docs/all-api': 'aggregated.json',
]
customBootRun {
args = ['--server.port=8091',
'--spring.profiles.active=doc',
"--halo.work-dir=${layout.buildDirectory.get()}/tmp/workdir-for-generating-apidocs"]
}
}
tasks.named('forkedSpringBootRun') {
dependsOn ':api:jar'
}
tasks.named('generateOpenApiDocs') {
outputs.upToDateWhen {
false
}
}