A dependency reconstruction method, device, apparatus and storage medium

By generating lossless semantic trees and automating dependency processing, the problem of low efficiency in software project dependency management is solved, version consistency and compatibility are achieved, configuration files are simplified, maintenance costs are reduced, and security is enhanced.

CN122489115APending Publication Date: 2026-07-31BEIJING BAIJU YIXING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING BAIJU YIXING TECH CO LTD
Filing Date
2026-03-24
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, software project dependency management is inefficient, modifications to management rules involve core code, and it has poor scalability, making it difficult to guarantee version consistency and compatibility.

Method used

It generates a lossless semantic tree by parsing the project configuration file, modifies the dependency configuration relationship based on the preset rule set, automatically removes redundant versions, and supports preview and persistence operations.

Benefits of technology

It improves dependency management efficiency, ensures version consistency and compatibility, simplifies configuration files, reduces maintenance costs, and enhances operational security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489115A_ABST
    Figure CN122489115A_ABST
Patent Text Reader

Abstract

This application discloses a dependency refactoring method, apparatus, device, and storage medium, relating to the field of software maintenance or management technology. The method includes: parsing a project's configuration file to obtain a lossless semantic tree corresponding to the configuration file, and identifying and determining the project's current dependency configuration relationships based on the lossless semantic tree; modifying the dependency configuration relationships in the lossless semantic tree according to a set of preset rules configured in the second node of the configuration file; obtaining a preset command, and feeding back the dependency refactoring result corresponding to the preset command based on the modified dependency configuration relationships. Implementing the above dependency refactoring method achieves non-intrusive configuration parsing through a lossless semantic tree, supports external rule injection, and provides a secure and controllable execution mode, avoiding accidental modifications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software maintenance or management technology, and in particular to a dependency reconstruction method, apparatus, device and storage medium. Background Technology

[0002] As software development becomes increasingly complex, and with the rise of microservice architectures and large-scale projects, software projects typically rely on numerous external libraries and frameworks. This necessitates declaring the external libraries a project depends on in the project file as dependency configuration, and managing these dependencies to ensure project stability, security, and maintainability. Currently, dependency management is done on a project-by-project basis, resulting in low efficiency; modifications to management rules involve changes to core code, leading to poor scalability. Summary of the Invention

[0003] To address the shortcomings mentioned in the background art, this application provides the following technical solution: Firstly, a dependency refactoring method is provided, including: Parse the project's configuration file to obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file; Based on the set of preset rules configured in the second node of the configuration file, modify the dependency configuration relationship in the lossless semantic tree; Retrieve preset commands and, based on the modified dependency configuration, return the dependency refactoring results corresponding to the preset commands.

[0004] Furthermore, based on the preset rule set configured in the second node of the configuration file, the dependency configuration relationships in the lossless semantic tree are modified, including: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version; For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to the preset rule set. Remove redundant versions of dependency configuration relationships from the lossless semantic tree.

[0005] Furthermore, the parent nodes in the lossless semantic tree are traversed, and the version field corresponding to the parent node is updated to the preset version, including: Locate any parent node in the lossless semantic tree; Verify that the organization space identifier in the parent node is the preset organization space identifier, and verify that the component name in the parent node is the preset component name; Replace the version field in the parent node with the preset version; Return the updated lossless semantic tree for use in subsequent steps.

[0006] Furthermore, for the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to a preset set of rules, including: Check if a dependency management node exists in the lossless semantic tree; Construct a dependency structure in a predefined format; Insert the dependency structure into the dependency management node; Returns a lossless semantic tree of the inserted dependency structure for use in subsequent steps.

[0007] Furthermore, redundant versions of dependency configuration relationships are removed from the lossless semantic tree, including: Extract dependency configuration relationships from the lossless semantic tree to form a dependency set; Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; Remove redundant versions from the lossless semantic tree.

[0008] Furthermore, it retrieves preset commands and, based on the modified dependency configuration relationships, returns the dependency refactoring results corresponding to the preset commands, including: Obtain preset commands, wherein the preset commands include at least: a first command and a second command, the first command being used to preview the dependency refactoring results, and the second command being used to persist the dependency refactoring results; If the default command is set to the first command, the dependency refactoring results will be displayed. If the default command is the second command, then the dependency refactoring results are saved.

