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

优化排包配置 #918

Merged
merged 12 commits into from
May 5, 2024
Merged

优化排包配置 #918

merged 12 commits into from
May 5, 2024

Conversation

gaosaroma
Copy link
Collaborator

@gaosaroma gaosaroma commented Apr 30, 2024

Motivation

优化排包配置

Modification

Describe the idea and modifications you've done.

Result

fix koupleless/koupleless#117

Summary by CodeRabbit

  • New Features

    • Introduced YAML-based configuration for artifact exclusions in the Ark Maven plugin.
    • Added properties-based configuration for specifying exclusions in artifact dependencies.
  • Enhancements

    • Enhanced the Ark Maven plugin to support exclusion of artifacts both from properties and YAML files.
  • Bug Fixes

    • Implemented fixes in the RepackageMojo class to ensure correct parsing and application of exclusion rules.
  • Tests

    • Added new tests to validate the functionality of artifact exclusions in the Ark Maven plugin.

Copy link
Contributor

coderabbitai bot commented Apr 30, 2024

Walkthrough

The update focuses on optimizing the configuration of dependency exclusions in the SOFA Ark Maven plugin by introducing standardized methods through properties and YAML files. This aims to enhance consistency in configurations and resolve issues related to discrepancies in directory handling during setup and configuration parsing.

Changes

File Path Change Summary
sofa-ark-bom/pom.xml Added dependency on snakeyaml v2.1
sofa-ark-parent/.../ark-maven-plugin/pom.xml Added dependency on snakeyaml
.../RepackageMojo.java Added imports, constants, and methods for parsing configurations
.../RepackageMojoTest.java Updated imports, added a new test method
.../ark.properties, ark.yml Added new files for exclusion configurations

Assessment against linked issues

Objective Addressed Explanation
Optimize auto-exclusion packaging configuration (#117) The changes enhance the handling of dependency exclusions, ensuring better configuration consistency and addressing issues with directory placement discrepancies.

🐰🎉 A Poem by CodeRabbit 🎉🐰
In the realm of code, where changes unfold,
A rabbit danced, scripts retold.
YAML and props in harmony bind,
Chaos dispelled, order refined.
Paths now clear, in Maven's light,
A symphony of code, neat and right. 🌟📂


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.59%. Comparing base (1bf4217) to head (8a11e90).
Report is 11 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #918      +/-   ##
============================================
- Coverage     78.70%   78.59%   -0.12%     
- Complexity      836      850      +14     
============================================
  Files           164      167       +3     
  Lines          6796     6866      +70     
  Branches       1009     1016       +7     
============================================
+ Hits           5349     5396      +47     
- Misses          923      945      +22     
- Partials        524      525       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (2)
sofa-ark-parent/support/ark-maven-plugin/src/test/resources/baseDir/src/main/resources/ark.properties (1)

1-6: Ensure the comments are translated to English to maintain consistency in codebase documentation.

sofa-ark-parent/support/ark-maven-plugin/src/test/resources/baseDir/src/main/resources/ark.yml (1)

1-10: Ensure the comments are translated to English to maintain consistency in codebase documentation.

@lvjing2
Copy link
Collaborator

lvjing2 commented Apr 30, 2024

  1. 原来的 rules.txt 保留
  2. koupleless 官网用户使用文档需要更新

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Comment on lines +646 to +673
protected void extensionExcludeArtifactsFromProp() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_PROPERTIES_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
return;
}

getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));

Properties prop = new Properties();
try (FileInputStream fis = new FileInputStream(configPath)) {
prop.load(fis);

parseExcludeProp(excludes, prop, EXTENSION_EXCLUDES);
parseExcludeProp(excludeGroupIds, prop, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeProp(excludeArtifactIds, prop, EXTENSION_EXCLUDES_ARTIFACTIDS);
} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Method extensionExcludeArtifactsFromProp effectively handles properties file for artifact exclusion. Consider adding a debug log before returning when the config file does not exist for better traceability.

652a653
>             getLog().debug("Config file does not exist: " + configPath);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
protected void extensionExcludeArtifactsFromProp() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_PROPERTIES_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
return;
}
getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));
Properties prop = new Properties();
try (FileInputStream fis = new FileInputStream(configPath)) {
prop.load(fis);
parseExcludeProp(excludes, prop, EXTENSION_EXCLUDES);
parseExcludeProp(excludeGroupIds, prop, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeProp(excludeArtifactIds, prop, EXTENSION_EXCLUDES_ARTIFACTIDS);
} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}
protected void extensionExcludeArtifactsFromProp() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_PROPERTIES_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
getLog().debug("Config file does not exist: " + configPath);
return;
}
getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));
Properties prop = new Properties();
try (FileInputStream fis = new FileInputStream(configPath)) {
prop.load(fis);
parseExcludeProp(excludes, prop, EXTENSION_EXCLUDES);
parseExcludeProp(excludeGroupIds, prop, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeProp(excludeArtifactIds, prop, EXTENSION_EXCLUDES_ARTIFACTIDS);
} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}

Comment on lines +675 to +702
protected void extensionExcludeArtifactsFromYaml() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_YML_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
return;
}

getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));

