A reference package packaging method and related device

By pruning and packaging the reference packages of the target project, the target reference path with the largest number of reference levels is determined, which solves the problem of inconsistency and non-update reference packages, and realizes automatic update and consistency of reference packages.

CN118295691BActive Publication Date: 2025-05-16SHENZHEN DIDATRAVEL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410256868.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-07
Publication Date
2025-05-16
Estimated Expiration
2044-03-07

AI Technical Summary

Technical Problem

The associated reference packages in the prior art cannot be consistent, resulting in the previous level reference package not being updated when the lower level reference package changes, which may lead to errors.

Method used

By obtaining the reference package and its reference relationship called by the target project, the reference relationship is pruned to determine the target reference path. The target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship. It is packaged from the reference package at the lowest reference level in the target reference path to the reference package at the highest reference level in the target reference path to the reference package at the highest reference level to generate the package.

Benefits of technology

It realizes that when the lower-level reference package changes, the previous level reference package is automatically updated, avoiding the situation where the previous level reference package is not updated, and ensuring the consistency and updateability of the reference package.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118295691B_ABST
    Figure CN118295691B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a reference package packaging method and related devices, wherein the method includes: obtaining the reference package called by the target project, obtaining the reference relationship between each reference package, pruning the reference relationship between each reference package according to the reference relationship, determining the target reference path between each reference package, wherein the target reference path is a reference path with as many reference levels as possible, the i-th level reference package and the i+1-th level reference package are in a reference and referenced relationship, and the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path are packaged in sequence to generate a package. In the present invention, by obtaining the target reference path with as many reference levels as possible, a reference path is realized to contain the reference package of a lower level as much as possible, so that if the reference package of the lower level is changed later, the reference package of the upper level will be automatically updated to avoid the situation where the reference package of the upper level is not updated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a reference package packaging method and related devices. Background Art

[0002] At present, in order to facilitate code generation, you can generally reference existing packages (reference packages) to edit projects. For example, reference packages are jar packages. However, referenced packages may reference other packages. All referenced packages, including sub-packages, are referenced. Therefore, in order to read the project normally, you need to know the dependencies between the referenced packages in the project. In the prior art, display tools are generally used to display dependencies as an aid to project reading. However, the display of dependencies in the prior art generally retains all reference paths. For example, if the packages are A, B, and C, A references B and C, and B actually references C, then the retained reference paths include A references C, and A references B and B references C.

[0003] But in fact, if A directly references C, when C is modified, B directly referenced by A in the project will not be updated with the modification of C. Therefore, it may cause B to fail due to the modification of C. Therefore, in order to avoid this problem, the reference path can be modified. Summary of the invention

[0004] The main purpose of the present invention is to provide a reference package packaging method, device, computer equipment and storage medium, which can solve the problem in the prior art that the associated reference packages cannot be kept consistent.

[0005] To achieve the above object, the present invention provides a reference package packaging method in a first aspect, the method comprising:

[0006] Obtain the reference packages called by the target project, and obtain the reference relationships between the reference packages;

[0007] The reference relationships between the reference packages are pruned according to the reference relationships, and a target reference path between the reference packages is determined, wherein the target reference path is a reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship;

[0008] The reference package at the lowest reference level in the target reference path to the reference package at the highest reference level in the target reference path are packaged in sequence to generate a package.

[0009] In combination with the first aspect, in a possible implementation, the pruning of the reference relationships between the reference packages according to the reference relationships to determine the target reference paths between the reference packages includes: obtaining the reference packages directly referenced by the target project to obtain an initial reference package set; pruning the first-level reference relationships according to the initial reference package set and the reference relationships between the reference packages in the initial reference package set according to a preset first pruning rule to obtain a first-level reference package set corresponding to the target project; traversing the i-th level reference package set to determine the traversed reference package set. The i+1th level initial reference package set corresponding to the i-th level target reference package is used to obtain the i+1th level initial reference package set of the i-th level reference package set, where the initial value of i is 1; according to the i+1th level initial reference package set and the reference relationship between each reference package in the i+1th level reference package set, the i+1th level reference relationship is pruned according to a preset second pruning rule to obtain the i+1th level reference package set of each reference package in the i-level reference package set; let i=i+1, and return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