[0009] Furthermore, before parsing the project's configuration file, the following steps are also included: Declare the organization space identifier, component name, and component version number under the first node of the configuration file; Configure a set of preset rules under the second node of the configuration file.

[0010] Secondly, a dependency reconstruction apparatus is provided, comprising: The parsing module is used to parse the project's configuration files, obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file. The rule configuration module is used to modify the dependency configuration relationship in the lossless semantic tree according to the preset rule set configured in the second node of the configuration file; The refactoring module is used to obtain preset commands and, based on the modified dependency configuration relationships, return the dependency refactoring results corresponding to the preset commands.

[0011] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the dependency refactoring method described in the first aspect when executing the computer program.

[0012] Fourthly, a computer-readable storage medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the dependency refactoring method described in the first aspect is implemented.

[0013] Fifthly, a computer program product is provided, including a computer program that, when executed by a processor, implements the dependency refactoring method described in the first aspect.

[0014] The beneficial effects of the technical solution provided in this application are as follows: By implementing the dependency refactoring method disclosed in this application, a Maven project dependency automated refactoring method based on declarative rules, configurable, previewable, precise and secure is provided. It generates a lossless semantic tree by parsing configuration files, executes a standardized management process in memory from upgrading the parent template to cleaning up redundant versions, and supports previewing or persisting results by command. This improves dependency management efficiency, transforming project-by-project modifications into a one-time configuration and batch execution process; ensures version consistency and compatibility, eliminating the "multiple versions of the same component" problem; by automatically removing redundant versions, it makes the pom.xml file concise, readable, and easy to maintain, reducing configuration maintenance costs; through target validation and preview mechanisms, it avoids accidental changes to production configurations, enhancing operational security; adding new management rules only requires developing new rules and... <activerecipes>The declaration can be made in the middle without modifying the core engine, and it supports flexible expansion. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a schematic diagram of a dependency refactoring method provided in an embodiment of this application; Figure 2 This is a schematic diagram of a dependency reconstruction device provided in an embodiment of this application; Figure 3 This is a schematic diagram of a computer device provided in an embodiment of this application. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0018] Unless otherwise defined, the technical or scientific terms used in this disclosure shall have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms "first," "second," and similar terms used in this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "an," "a," or "the" and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The numbers in the accompanying drawings are only used to distinguish individual functional parts or modules and do not indicate logical relationships between parts or modules. The terms "including" or "comprising" and similar terms mean that the element or object preceding the term encompasses the element or object listed following the term and its equivalents, without excluding other elements or objects. The terms "connected" or "linked" and similar terms are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Above," "below," "left," "right," etc., are used only to indicate relative positional relationships, and these relative positional relationships may change accordingly when the absolute position of the described object changes.

[0019] The various embodiments according to this disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that in the drawings, the same reference numerals are assigned to components having substantially the same or similar structure and function, and repeated descriptions of them will be omitted.

[0020] To address the shortcomings in current software project dependency management as mentioned in the background section, this application provides the following technical solution: In some embodiments, such as Figure 1 As shown, a dependency refactoring method includes: S100: Parse the project's configuration file to obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file.

[0021] S200: Modify the dependency configuration relationships in the lossless semantic tree based on the set of preset rules configured in the second node of the configuration file.

[0022] S300: Obtain the preset command and, based on the modified dependency configuration relationship, return the dependency refactoring result corresponding to the preset command.

[0023] A project refers to a software project, especially a microservices architecture or a large-scale project.

[0024] Configuration files, specifically Maven configuration files, are used to define project dependencies, plugins, and build configurations. They are typically recorded in the pom.xml (Project Object Model, POM) file.

[0025] A lossless semantic tree (LST) is a structured in-memory representation generated after parsing a pom.xml file. It preserves all syntactic elements of the original file (including comments, whitespace, attribute order, etc.) and serves as the operational vehicle for automated refactoring. All modifications are applied to the LST, which can ultimately be serialized back to the original file format.