try (FileInputStream fis = new FileInputStream(configPath)) {
Yaml yaml = new Yaml();
Map<String, List<String>> parsedYaml = yaml.load(fis);
parseExcludeYaml(excludes, parsedYaml, EXTENSION_EXCLUDES);
parseExcludeYaml(excludeGroupIds, parsedYaml, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeYaml(excludeArtifactIds, parsedYaml, EXTENSION_EXCLUDES_ARTIFACTIDS);

} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Method extensionExcludeArtifactsFromYaml is well-implemented for parsing YAML configurations. Similar to the previous method, consider adding a debug log for missing config files.

681a682
>             getLog().debug("Config file does not exist: " + configPath);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
protected void extensionExcludeArtifactsFromYaml() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_YML_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
return;
}
getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));
try (FileInputStream fis = new FileInputStream(configPath)) {
Yaml yaml = new Yaml();
Map<String, List<String>> parsedYaml = yaml.load(fis);
parseExcludeYaml(excludes, parsedYaml, EXTENSION_EXCLUDES);
parseExcludeYaml(excludeGroupIds, parsedYaml, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeYaml(excludeArtifactIds, parsedYaml, EXTENSION_EXCLUDES_ARTIFACTIDS);
} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}
protected void extensionExcludeArtifactsFromYaml() {
String configPath = baseDir + File.separator + RESOURCES_DIR + File.separator
+ ARK_YML_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
String.format(
"sofa-ark-maven-plugin: extension-config %s not found, will not config it",
configPath));
getLog().debug("Config file does not exist: " + configPath);
return;
}
getLog().info(
String.format("sofa-ark-maven-plugin: find extension-config %s and will config it",
configPath));
try (FileInputStream fis = new FileInputStream(configPath)) {
Yaml yaml = new Yaml();
Map<String, List<String>> parsedYaml = yaml.load(fis);
parseExcludeYaml(excludes, parsedYaml, EXTENSION_EXCLUDES);
parseExcludeYaml(excludeGroupIds, parsedYaml, EXTENSION_EXCLUDES_GROUPIDS);
parseExcludeYaml(excludeArtifactIds, parsedYaml, EXTENSION_EXCLUDES_ARTIFACTIDS);
} catch (IOException ex) {
getLog().error(
String.format("failed to parse excludes artifacts from %s.", configPath), ex);
}
}

+ ARK_PROPERTIES_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
Copy link
Collaborator

Choose a reason for hiding this comment

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

warn 级别

+ ARK_YML_FILE;
File configFile = com.alipay.sofa.ark.common.util.FileUtils.file(configPath);
if (!configFile.exists()) {
getLog().info(
Copy link
Collaborator

Choose a reason for hiding this comment

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

warn 级别

@lvjing2
Copy link
Collaborator

lvjing2 commented May 5, 2024

Others LGTM

@lvjing2 lvjing2 merged commit 5a13e01 into sofastack:master May 5, 2024
6 of 7 checks passed
lvjing2 pushed a commit that referenced this pull request May 27, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

* 优化自动排包配置

* 更新排包描述

---------

Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 5a13e01)
lvjing2 added a commit that referenced this pull request May 27, 2024
* 优化排包配置 (#918)

* 优化显示

* fix as bizStateRecords

* 更新显示

* 优化自动排包配置

* 更新排包描述

---------

Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 5a13e01)

* runtime中静态合并部署时多模块并行执行createTempDir时异常 (#911)

Co-authored-by: jiyunfei <jiyunfei@come-future.com>
Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 67a0bdf)

* add string contains (#926)

(cherry picked from commit 07009d7)

* fix ReactiveWebServerFactoryAutoConfiguration not support sprintboot 1.x (#927)

(cherry picked from commit 41d3cda)

* add biz jar url in biz module (#928)

(cherry picked from commit e1f5872)

* update netty version (#931)

* update netty version

* fix version netty

---------

Co-authored-by: tangjiafu <tangjiafu@kuaishou.com>
Co-authored-by: leojames <leojames.googol@gmail.com>

(cherry picked from commit fb233cf)

* update version to 3.0.6-SNAPSHOT

---------

Co-authored-by: Lipeng <44571204+gaosaroma@users.noreply.github.com>
Co-authored-by: FFF <31267018+1034323716@users.noreply.github.com>
Co-authored-by: Laglangyue <35491928+laglangyue@users.noreply.github.com>
lvjing2 pushed a commit that referenced this pull request May 27, 2024
* 优化显示

* fix as bizStateRecords

* 更新显示

* 优化自动排包配置

* 更新排包描述

---------

Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 5a13e01)
lvjing2 added a commit that referenced this pull request May 28, 2024
* 优化排包配置 (#918)

* 优化显示

* fix as bizStateRecords

* 更新显示

* 优化自动排包配置

* 更新排包描述

---------

Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 5a13e01)

* runtime中静态合并部署时多模块并行执行createTempDir时异常 (#911)

Co-authored-by: jiyunfei <jiyunfei@come-future.com>
Co-authored-by: leo james <leojames.googol@gmail.com>
(cherry picked from commit 67a0bdf)

* add string contains (#926)

(cherry picked from commit 07009d7)

* fix ReactiveWebServerFactoryAutoConfiguration not support sprintboot 1.x (#927)

(cherry picked from commit 41d3cda)

* add biz jar url in biz module (#928)

(cherry picked from commit e1f5872)

* update netty version (#931)

* update netty version

* fix version netty

---------

Co-authored-by: tangjiafu <tangjiafu@kuaishou.com>
Co-authored-by: leojames <leojames.googol@gmail.com>

(cherry picked from commit fb233cf)

* update version to 3.1.4-SNAPSHOT

* fix multi ark boot runner test

---------

Co-authored-by: Lipeng <44571204+gaosaroma@users.noreply.github.com>
Co-authored-by: FFF <31267018+1034323716@users.noreply.github.com>
Co-authored-by: Laglangyue <35491928+laglangyue@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

优化自动排包的配置方式
2 participants