[0010] In combination with the first aspect, in a possible implementation method, the above-mentioned first-level reference relationship pruning is performed according to the reference relationship between the initial reference package set and each reference package in the initial reference package set according to a preset first pruning rule to obtain the first-level reference package set corresponding to the target project, including: traversing the initial reference package set; for the traversed initial reference package, judging whether there is a reference package to be deleted that complies with the first pruning rule, and the first pruning rule is: there is a reference package in the initial reference package set that is directly or indirectly referenced by the initial reference package; if the reference package to be deleted exists in the initial reference package set, the reference package to be deleted is placed in the first reference package set to be deleted, until the traversal is completed, and the reference package to be deleted in the first reference package set to be deleted is deleted from the initial reference package set to obtain the first-level reference package set corresponding to the target project.

[0011] In combination with the first aspect, in a possible implementation method, the above-mentioned pruning of the i+1-level reference relationship according to the i+1-level initial reference package set and the reference relationship of each reference package in the i+1-level reference package set is performed according to a preset second pruning rule to obtain the i+1-level reference package set of each reference package in the i-level reference package set, and the i+1-level reference relationship between each reference package in the i-level reference package set and each reference package in the corresponding i+1-level reference package set, including: for the n-th i+1-level initial reference package set in the i+1-level initial reference package set, traversing the n-th i+1-level initial reference package set, where the initial value of n is 1, and n is less than or equal to N, and N represents the i+1-level initial reference package set. The total number; for the i+1th level reference package in the traversed nth level i+1th initial reference package set, determine whether there is an i+1th level reference package to be deleted that meets the second pruning rule, and the second pruning rule is: there is a reference package directly or indirectly referenced by the i+1th level reference package in the nth level i+1th initial reference package set; if the reference package to be deleted exists in the nth level i+1th initial reference package set, put the i+1th level reference package to be deleted into the second reference package set to be deleted, until the traversal is completed, delete the i+1th level reference package to be deleted in the second reference package set to be deleted from the nth level i+1th initial reference package set, and obtain the i+1th level reference package set of each reference package in the i-th level reference package set.

[0012] In combination with the first aspect, in a possible implementation, the above-mentioned determination of the target reference path between the reference packages includes: generating the target reference path according to the reference packages in each i-th level reference package set and the corresponding i+1-th level reference package set.

[0013] In combination with the first aspect, in a possible implementation, the above-mentioned obtaining of the reference relationship between the various reference packages includes: using preset software to analyze the reference packages called by the target project to generate a directed graph, wherein the directed graph represents the reference relationship between the various reference packages.

[0014] To achieve the above object, the second aspect of the present invention provides a reference package packaging device, the device comprising:

[0015] Acquisition module: used to acquire the reference packages called by the target project and acquire the reference relationship between the reference packages;

[0016] A path determination module is used to prune the reference relationships between the reference packages according to the reference relationships, and determine the target reference path between the reference packages, wherein the target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship;

[0017] Package packaging module: used to package the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path in sequence to generate a package.

[0018] In combination with the second aspect, in a possible design, the path determination module includes a set determination module; the set determination module is used to obtain the reference packages directly referenced by the target project to obtain an initial reference package set; according to the initial reference package set and the reference relationship between each reference package in the initial reference package set, prune the first-level reference relationship according to a preset first pruning rule to obtain the first-level reference package set corresponding to the target project; traverse the i-th level reference package set to determine the i+1-th level initial reference package set corresponding to the traversed i-th level target reference package to obtain the i+1-th level initial reference package set of the i-th level reference package set, where the initial value of i is 1; according to the i+1-th level initial reference package set and the reference relationship between each reference package in the i+1-th level reference package set, prune the i+1-th level reference relationship according to a preset second pruning rule to obtain the i+1-th level reference package set of each reference package in the i-th level reference package set; let i=i+1, return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

[0019] To achieve the above object, the third aspect of the present invention provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:

[0020] Obtain the reference packages called by the target project, and obtain the reference relationships between the reference packages;

[0021] The reference relationships between the reference packages are pruned according to the reference relationships, and a target reference path between the reference packages is determined, wherein the target reference path is a reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship;