[0026] The second node refers to the preset plugin. <configuration>In <activerecipes>Its path can be represented as: <build> → <plugins> → <plugin> → <configuration> → <activerecipes>.

[0027] Preset rule sets refer to the rules that developers set in advance. <activerecipes>The fully qualified class name of one or more refactoring rules listed, such as com.yueyue.recipe.ChangeLeopardParentVersion. Each refactoring rule encapsulates a specific refactoring logic (e.g., upgrading the parent POM, cleaning up versions, etc.). Only explicitly declared refactoring rules will be executed during refactoring.

[0028] By implementing the above dependency reconstruction method, non-intrusive configuration parsing is achieved through lossless semantic trees, external rule injection is supported, and a safe and controllable execution mode is provided to avoid accidental modification.

[0029] Specifically, S200: Based on the preset rule set configured in the second node of the configuration file, modify the dependency configuration relationships in the lossless semantic tree, including: S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version.

[0030] S220: For the lossless semantic tree updated by the parent node, write the dependency structure into its dependency management node according to the preset rule set.

[0031] S230: Remove redundant versions of dependency configuration relationships in the lossless semantic tree.

[0032] The parent node refers to the node in pom.xml. <parent>This represents the parent POM configuration inherited by the project, and includes at least groupId, artifactId, and version. It's important to emphasize that "parent node" here is a Maven project model term, not a general parent element in an XML tree structure.

[0033] The dependency management node refers to the node in pom.xml. <dependencymanagement>It is used to centrally declare metadata such as the version and range of dependencies.

[0034] Dependency structure refers to a structure of type pom with scope import. <dependency>The structure, in its typical form, is as follows: <dependency> <groupid>com.yueyue< / groupid> <artifactid>wukong-infra-std-bom< / artifactid> <version>1.0.0-SNAPSHOT< / version> <type>pom< / type> <scope>import< / scope> < / dependency> Redundant version refers to <dependencies>One of the middle <dependency>Explicitly declared <version>A child node is considered if and only if the dependent's groupId:artifactId has already appeared. <dependencymanagement>When the managed dependencies are in, the <version>This is redundant and should be removed to achieve "maintain once, inherit everywhere".

[0035] By executing the specific implementation of modifying the dependency configuration relationship in the lossless semantic tree according to the preset rule set configured in the second node of the configuration file, version consistency and compatibility are ensured, and "version drift" or "conflict escalation" is avoided.

[0036] Specifically, S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version, including: S211: Locate any parent node in the lossless semantic tree; S212: Verify whether the organization space identifier in the parent node is the preset organization space identifier, and verify whether the component name in the parent node is the preset component name; S213: Replace the version field in the parent node with the preset version; S214: Return the updated lossless semantic tree for use in subsequent steps.

[0037] A component is an external library that is uniquely identified by its organizational space identifier and component name. For example, an external Java library can be uniquely identified by its groupId as the organizational space identifier and its artifactId as the component name.

[0038] The component name refers to the name of the component, such as "artifactId" mentioned earlier.

[0039] Before upgrading the parent POM, verify that its groupId and artifactId are the target template. This allows the upgrade to be performed only on the specified parent POM (e.g., com.leopard:leopard-parent), preventing accidental operations. It also improves the security and applicability of refactoring and supports batch governance of multiple projects without polluting non-target projects.

[0040] Specifically, S220: For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to a preset set of rules, including: S221: Check if a dependency management node exists in the lossless semantic tree; S222: Construct a dependency structure in a predefined form; S223: Insert the dependency structure into the dependency management node; S224: Return the lossless semantic tree of the inserted dependency structure for use in subsequent steps.

[0041] To illustrate, the following code implements "for the lossless semantic tree updated by the parent node, writing the dependency structure into its dependency management node according to a preset set of rules". <dependencymanagement> <dependencies> <dependency> <groupid>com.yueyue< / groupid> <artifactid>wukong-infra-std-bom< / artifactid> <version>1.0.0-SNAPSHOT< / version> <type>pom< / type> <scope>import< / scope> < / dependency> < / dependencies> < / dependencymanagement> <dependencymanagement>This indicates the start of dependency management configuration, used to centrally declare the area for dependency versions.

