-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #2730 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 重构项目结构 ```
- Loading branch information
Showing
715 changed files
with
596 additions
and
466 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
console | ||
.github | ||
.git |
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
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
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'maven-publish' | ||
id "io.freefair.lombok" version "8.0.0-rc2" | ||
} | ||
|
||
group = 'run.halo.app' | ||
description = 'API of halo project, connecting by other projects.' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
api platform(project(':platform:application')) | ||
|
||
api 'org.springframework.boot:spring-boot-starter-actuator' | ||
api 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
api 'org.springframework.boot:spring-boot-starter-mail' | ||
api 'org.springframework.boot:spring-boot-starter-thymeleaf' | ||
api 'org.springframework.boot:spring-boot-starter-webflux' | ||
api 'org.springframework.boot:spring-boot-starter-validation' | ||
api 'org.springframework.boot:spring-boot-starter-data-r2dbc' | ||
|
||
// Spring Security | ||
api 'org.springframework.boot:spring-boot-starter-security' | ||
api 'org.springframework.security:spring-security-oauth2-jose' | ||
api 'org.springframework.security:spring-security-oauth2-client' | ||
api 'org.springframework.security:spring-security-oauth2-resource-server' | ||
|
||
api "org.springdoc:springdoc-openapi-starter-webflux-ui" | ||
api 'org.openapi4j:openapi-schema-validator' | ||
api "net.bytebuddy:byte-buddy" | ||
|
||
// Apache Lucene | ||
api "org.apache.lucene:lucene-core" | ||
api "org.apache.lucene:lucene-queryparser" | ||
api "org.apache.lucene:lucene-highlighter" | ||
api "org.apache.lucene:lucene-backward-codecs" | ||
api 'cn.shenyanchao.ik-analyzer:ik-analyzer' | ||
|
||
api "org.apache.commons:commons-lang3" | ||
api "io.seruco.encoding:base62" | ||
api "org.pf4j:pf4j" | ||
api "com.google.guava:guava" | ||
api "org.jsoup:jsoup" | ||
api "io.github.java-diff-utils:java-diff-utils" | ||
api "org.springframework.integration:spring-integration-core" | ||
api "com.github.java-json-tools:json-patch" | ||
api "org.thymeleaf.extras:thymeleaf-extras-springsecurity6" | ||
|
||
runtimeOnly 'io.r2dbc:r2dbc-h2' | ||
runtimeOnly 'org.postgresql:postgresql' | ||
runtimeOnly 'org.postgresql:r2dbc-postgresql' | ||
runtimeOnly 'org.mariadb:r2dbc-mariadb' | ||
runtimeOnly 'com.github.jasync-sql:jasync-r2dbc-mysql' | ||
|
||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.springframework.security:spring-security-test' | ||
testImplementation 'io.projectreactor:reactor-test' | ||
} | ||
|
||
java { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
publishing { | ||
publications { | ||
library(MavenPublication) { | ||
from components.java | ||
} | ||
} | ||
repositories { | ||
mavenLocal() | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
api/src/main/java/run/halo/app/core/extension/Counter.java
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package run.halo.app.core.extension; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import run.halo.app.extension.AbstractExtension; | ||
import run.halo.app.extension.GVK; | ||
import run.halo.app.extension.Metadata; | ||
|
||
/** | ||
* A counter for number of requests by extension resource name. | ||
* | ||
* @author guqing | ||
* @since 2.0.0 | ||
*/ | ||
@Data | ||
@GVK(group = "metrics.halo.run", version = "v1alpha1", kind = "Counter", plural = "counters", | ||
singular = "counter") | ||
@EqualsAndHashCode(callSuper = true) | ||
public class Counter extends AbstractExtension { | ||
|
||
private Integer visit; | ||
|
||
private Integer upvote; | ||
|
||
private Integer downvote; | ||
|
||
private Integer totalComment; | ||
|
||
private Integer approvedComment; | ||
|
||
public static Counter emptyCounter(String name) { | ||
Counter counter = new Counter(); | ||
counter.setMetadata(new Metadata()); | ||
counter.getMetadata().setName(name); | ||
counter.setUpvote(0); | ||
counter.setTotalComment(0); | ||
counter.setApprovedComment(0); | ||
counter.setVisit(0); | ||
return counter; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.