[0022] The reference package at the lowest reference level in the target reference path to the reference package at the highest reference level in the target reference path are packaged in sequence to generate a package.

[0023] To achieve the above object, a fourth aspect of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0024] Obtain the reference packages called by the target project, and obtain the reference relationships between the reference packages;

[0025] The reference relationships between the reference packages are pruned according to the reference relationships, and a target reference path between the reference packages is determined, wherein the target reference path is a reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship;

[0026] The reference package at the lowest reference level in the target reference path to the reference package at the highest reference level in the target reference path are packaged in sequence to generate a package.

[0027] The embodiments of the present invention have the following beneficial effects:

[0028] The present invention provides a reference package packaging method, which obtains the reference package called by the target project, obtains the reference relationship between each reference package, prunes the reference relationship between each reference package according to the reference relationship, and determines the target reference path between each reference package, wherein the target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference and referenced relationship, and the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path are packaged in sequence to generate a package. In the present invention, by obtaining a target reference path with as many reference levels as possible, a reference path is realized to contain as many lower-level reference packages as possible, so that if a lower-level reference package is subsequently changed, the upper-level reference package will be automatically updated to avoid the situation where the upper-level reference package is not updated. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0030] in:

[0031] Figure 1 A schematic diagram of a flow chart of a reference package packaging method according to an embodiment of the present invention;

[0032] Figure 2 It is a structural block diagram of a reference package packaging device in an embodiment of the present invention;

[0033] Figure 3 4 is a structural block diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] An embodiment of the present invention provides a reference package packaging method, which can be applied to sorting out the reference relationships of various reference packages of a java project and packaging according to the reference relationships, so that when the reference package of a subsequent java project is changed, the reference package that references the modified reference package can be automatically changed.

[0036] Reference Figure 1 , Figure 1 A flowchart of a reference package packaging method provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method is as follows:

[0037] Step S101: Obtain reference packages called by a target project, and obtain reference relationships between the reference packages.

[0038] In this embodiment, the target project is the currently processed project, which can be a Java project, and the reference package can be a jar package. The reference package called by the target project is obtained, and the reference relationship between each reference package is obtained. Since the reference relationship between each reference package is not directly represented in the target project, in a possible implementation, a preset software is used to analyze the reference package called by the target project to generate a directed graph, wherein the directed graph represents the reference relationship between each reference package.

[0039] Step S102: prune the reference relationships between the reference packages according to the reference relationships, and determine the target reference paths between the reference packages, wherein the target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference and referenced relationship.

[0040] Step S103 , packaging is performed in sequence from the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path to generate a package.

[0041] In this embodiment, the purpose is to generate reference paths with as many reference levels as possible. As many as possible can be understood as a reference path that contains as many reference packages with reference relationships as possible, so that reference packages with direct reference relationships are on one reference path. For example, target project 1 references A, B, and C, A references D, B references D, and D references E, then target project 1-A-D-E, target project 1-B-D-E, and target project 1-C are each a target reference path.

[0042] Specifically, the reference relationships between the reference packages are pruned according to the reference relationships, and the target reference paths between the reference packages are determined, wherein the target reference path is a reference path with as many reference levels as possible, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship.

[0043] The specific implementation method is shown in steps S201 to S205.

[0044] Step S201: Acquire the reference packages directly referenced by the target project to obtain an initial reference package set.

[0045] Get the reference packages directly referenced by the target project and get the initial reference package set. The directed graph contains multiple reference paths. The reference paths represent reference relationships. The reference paths are composed of the i-th reference package and the i+1-th reference package. The reference relationship between the i-th reference package and the i+1-th reference package in the reference path represents direct reference. The reference relationship between the i-th reference package and the i+j-th reference package represents indirect reference, where j can start from 2.

[0046] For example, target project 1 references A, B, and C, A references D, B references D, and D references E, then target project 1-A-D-E, target project 1-B-D-E, and target project 1-C are each a reference path, among which the reference packages directly referenced by target project 1 are A, B, and C, then the initial reference package set of target project 1 includes A, B, and C.

[0047] Step S202: According to the initial reference package set and the reference relationships between the reference packages in the initial reference package set, first-level reference relationship pruning is performed according to a preset first pruning rule to obtain a first-level reference package set corresponding to the target project.