[0042] <dependencies>It includes all dependencies that are managed uniformly.

[0043] <dependency>Start managing a dependency.

[0044] <groupid>com.yueyue< / groupid> This indicates the publisher whose organization identifier is com.yueyue.

[0045] <artifactid>wukong-infra-std-bom< / artifactid> This is a unique identifier for the component name: wukong-infra-std-bom.

[0046] <version>1.0.0-SNAPSHOT< / version> This indicates the specific release version of SNAPSHOT, version 1.0.0-SNAPSHOT.

[0047] <type>pom< / type> , indicates a component of type pom.

[0048] <scope>import< / scope> The is a key marker indicating that the scope is import, meaning that this dependency is used to import BOM content.

[0049] < / dependency> This indicates the end of the dependency.

[0050] < / dependencies> This indicates the end of the dependency list.

[0051] < / dependencymanagement> This indicates the end of dependency management configuration.

[0052] Automatically create missing nodes (if none) <dependencymanagement>Then create a new one, ensuring the BOM format is compliant (type=pom, scope=import) so that it can be correctly resolved by Maven into a version source, and ensuring that BOM dependencies are correctly constructed and inserted. <dependencymanagement>middle.

[0053] Specifically, S230: Removes redundant versions of dependency configuration relationships in the lossless semantic tree, including: S231: Extract dependency configuration relationships from the lossless semantic tree and form a dependency set; S232: Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; S233: Remove redundant versions from the lossless semantic tree.

[0054] The code before and after execution is shown in comparison: Before execution: <dependencies> <dependency> <groupid>com.yueyue< / groupid> <artifactid>wukong-mq-client< / artifactid> <version> 1.3.1< / version> <!-- Redundant version --> < / dependency> < / dependencies> After execution: <dependencies> <dependency> <groupid>com.yueyue< / groupid> <artifactid>wukong-mq-client< / artifactid> <!-- The version node has been deleted --> < / dependency> < / dependencies> Based on dependency sets, explicit version declarations are accurately identified and removed. By eliminating configuration redundancy, "maintain once, inherit everywhere" is achieved, reducing maintenance costs and avoiding implicit conflicts caused by partial version overwriting.

[0055] Specifically, S300: Obtains preset commands and, based on the modified dependency configuration relationships, returns the dependency refactoring results corresponding to the preset commands, including: Obtain preset commands, wherein the preset commands include at least: a first command and a second command, the first command being used to preview the dependency refactoring results, and the second command being used to persist the dependency refactoring results; If the default command is set to the first command, the dependency refactoring results will be displayed. If the default command is the second command, then the dependency refactoring results are saved.

[0056] Preset commands refer to the commands executed based on the results of dependency refactoring. The first command instructs the system to compare the lossless semantic tree with the original file, output the differences, but not modify any file—that is, to implement "preview". The second command serializes the modified lossless semantic tree and overwrites the original pom.xml file to complete persistence—that is, to implement "save".

[0057] It offers two operation modes: "Preview" and "Run", allowing users to review changes before deciding whether to apply them.

[0058] Specifically, before parsing the project's configuration files, the following is also included: S000: Add a preset plugin to the configuration file.

[0059] Preset plugins refer to the Maven refactoring plugins provided by OpenRewrite. <build> <plugins>In it, you can declare its groupId, artifactId, and version; and in its <configuration>China passed <activerecipes>Enable specific rules.

[0060] Specifically, this includes: S010: Declare the organization space identifier, component name, and component version number under the first node of the configuration file; S020: Configure the preset rule set under the second node of the configuration file.

[0061] The first node refers to <build> <plugins>The `<project>` node is used to declare the Maven plugins used for project building.

