Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor project structure for a better development #3552

Merged
merged 9 commits into from
Mar 23, 2023

Conversation

JohnNiang
Copy link
Member

@JohnNiang JohnNiang commented Mar 21, 2023

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:

./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:

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?

重构项目结构以支持发布插件所需的依赖。

Signed-off-by: John Niang <johnniang@fastmail.com>
@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. area/core Issues or PRs related to the Halo Core labels Mar 21, 2023
@f2c-ci-robot f2c-ci-robot bot requested review from Aanko and minliacom March 21, 2023 15:59
Signed-off-by: John Niang <johnniang@fastmail.com>
@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #3552 (76cf602) into main (7ca5270) will decrease coverage by 1.98%.
The diff coverage is 58.73%.

@@             Coverage Diff              @@
##               main    #3552      +/-   ##
============================================
- Coverage     61.72%   59.75%   -1.98%     
+ Complexity     2572     2188     -384     
============================================
  Files           408      337      -71     
  Lines         12921    11273    -1648     
  Branches       1026      837     -189     
============================================
- Hits           7976     6736    -1240     
+ Misses         4458     4132     -326     
+ Partials        487      405      -82     
Impacted Files Coverage Δ
...cation/src/main/java/run/halo/app/Application.java 20.00% <ø> (ø)
...run/halo/app/actuator/DatabaseInfoContributor.java 20.00% <ø> (ø)
...java/run/halo/app/actuator/GlobalInfoEndpoint.java 1.56% <ø> (ø)
...va/run/halo/app/config/ExtensionConfiguration.java 66.66% <ø> (ø)
...p/config/HaloAnonymousAuthenticationWebFilter.java 27.27% <ø> (ø)
...in/java/run/halo/app/config/HaloConfiguration.java 100.00% <ø> (ø)
...c/main/java/run/halo/app/config/SwaggerConfig.java 100.00% <ø> (ø)
...c/main/java/run/halo/app/config/WebFluxConfig.java 72.41% <ø> (ø)
...a/run/halo/app/config/WebServerSecurityConfig.java 94.11% <ø> (ø)
.../java/run/halo/app/console/ConsoleProxyFilter.java 0.00% <ø> (ø)
... and 174 more

... and 379 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@guqing
Copy link
Member

guqing commented Mar 22, 2023

需要将下列 utils 放入 api 模块:

  • run.halo.app.infra.utils.PathUtils
  • run.halo.app.infra.utils.JsonUtils

还需要将 core/extension 下的那些 extension 放进来比如 Post、SinglePage、Comment 等,以及依赖到 infra 下的 ConditionList、ConditionStatus 等

还需要将下列类放进去

  • run.halo.app.infra.ExternalUrlSupplier
  • run.halo.app.infra.SystemSetting
  • run.halo.app.infra.SystemVersionSupplier

@guqing
Copy link
Member

guqing commented Mar 22, 2023

api platform(project(':platform:application')) 貌似应该声明在 constraints 里面,否则在插件无法通过implementation platform('run.halo.tools.platform:plugin:2.4.0-SNAPSHOT')使用

Could not resolve: run.halo.tools.platform:plugin:2.4.0-SNAPSHOT

@guqing
Copy link
Member

guqing commented Mar 22, 2023

期望插件中可以引入一个依赖然后自动包含所有 halo 引入过的依赖 并且 scope 为 provide/compileOnly 这样插件可以直接使用且不会打包到插件中

Copy link
Member

@guqing guqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 23, 2023
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Mar 23, 2023
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing, ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot merged commit c400c85 into halo-dev:main Mar 23, 2023
@JohnNiang JohnNiang deleted the refactor/project-structure branch March 23, 2023 08:07
@ruibaby ruibaby added this to the 2.4.0 milestone Mar 27, 2023
f2c-ci-robot bot pushed a commit that referenced this pull request Mar 27, 2023
#### What type of PR is this?

/kind bug
/area console

#### What this PR does / why we need it:

修正 Console 构建的输出目录,此问题由 #3552 导致。

#### Does this PR introduce a user-facing change?

```release-note
None
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

将 Halo 的 bootJar 和 plainJar 发布到 maven 中央仓库
3 participants