[0048] According to the initial reference package set and the reference relationship between each reference package in the initial reference package set, the first-level reference relationship is pruned according to the preset first pruning rule to obtain the first-level reference package set corresponding to the target project. In this embodiment, there is no reference relationship between the reference packages included in the first-level reference package set, that is, the reference packages in the initial reference package set that are referenced by the initial reference package are deleted according to the first pruning rule to obtain the first-level reference package set.

[0049] The determination of the first-level reference package set is specifically shown in steps S301 to S303:

[0050] Step S301: traverse the initial reference package set.

[0051] Step S302: for the traversed initial reference packages, determine whether there are reference packages to be deleted that meet the first pruning rule, where the first pruning rule is: there are reference packages in the initial reference package set that are directly or indirectly referenced by the initial reference package.

[0052] Step S303: If the reference package to be deleted exists in the initial reference package set, the reference package to be deleted is placed in the first reference package set to be deleted until the traversal is completed, and the reference package to be deleted in the first reference package set to be deleted is deleted from the initial reference package set to obtain the first-level reference package set corresponding to the target project.

[0053] The initial reference package set is traversed, and for the traversed initial reference packages, it is determined whether there are reference packages to be deleted that meet the first pruning rule, wherein the first pruning rule is that there are reference packages in the initial reference package set that are directly or indirectly referenced by the initial reference package. If there are reference packages to be deleted in the initial reference package set, the reference packages to be deleted are placed in the first reference package set to be deleted until the traversal is completed, and the reference packages to be deleted in the first reference package set to be deleted are deleted from the initial reference package set to obtain the first-level reference package set corresponding to the target project.

[0054] For example, target project 1 directly references A, B, C, D, E, and F. The initial reference package set of target project 1 includes A, B, C, D, E, and F. Among them, A references D, B references D, and D references E. When traversing to A, the reference packages directly and indirectly referenced by A in the initial reference package set include D and E. Then D and E are put into the first reference package set to be deleted. When traversing to B, the reference packages directly and indirectly referenced by A in the initial reference package set include D. Then D is put into the first reference package set to be deleted. Using the package set, when traversing to C, there is no reference package to be deleted. When traversing to D, the reference package directly and indirectly referenced by D in the initial reference package set includes E. E is put into the first reference package set to be deleted. When traversing to E, there is no reference package to be deleted. When traversing to F, there is no reference package to be deleted. Then the final first reference package set to be deleted includes D and E. Then D and E are deleted from the initial reference package set to obtain the first-level reference package set. At this time, the first-level reference package set includes A, B, C, and F.

[0055] Step S203, traverse the i-th level reference package set, determine the i+1-th level initial reference package set corresponding to the traversed i-th level target reference package, and obtain the i+1-th level initial reference package set of the i-th level reference package set, where the initial value of i is 1.

[0056] Starting from the first-level reference package set, determine the i+1-level reference package set corresponding to each i-th-level reference package. Specifically, the initial value of i is 1, traverse the i-th-level reference package set, determine the i+1-level initial reference package set corresponding to the traversed i-th-level target reference package, and obtain the i+1-level initial reference package set for each package in the i-th-level reference package set.

[0057] Step S204: based on the i+1th level initial reference package set and the reference relationship between each reference package in the i+1th level reference package set, prune the i+1th level reference relationship according to a preset second pruning rule to obtain the i+1th level reference package set of each reference package in the i-th level reference package set.

[0058] For each i+1-th level initial reference package set, according to the i+1-th level initial reference package set and the reference relationship between each reference package in the i+1-th level reference package set, the i+1-th level reference relationship is pruned according to the preset second pruning rule to obtain the i+1-th level reference package set of the i-th level reference package.

[0059] Specifically, as shown in step S401 to step S403:

[0060] Step S401: For the nth i+1th level initial reference package set in the i+1th level initial reference package set, traverse the nth i+1th level initial reference package set, where the initial value of n is 1, and n is less than or equal to N, and N represents the total number of i+1th level initial reference package sets.

[0061] Step S402: for the i+1th level reference package in the traversed nth level i+1th level initial reference package set, determine whether there is an i+1th level reference package to be deleted that complies with the second pruning rule, and the second pruning rule is: there is a reference package in the nth level i+1th level initial reference package set that is directly or indirectly referenced by the i+1th level reference package.