[0062] To illustrate, the following code adds a preset plugin to the configuration file: <plugin> <groupid>org.openrewrite.maven< / groupid> <artifactid>rewrite-maven-plugin< / artifactid> <version> 6.4.0< / version> <configuration> <activerecipes> <recipe> < / recipe> <recipe>com.yueyue.recipe.ChangeLeopardParentVersion< / recipe> <recipe>com.yueyue.recipe.AddWukongBom< / recipe> < / activerecipes> < / configuration> < / plugin> pass <plugin>Declare a Maven plugin and begin the plugin configuration block.

[0063] <groupid>org.openrewrite.maven.RemoveRedundantDependencyVersions< / groupid> The organization identifier is declared as org.openrewrite.maven, and the plugin publisher is specified as OpenRewrite.

[0064] <artifactid>org.openrewrite.maven< / artifactid> The plugin name is declared as rewrite-maven-plugin, which introduces the Maven refactoring plugin for OpenRewrite.

[0065] <version> 6.4.0< / version> The version is set to 6.4.0 (illustrative) to lock the plugin version and ensure stable behavior.

[0066] pass <configuration>Start plugin configuration and enter the plugin runtime parameter settings.

[0067] <activerecipes>Enable the refactoring rule list and declare the specific rules to be activated in this refactoring.

[0068] <recipe>rewrite-maven-plugin< / recipe> Enable the rule to upgrade the parent POM version.

[0069] <recipe>com.yueyue.recipe.ChangeLeopardParentVersion< / recipe> For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to the preset rule set.

[0070] <recipe>com.yueyue.recipe.AddWukongBom< / recipe> Remove redundant versions of dependency configuration relationships from the lossless semantic tree.

[0071] < / activerecipes> End the refactoring rule list.

[0072] < / configuration> End plugin configuration.

[0073] < / plugin> End of plugin declaration.

[0074] By declaring and defining the activation of the refactoring system, on-demand activation can be achieved: different projects can enable different combinations of rules; rules and execution engines are decoupled, so that only the pom.xml configuration needs to be maintained, without writing any code.

[0075] This application discloses a dependency refactoring method, providing a declarative, configurable, previewable, precise, and secure automated Maven project dependency refactoring method. It generates a lossless semantic tree by parsing configuration files, executes a standardized management process in memory from upgrading the parent template to cleaning up redundant versions, and supports command-line previewing or persistence of results. This improves dependency management efficiency by transforming project-by-project modifications into a one-time configuration, batch execution process; ensures version consistency and compatibility, eliminating the "multiple versions of the same component" problem; automatically removes redundant versions, making the pom.xml file concise, readable, and easy to maintain, reducing configuration maintenance costs; and through target validation and preview mechanisms, avoids accidental changes to production configurations, enhancing operational security. Adding new management rules only requires developing new rules and... <activerecipes>The declaration can be made in the middle without modifying the core engine, and it supports flexible expansion.

[0076] It should be understood that, although org.openrewrite.maven.RemoveRedundantDependencyVersions The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0077] In other embodiments, such as Figure 1 As shown, a dependency reconstruction apparatus includes: The parsing module is used to parse the project's configuration files, obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file. The rule configuration module is used to modify the dependency configuration relationship in the lossless semantic tree according to the preset rule set configured in the second node of the configuration file; The refactoring module is used to obtain preset commands and, based on the modified dependency configuration relationships, return the dependency refactoring results corresponding to the preset commands.

[0078] For specific limitations regarding the dependency refactoring apparatus described above, please refer to the limitations on the dependency refactoring method above, which will not be repeated here. Each module in the aforementioned dependency refactoring apparatus can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0079] In other embodiments, such as Figure 2 Figure 3 As shown, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the dependency refactoring method described above. Specifically, it includes: S010: Declare the organization space identifier, component name, and component version number under the first node of the configuration file; S020: Configure the preset rule set under the second node of the configuration file.

[0080] S100: Parse the project's configuration file to obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file.

[0081] S200: Modify the dependency configuration relationships in the lossless semantic tree based on the set of preset rules configured in the second node of the configuration file.

[0082] S300: Obtain the preset command and, based on the modified dependency configuration relationship, return the dependency refactoring result corresponding to the preset command.

[0083] Specifically, S200: Based on the preset rule set configured in the second node of the configuration file, modify the dependency configuration relationships in the lossless semantic tree, including: S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version.

[0084] S220: For the lossless semantic tree updated by the parent node, write the dependency structure into its dependency management node according to the preset rule set.

[0085] S230: Remove redundant versions of dependency configuration relationships in the lossless semantic tree.

[0086] Specifically, S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version, including: S211: Locate any parent node in the lossless semantic tree; S212: Verify whether the organization space identifier in the parent node is the preset organization space identifier, and verify whether the component name in the parent node is the preset component name; S213: Replace the version field in the parent node with the preset version; S214: Return the updated lossless semantic tree for use in subsequent steps.

[0087] Specifically, S220: For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to a preset set of rules, including: S221: Check if a dependency management node exists in the lossless semantic tree; S222: Construct a dependency structure in a predefined form; S223: Insert the dependency structure into the dependency management node; S224: Return the lossless semantic tree of the inserted dependency structure for use in subsequent steps.

[0088] Specifically, S230: Removes redundant versions of dependency configuration relationships in the lossless semantic tree, including: S231: Extract dependency configuration relationships from the lossless semantic tree and form a dependency set; S232: Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; S233: Remove redundant versions from the lossless semantic tree.

[0089] Specifically, S300: Obtains preset commands and, based on the modified dependency configuration relationships, returns the dependency refactoring results corresponding to the preset commands, including: Obtain preset commands, wherein the preset commands include at least: a first command and a second command, the first command being used to preview the dependency refactoring results, and the second command being used to persist the dependency refactoring results; If the default command is set to the first command, the dependency refactoring results will be displayed. If the default command is the second command, then the dependency refactoring results are saved.

[0090] In other embodiments, a computer-readable storage medium stores a computer program that, when executed by a processor, implements the dependency refactoring method described above. Specifically, it includes: S010: Declare the organization space identifier, component name, and component version number under the first node of the configuration file; S020: Configure the preset rule set under the second node of the configuration file.

[0091] S100: Parse the project's configuration file to obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file.

[0092] S200: Modify the dependency configuration relationships in the lossless semantic tree based on the set of preset rules configured in the second node of the configuration file.

[0093] S300: Obtain the preset command and, based on the modified dependency configuration relationship, return the dependency refactoring result corresponding to the preset command.

[0094] Specifically, S200: Based on the preset rule set configured in the second node of the configuration file, modify the dependency configuration relationships in the lossless semantic tree, including: S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version.

[0095] S220: For the lossless semantic tree updated by the parent node, write the dependency structure into its dependency management node according to the preset rule set.

[0096] S230: Remove redundant versions of dependency configuration relationships in the lossless semantic tree.

[0097] Specifically, S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version, including: S211: Locate any parent node in the lossless semantic tree; S212: Verify whether the organization space identifier in the parent node is the preset organization space identifier, and verify whether the component name in the parent node is the preset component name; S213: Replace the version field in the parent node with the preset version; S214: Return the updated lossless semantic tree for use in subsequent steps.

[0098] Specifically, S220: For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to a preset set of rules, including: S221: Check if a dependency management node exists in the lossless semantic tree; S222: Construct a dependency structure in a predefined form; S223: Insert the dependency structure into the dependency management node; S224: Return the lossless semantic tree of the inserted dependency structure for use in subsequent steps.

[0099] Specifically, S230: Removes redundant versions of dependency configuration relationships in the lossless semantic tree, including: S231: Extract dependency configuration relationships from the lossless semantic tree and form a dependency set; S232: Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; S233: Remove redundant versions from the lossless semantic tree.

[0100] Specifically, S300: Obtains preset commands and, based on the modified dependency configuration relationships, returns the dependency refactoring results corresponding to the preset commands, including: Obtain preset commands, wherein the preset commands include at least: a first command and a second command, the first command being used to preview the dependency refactoring results, and the second command being used to persist the dependency refactoring results; If the default command is set to the first command, the dependency refactoring results will be displayed. If the default command is the second command, then the dependency refactoring results are saved.