[0062] Step S403: If the i+1th level reference package to be deleted exists in the nth i+1th level initial reference package set, the i+1th level reference package to be deleted is placed in the second reference package set to be deleted, until the traversal is completed, and the i+1th level reference package to be deleted in the second reference package set to be deleted is deleted from the nth i+1th level initial reference package set to obtain the i+1th level reference package set of each reference package in the i-th level reference package set.

[0063] For the nth i+1th level initial reference package set in the i+1th level initial reference package set, traverse the nth i+1th level initial reference package set, and for the i+1th level reference package in the traversed nth i+1th level initial reference package set, determine whether there is an i+1th level reference package to be deleted that meets the second pruning rule, wherein the second pruning rule is that there is a reference package directly or indirectly referenced by the i+1th level reference package in the nth i+1th level initial reference package set, if there is an i+1th level reference package to be deleted in the nth i+1th level initial reference package set, then put the i+1th level reference package to be deleted into the second reference package set to be deleted, until the traversal is completed, and delete the i+1th level reference package to be deleted in the second reference package set to be deleted from the nth i+1th level initial reference package set to obtain the i+1th level reference package set of the i-level reference package.

[0064] For example, the first-level reference package set includes A and C, the second-level initial reference package set of A includes B and E, and the second-level initial reference package set of B includes D and E. For the second-level initial reference package set of A, when traversing to B, B references E, therefore, E is determined as the second-level reference package to be deleted, and E is put into the second reference package set to be deleted. When traversing to E, there is no corresponding second-level reference package to be deleted, then the second reference package set to be deleted only includes E, and E is deleted from the second-level initial reference package set to obtain the second-level reference package set of A. The second-level reference package set of A includes B. For the second-level initial reference package set of C, when traversing to D, there is no corresponding second-level reference package to be deleted. When traversing to E, there is no corresponding second-level reference package to be deleted, and the second-level initial reference package set of A is determined as the second-level reference package set of A, and the second-level reference package set of A includes D and E.

[0065] Step S205 , let i=i+1, and return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

[0066] Let i=i+1, and return to execute the step of traversing the i-th level reference package set until the target reference path is obtained. Specifically, the target reference path is generated according to the reference packages in each i-th level reference package set and the corresponding i+1-th level reference package set. For example, the first-level reference package set of the target project is A, B, and C, the second-level reference package set of A is D and E, the second-level reference package set of B is F, the second-level reference package set of C is G, and the third-level reference package set of F is G. Then the target reference paths are target project-A-D, target project-A-E, target project-B-F-G, and target project-C-G, respectively.

[0067] The reference packages from the lowest reference level in the target reference path to the highest reference level in the target reference path are packaged in sequence to generate a package.

[0068] Based on the above method, by obtaining the reference package called by the target project, obtaining the reference relationship between each reference package, pruning the reference relationship between each reference package according to the reference relationship, determining the target reference path between each reference package, wherein the target reference path is a reference path with as many reference levels as possible, the i-th level reference package and the i+1-th level reference package are in a reference and referenced relationship, and the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path are packaged in sequence to generate a package. In the present invention, by obtaining the target reference path with as many reference levels as possible, a reference path is realized to contain the reference package of a lower level as much as possible, so that if the reference package of a lower level is changed later, the reference package of the upper level will be automatically updated to avoid the situation where the reference package of the upper level is not updated.

[0069] In order to better implement the above method, the embodiment of the present invention provides a structural block diagram of a reference package packaging device, such as Figure 2 As shown, the device 20 specifically includes the following:

[0070] The acquisition module 201 is used to acquire the reference packages called by the target project and acquire the reference relationship between the reference packages.

[0071] Path determination module 202: used to prune the reference relationship between the reference packages according to the reference relationship, and determine the target reference path between the reference packages, wherein the target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference and referenced relationship.

[0072] The package packaging module 203 is used to package the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path in sequence to generate a package.

[0073] In a possible design, the acquisition module 201 is further configured to use preset software to analyze the reference packages called by the target project and generate a directed graph, wherein the directed graph represents the reference relationship between the reference packages.

[0074] In a possible design, the path determination module 202 includes a set determination module, which is used to obtain the reference packages directly referenced by the target project to obtain an initial reference package set; based on the initial reference package set and the reference relationship between each reference package in the initial reference package set, prune the first-level reference relationship according to a preset first pruning rule to obtain the first-level reference package set corresponding to the target project; traverse the i-th level reference package set to determine the i+1-th level initial reference package set corresponding to the traversed i-th level target reference package to obtain the i+1-th level initial reference package set of the i-th level reference package set, where the initial value of i is 1; based on the i+1-th level initial reference package set and the reference relationship between each reference package in the i+1-th level reference package set, prune the i+1-th level reference relationship according to a preset second pruning rule to obtain the i+1-th level reference package set of each reference package in the i-th level reference package set; let i=i+1, return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

[0075] In a possible design, the above-mentioned set determination module is specifically used to traverse the initial reference package set; for the traversed initial reference package, determine whether there is a reference package to be deleted that meets the first pruning rule, and the first pruning rule is: there is a reference package in the initial reference package set that is directly or indirectly referenced by the initial reference package; if the reference package to be deleted exists in the initial reference package set, the reference package to be deleted is placed in the first reference package set to be deleted until the traversal is completed, and the reference package to be deleted in the first reference package set to be deleted is deleted from the initial reference package set to obtain the first level reference package set corresponding to the target project.

[0076] In a possible design, the above-mentioned set determination module is specifically used to traverse the nth i+1-th level initial reference package set in the i+1-th level initial reference package set, where the initial value of n is 1, and n is less than or equal to N, and N represents the total number of i+1-th level initial reference package sets; for the i+1-th level reference package in the traversed nth i+1-th level initial reference package set, determine whether there is an i+1-th level reference package to be deleted that meets the second pruning rule, and the second pruning rule Then: the nth i+1th level initial reference package set contains reference packages that are directly or indirectly referenced by the i+1th level reference package; if the to-be-deleted reference package exists in the nth i+1th level initial reference package set, the i+1th level reference package to be deleted is put into the second to-be-deleted reference package set until the traversal is completed, and the i+1th level reference package to be deleted of the second to-be-deleted reference package set is deleted from the nth i+1th level initial reference package set to obtain the i+1th level reference package set of each reference package in the i-th level reference package set.

[0077] In a possible design, the above-mentioned set determination module is specifically used to generate a target reference path according to the reference packages in each i-th level reference package set and the corresponding i+1-th level reference package set.

[0078] Based on the above device, by obtaining a target reference path with as many reference levels as possible, a reference path can be implemented to contain as many reference packages of a lower level as possible, so that if a reference package of a lower level is changed later, the reference package of the upper level will be automatically updated to avoid the situation where the reference package of the upper level is not updated.

[0079] Figure 3 FIG. 1 shows an internal structure diagram of a computer device in an embodiment. The computer device may be a terminal or a server. Figure 3As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement all the steps of the above method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can implement all the steps of the above method. Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0080] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes each step of the aforementioned method.

[0081] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes each step of the aforementioned method.

[0082] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0083] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0084] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A reference package packaging method, characterized in that: The method comprises: Get the reference packages called by the target project and the reference relationships between the reference packages; The reference relationships between the reference packages are pruned according to the reference relationships, and a target reference path between the reference packages is determined, wherein the target reference path is a reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship; Packing in sequence from the reference package with the lowest reference level in the target reference path to the reference package with the highest reference level in the target reference path to generate a package; The pruning of the reference relationships between the reference packages according to the reference relationships to determine the target reference paths between the reference packages includes: Acquire the reference packages directly referenced by the target project to obtain an initial reference package set; According to the initial reference package set and the reference relationships between the reference packages in the initial reference package set, pruning the first-level reference relationship according to a preset first pruning rule to obtain the first-level reference package set corresponding to the target project; Traversing the i-th level reference package set, determining the i+1-th level initial reference package set corresponding to the traversed i-th level target reference package, and obtaining the i+1-th level initial reference package set of the i-th level reference package set, where the initial value of i is 1; According to the i+1th level initial reference package set and the reference relationship of each reference package in the i+1th level reference package set, pruning the i+1th level reference relationship according to a preset second pruning rule, to obtain the i+1th level reference package set of each reference package in the i-th level reference package set; Let i=i+1, and return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