[0101] In other embodiments, a computer program product includes a computer program that, when executed by a processor, implements the dependency refactoring method described above. Specifically, it includes: S010: Declare the organization space identifier, component name, and component version number under the first node of the configuration file; S020: Configure the preset rule set under the second node of the configuration file.

[0102] S100: Parse the project's configuration file to obtain the lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file.

[0103] S200: Modify the dependency configuration relationships in the lossless semantic tree based on the set of preset rules configured in the second node of the configuration file.

[0104] S300: Obtain the preset command and, based on the modified dependency configuration relationship, return the dependency refactoring result corresponding to the preset command.

[0105] Specifically, S200: Based on the preset rule set configured in the second node of the configuration file, modify the dependency configuration relationships in the lossless semantic tree, including: S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version.

[0106] S220: For the lossless semantic tree updated by the parent node, write the dependency structure into its dependency management node according to the preset rule set.

[0107] S230: Remove redundant versions of dependency configuration relationships in the lossless semantic tree.

[0108] Specifically, S210: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version, including: S211: Locate any parent node in the lossless semantic tree; S212: Verify whether the organization space identifier in the parent node is the preset organization space identifier, and verify whether the component name in the parent node is the preset component name; S213: Replace the version field in the parent node with the preset version; S214: Return the updated lossless semantic tree for use in subsequent steps.

[0109] Specifically, S220: For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to a preset set of rules, including: S221: Check if a dependency management node exists in the lossless semantic tree; S222: Construct a dependency structure in a predefined form; S223: Insert the dependency structure into the dependency management node; S224: Return the lossless semantic tree of the inserted dependency structure for use in subsequent steps.

[0110] Specifically, S230: Removes redundant versions of dependency configuration relationships in the lossless semantic tree, including: S231: Extract dependency configuration relationships from the lossless semantic tree and form a dependency set; S232: Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; S233: Remove redundant versions from the lossless semantic tree.

[0111] Specifically, S300: Obtains preset commands and, based on the modified dependency configuration relationships, returns the dependency refactoring results corresponding to the preset commands, including: Obtain preset commands, wherein the preset commands include at least: a first command and a second command, the first command being used to preview the dependency refactoring results, and the second command being used to persist the dependency refactoring results; If the default command is set to the first command, the dependency refactoring results will be displayed. If the default command is the second command, then the dependency refactoring results are saved.

[0112] By implementing the dependency refactoring method, apparatus, device, and storage medium disclosed in the embodiments of this application, a method for automated dependency refactoring of Maven projects based on declarative rules, configurable, previewable, precise, and secure is provided. This method generates a lossless semantic tree by parsing configuration files, executes a standardized management process in memory from upgrading the parent template to cleaning up redundant versions, and supports previewing or persisting results by command. It improves dependency management efficiency by transforming project-by-project modifications into a one-time configuration and batch execution process; ensures version consistency and compatibility, eliminating the "multiple versions of the same component" problem; automatically removes redundant versions, making the pom.xml file concise, readable, and easy to maintain, reducing configuration maintenance costs; and through target validation and preview mechanisms, avoids accidental changes to production configurations, enhancing operational security. Adding new management rules only requires developing new rules and... <activerecipes>The declaration can be made in the middle without modifying the core engine, and it supports flexible expansion.

[0113] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.

[0114] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program loaded on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from memory, or installed from ROM. When the computer program is executed by an external processor, it performs the functions defined in the methods of embodiments of this application.

[0115] It should be noted that the computer-readable medium in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the embodiments of this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (Radio Frequency), etc., or any suitable combination thereof.

[0116] The aforementioned computer-readable medium may be included in the aforementioned server; or it may exist independently and not assembled into the server. The aforementioned computer-readable medium carries one or more programs that, when executed by the server, cause the server to: in response to detecting that the peripheral mode of the terminal is not activated, acquire the frame rate of the application on the terminal; when the frame rate meets the screen-off condition, determine whether the user is acquiring the terminal's screen information; and in response to the determination that the user is not acquiring the terminal's screen information, control the screen to enter an immediate dimming mode.