2. The method according to claim 1, characterized in that The step of pruning the first-level reference relationship according to the initial reference package set and the reference relationship between each reference package in the initial reference package set according to a preset first pruning rule to obtain the first-level reference package set corresponding to the target project includes: Traversing the initial reference package set; For the traversed initial reference packages, it is determined whether there is a reference package to be deleted that meets the first pruning rule, wherein the first pruning rule is: there is a reference package in the initial reference package set that is directly or indirectly referenced by the initial reference package; If the reference package to be deleted exists in the initial reference package set, the reference package to be deleted is placed in the first reference package set to be deleted until the traversal is completed, and the reference package to be deleted in the first reference package set to be deleted is deleted from the initial reference package set to obtain the first-level reference package set corresponding to the target project.

3. The method according to claim 1, characterized in that The step of pruning the i+1th level reference relationship according to the i+1th level initial reference package set and the reference relationship between each reference package in the i+1th level reference package set according to a preset second pruning rule, to obtain the i+1th level reference package set of each reference package in the i-th level reference package set, and the i+1th level reference relationship between each reference package in the i-th level reference package set and each reference package in the corresponding i+1th level reference package set, includes: For the nth i+1th level initial reference package set in the i+1th level initial reference package set, traverse the nth i+1th level initial reference package set, where the initial value of n is 1, and n is less than or equal to N, where N represents the total number of i+1th level initial reference package sets; For the i+1th level reference package in the traversed nth level i+1th initial reference package set, determining whether there is an i+1th level reference package to be deleted that meets the second pruning rule, wherein the second pruning rule is: there is a reference package in the nth level i+1th initial reference package set that is directly or indirectly referenced by the i+1th level reference package; If there is a reference package to be deleted in the nth i+1th level initial reference package set, the i+1th level reference package to be deleted is put into the second reference package set to be deleted until the traversal is completed, and the i+1th level reference package to be deleted in the second reference package set to be deleted is deleted from the nth i+1th level initial reference package set to obtain the i+1th level reference package set of each reference package in the i-th level reference package set.

4. The method according to claim 3, characterized in that The determining of the target reference paths between the reference packages includes: A target reference path is generated according to the reference packages in each i-th level reference package set and the corresponding i+1-th level reference package set.

5. The method according to claim 4, characterized in that The obtaining of the reference relationship between the reference packages includes: The reference packages called by the target project are analyzed by using preset software to generate a directed graph, wherein the directed graph represents the reference relationship between the reference packages.

6. A quotation package packaging device, characterized in that: The device comprises: Acquisition module: used to obtain the reference package called by the target project and the reference relationship between each reference package; A path determination module is used to prune the reference relationships between the reference packages according to the reference relationships, and determine the target reference path between the reference packages, wherein the target reference path is the reference path with the largest number of reference levels among multiple branch reference paths with the same reference relationship, and the i-th level reference package and the i+1-th level reference package are in a reference-referenced relationship; A package packaging module: used for packaging in sequence from the lowest reference level reference package in the target reference path to the highest reference level reference package in the target reference path to generate a package; The path determination module includes a set determination module; The set determination module is used to obtain the reference packages directly referenced by the target project to obtain an initial reference package set; based on the initial reference package set and the reference relationships between the reference packages in the initial reference package set, prune the first-level reference relationships according to a preset first pruning rule to obtain a first-level reference package set corresponding to the target project; traverse the i-th level reference package set to determine the i+1-th level initial reference package set corresponding to the traversed i-th level target reference package to obtain the i+1-th level initial reference package set of the i-th level reference package set, where the initial value of i is 1; based on the i+1-th level initial reference package set and the reference relationships between the reference packages in the i+1-th level reference package set, prune the i+1-th level reference relationships according to a preset second pruning rule to obtain the i+1-th level reference package set of each reference package in the i-th level reference package set; let i=i+1, return to execute the step of traversing the i-th level reference package set until the target reference path is obtained.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 5.

8. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Code processing method and device, electronic equipment and storage medium

    CN113296797A

  • Element set acquisition method and device, equipment and storage medium

    CN114861575A