[0117] Computer program code for performing the operations of the embodiments of this application can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0118] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0119] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

[0120] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.< / activerecipes> < / activerecipes> < / plugins> < / build> < / activerecipes> < / configuration> < / plugins> < / build> < / dependencymanagement> < / dependencymanagement> < / version> < / dependencymanagement> < / version> < / dependency> < / dependencies> < / dependency> < / dependencymanagement> < / parent> < / activerecipes> < / activerecipes> < / configuration> < / plugin> < / plugins> < / build> < / activerecipes> < / configuration> < / activerecipes>

Claims

1. A dependency reconstruction method, characterized by, include: Parse the project's configuration file to obtain a lossless semantic tree corresponding to the configuration file, and identify and determine the project's current dependency configuration relationship based on the lossless semantic tree of the configuration file; Based on the preset rule set configured in the second node of the configuration file, modify the dependency configuration relationship in the lossless semantic tree; Obtain a preset command and, based on the modified dependency configuration relationship, return the dependency reconstruction result corresponding to the preset command.

2. The dependency reconstruction method according to claim 1, characterized in that, The step of modifying the dependency configuration relationship in the lossless semantic tree according to the preset rule set configured in the second node of the configuration file includes: Traverse the parent nodes in the lossless semantic tree and update the version field corresponding to the parent node to the preset version; For the lossless semantic tree updated by the parent node, the dependency structure is written into its dependency management node according to the preset rule set; Remove redundant versions of dependency configuration relationships from the lossless semantic tree.

3. The dependency reconstruction method according to claim 2, characterized in that, The step of traversing the parent nodes in the lossless semantic tree and updating the version field corresponding to the parent node to a preset version includes: Locate any parent node in the lossless semantic tree; Verify whether the organization space identifier in the parent node is a preset organization space identifier, and verify whether the component name in the parent node is a preset component name; Replace the version field in the parent node with a preset version; Return the updated lossless semantic tree for use in subsequent steps.

4. The dependency reconstruction method according to claim 2, characterized in that, The lossless semantic tree updated for the parent node is used to write the dependency structure in its dependency management node according to the preset rule set, including: Check if a dependency management node exists in the lossless semantic tree; Construct a dependency structure in a predefined format; Insert the dependency structure into the dependency management node; Returns a lossless semantic tree of the inserted dependency structure for use in subsequent steps.

5. The dependency reconstruction method according to claim 2, characterized in that, The removal of redundant versions of dependency configuration relationships in the lossless semantic tree includes: Extract dependency configuration relationships from the lossless semantic tree to form a dependency set; Iterate through the dependencies in the dependency set and check if there are redundant versions of the components contained in the dependencies; Remove redundant versions from the lossless semantic tree.

6. The dependency reconstruction method according to claim 1, characterized in that, The step of obtaining a preset command and feeding back the dependency refactoring result corresponding to the preset command based on the modified dependency configuration relationship includes: Obtain the preset command, wherein the preset command includes at least: a first command and a second command, the first command being used to preview the dependency refactoring result, and the second command being used to persist the dependency refactoring result; If the preset command is the first command, then the dependency refactoring result is displayed; If the preset command is the second command, then the dependency reconstruction result is saved.

7. The dependency reconstruction method according to claim 1, characterized in that, Before parsing the project's configuration file, the following is also included: The organization space identifier, component name, and component version number are declared under the first node of the configuration file; Configure a set of preset rules under the second node of the configuration file.

8. A dependency reconstruction apparatus, characterized in that, include: The parsing module is used to parse the project's configuration file, obtain a lossless semantic tree corresponding to the configuration file, and identify and determine the current dependency configuration relationship of the project based on the lossless semantic tree of the configuration file. The rule configuration module is used to modify the dependency configuration relationship in the lossless semantic tree according to the preset rule set configured in the second node of the configuration file; The refactoring module is used to obtain a preset command and, based on the modified dependency configuration relationship, return the dependency refactoring result corresponding to the preset command.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the dependency reconstruction method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the dependency reconstruction method as described in any one of claims 1 to 7.