Method and device for splitting software project
By analyzing the dependencies of files in software projects, we solve the splitting errors caused by unclear file directories after iterative upgrades of software projects, achieve more accurate micro-application splitting, and reduce the error rate.
Patent Information
- Application Number
- CN202410593648.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-09-10
AI Technical Summary
During the iterative upgrade process of software projects, the file directory hierarchy is deep and the layering is unclear, which leads to errors of missing files or extra files that do not belong to the micro-applications when manually splitting them.
By analyzing the dependencies between files in the software project, the entry files and target files are determined, and micro-applications are split based on the dependencies to reduce the occurrence of splitting errors.
It effectively reduces the errors of missing files or having extra files that do not belong to the micro-application during the splitting process, and improves the accuracy and reliability of software project splitting.
Smart Images

Figure CN118626141A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for splitting a software project. Background Art
[0002] As software projects are iterated and upgraded, they usually change from an ordinary software project to a monolithic project. Therefore, in order to better manage and maintain software projects, they are usually split into micro-applications that can be developed and deployed independently.
[0003] Currently, software projects are usually split into micro-applications manually based on the file directories of the software projects. However, software projects usually lack planning during the iterative upgrade process, and the file directory hierarchy is deep and unclear. Therefore, manually splitting software projects based on the file directory can easily lead to errors such as missing files in the split micro-applications. Summary of the invention
[0004] In view of this, the present application proposes a method and device for splitting a software project, the main purpose of which is to reduce the error rate of splitting micro-applications from a software project.
[0005] In order to achieve the above objectives, this application mainly provides the following technical solutions:
[0006] In a first aspect, the present application provides a method for splitting a software project, the method for splitting a software project comprising:
[0007] Identify the micro-applications to be split out of the software project;
[0008] In the files of the software project, determine the entry file of the micro-application, and search for the target file that has a dependency relationship with the entry file;
[0009] Based on the entry file and the found target file, the micro-application is split out from the software project.
[0010] In some embodiments of the present application, searching for a target file that has a dependency relationship with the entry file includes: for each entry file: determining the entry file as the current file, searching for a dependency path of the current file, the dependency path being used to represent the file that is dependent on when executing the current file, detecting whether the file represented by the found dependency path is a file of the software project, and if so, determining the corresponding file as the target file that has a dependency relationship with the entry file, using the determined target file as the new current file, and looping through the steps of searching for the dependency path of the new current file until the dependency path is not found, or the dependency path is found and the file represented by the dependency path is not a file of the software project.
[0011] In some embodiments of the present application, searching for the dependency path of the current file includes: searching whether a target string is included in an abstract syntax tree corresponding to the current file, the abstract syntax tree being constructed based on the file content of the current file, and the target string being used to identify the dependency path of the current file; if included, searching for the dependency path identified by the target string.
[0012] In some embodiments of the present application, if the software project uses the storage path of a file as a dependency path, detecting whether the file represented by the found dependency path is a file of the software project includes: matching the found dependency path with the storage path of the file of the software project; if the match is successful, detecting that the file represented by the found dependency path is a file of the software project.
[0013] In some embodiments of the present application, if the software project uses data obtained by simplifying the storage path of a file as a dependent path, then detecting whether the file represented by the found dependent path is a file of the software project includes: restoring the found dependent path to a corresponding target storage path; matching the target storage path with the storage path of the file of the software project; if the match is successful, detecting that the file represented by the found dependent path is a file of the software project.
[0014] In some embodiments of the present application, the software project splitting method also includes: determining whether the current file is a source code file; if so, executing the step of searching for a dependency path of the current file; if not, determining that the current file does not have a dependency path.
[0015] In some embodiments of the present application, when the software project is executed, there is a dependency path for files that need to rely on other files, and the dependency path is used to characterize the files that the execution file depends on. Then, based on the entry file and the found target file, the micro-application is split out from the software project, including: migrating the entry file and the target file of the micro-application to the micro-application corresponding file.
[0017] For a file migrated to the designated migration location, based on the storage address of the file on which the file depends in the designated migration location, modify the corresponding dependency path of the file.
[0018] In some embodiments of the present application, there is a dependency path for files in the software project that need to rely on other files when executed, and the dependency path is used to characterize the files that the execution file depends on. Then, based on the entry file and the found target file, the micro-application is split from the software project, including: detecting whether the entry file and the target file of the micro-application have common files that are common to other micro-applications in the software project; if so, migrating the files other than the common files in the entry file and the target file of the micro-application to the corresponding designated migration position of the micro-application, and migrating the common files to the common migration position; for the files migrated to the corresponding migration position, modifying the corresponding dependency path of the file based on the storage address of the file on which the file depends in the corresponding migration position; wherein, if the dependent file is a file migrated to the designated migration position, the storage address is the storage address of the corresponding file in the designated migration position, and if the dependent file is a file migrated to the common migration position, the storage address is the storage address of the corresponding file in the common migration position.
[0019] In some embodiments of the present application, detecting whether the entry file and the target file of the micro-application have common files that are common to other micro-applications in the software project includes: obtaining a topology map based on the dependency relationship between the entry file and the target file of the micro-application and the dependency relationship between the entry file and the target file of other micro-applications in the software project; if there is an intersection in the topology map, and the file located at the intersection is associated with the micro-application and at least one of the other micro-applications, then it is determined that there are common files that are common to other micro-applications in the software project.
[0020] In some embodiments of the present application, determining the micro-application to be split from the software project includes: detecting whether a split instruction is received in the command line tool; if so, determining the micro-application specified by the split instruction as the micro-application to be split from the software project.
[0021] In a second aspect, the present application provides a software project splitting device, the software project splitting device comprising:
[0022] A determination module, used to determine the micro-applications to be separated from the software project;
[0023] A search module, used to determine the entry file of the micro-application in the files of the software project, and to search for a target file that has a dependency relationship with the entry file;
[0024] A splitting module is used to split the micro-application from the software project based on the entry file and the found target file.
[0025] In a third aspect, the present application provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the method for splitting the software project of the first aspect.
[0026] In a fourth aspect, the present application provides an electronic device, comprising: a memory for storing a program; and a processor, coupled to the memory, for running the program to execute the method for splitting a software project described in the first aspect.
[0027] The method and device for splitting a software project provided by the present application, when it is necessary to split a micro-application from a software project, determine the micro-application to be split from the software project. In the file of the software project, determine the entry file of the micro-application, and find the target file that has a dependency relationship with the entry file. Based on the entry file and the target file found, split the micro-application from the software project. It can be seen that the solution provided by the present application performs dependency analysis on the files of the software project based on the entry file corresponding to the micro-application, and splits the corresponding micro-application from the software project based on the entry file and the file that has a dependency relationship with the entry file, so that errors such as missing files or extra files that do not belong to the split micro-application can be reduced.
[0028] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0030] Figure 1 A flowchart showing a method for splitting a software project provided by an embodiment of the present application is shown;
[0031] Figure 2 A schematic diagram showing the structure of a software project splitting device provided by an embodiment of the present application is shown;
[0032] Figure 3 A schematic structural diagram of a software project splitting device provided in another embodiment of the present application is shown. DETAILED DESCRIPTION
[0033] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0034] At present, software projects such as front-end projects are usually split into micro-applications that can be developed and deployed independently, so as to better manage and maintain software projects using the microservice architecture model. Software projects are usually split into micro-applications manually based on the file directory of the software project. However, software projects usually lack planning during the iterative upgrade process, and the file directory hierarchy is deep and the layers are not clear. Therefore, manually splitting software projects based on the file directory can easily lead to errors such as missing files or extra files that do not belong to the split micro-applications.
[0035] After research, the inventor found that there are dependencies between files belonging to the same micro-application in a software project. Even if the file directory of the software project has deep levels and unclear layers, it will not affect the dependencies between the files in the software project. Therefore, the inventor considered splitting the micro-application from the software project by analyzing the dependencies between the files.
[0036] Based on the above considerations, the embodiment of the present application provides a technical solution for splitting a software project, specifically: determining the micro-application to be split from the software project; in the files of the software project, determining the entry file of the micro-application, and finding the target file that has a dependency relationship with the entry file; based on the entry file and the found target file, split the micro-application from the software project. In this way, starting with the entry file of the micro-application to perform file dependency analysis, the files related to the micro-application can be found, which can reduce the errors such as missing files or extra files that do not belong to the split micro-application.
[0037] The software project splitting technical solution provided in this embodiment can be used to split any software project, and this embodiment does not limit the type of software project. Exemplarily, the software project is a front-end project.
[0038] Based on the above-mentioned technical solution for splitting software projects, this embodiment specifically provides a method and device for splitting software projects. The method and device for splitting software projects provided in this embodiment are specifically described below.
[0039] like Figure 1 As shown, the embodiment of the present application provides a method for splitting a software project, and the method for splitting a software project mainly includes the following steps 101 to 103:
[0040] 101. Identify the micro-applications to be separated from the software project.
[0041] A software project has multiple functions integrated. When the software project needs to be split, micro-applications that can be split from the software project can be pre-planned based on the functions integrated in the software project, wherein each micro-application involves at least one function. The method of pre-planning micro-applications that can be split from the software project based on the functions integrated in the software project may include the following two methods: one is to determine the functions integrated in the software project and plan each function as a corresponding micro-application; the other is to plan the functions specified by the customized requirements as a corresponding micro-application, wherein the customized requirements are determined based on the needs of the user, and the functions specified by different customized requirements may be repeated or not repeated, which can be flexibly set based on business needs, and this embodiment does not limit this.
[0042] Based on the planned micro-applications, the micro-applications to be split from the software project are determined. The method for determining the micro-applications to be split from the software project can include the following three methods: the first method is to determine all the planned micro-applications as micro-applications to be split from the software project, so that all the micro-applications involved in the software project can be split from the software project; the second method is that, considering the user's splitting needs, the planned micro-applications can be displayed for the user to select, and when there is a selected micro-application, the selected micro-application is determined as the micro-application to be split from the software project. The third method is to detect whether a split instruction is received in the command line tool; if so, the micro-application specified by the split instruction is determined as the micro-application to be split from the software project. The split instruction can specify the micro-application by specifying the functions related to the micro-application, or the split instruction can specify the micro-application selected by the user in combination with the above-mentioned second method.
[0043] 102. In the files of the software project, determine the entry file of the micro-application and find the target file that has a dependency relationship with the entry file.
[0044] The software project includes multiple files, and the multiple files here include at least one entry file and the files on which the entry file depends. The entry file has corresponding functions, i.e., the corresponding micro-applications, which are the files that are first started when the micro-application is executed. The files on which the entry file depends are the files on which the entry file depends when executing the entry file. The types of files included in the software project may include, but are not limited to, source code files, pictures, and Cascading Style Sheets (CSS), etc. Among them, the entry file is usually a source code file, and the files on which the entry file depends can be one or more of a source code file, a picture, and a Cascading Style Sheet.
[0045] Splitting a micro-application from a software project is essentially splitting files related to the micro-application from the software project. Therefore, after determining the micro-application to be split from the software project, it is necessary to determine the entry file of the micro-application in the files of the software project to find other files of the micro-application through the entry file.
[0046] The specific process of determining the entry file of the micro-application may include the following steps: searching for the entry file corresponding to the function involved in the micro-application from the entry files included in the software project; and determining the found file as the entry file of the micro-application. Specifically, the entry file of the function has a corresponding identifier, and the identifier is used to characterize that the corresponding file is the entry file of the corresponding function, so the entry file corresponding to the function involved in the micro-application can be searched based on the identifier of the entry file.
[0047] After determining the entry file of the micro-application, the target file that has a dependency relationship with the entry file is found from the files of the software project based on the entry file, where the dependency relationship includes direct dependency and indirect dependency. Specifically, the specific process of finding the target file that has a dependency relationship with the entry file can be to perform the following steps 102A to 102E for each entry file:
[0048] 102A. Determine the entry file as the current file.
[0049] The entry file is the first file to be executed when the corresponding micro-application is executed. Therefore, the entry file is first determined as the first current file, so as to start looking for other files of the micro-application from the entry file, that is, the target files that have a dependency relationship with the entry file.
[0050] 102B. Find the dependency path of the current file.
[0051] The dependency path is used to represent the files that the current file depends on when executing. The execution of the current file depends on the files that it depends on. Therefore, in order to find the files that the current file depends on, you need to find the dependency path of the current file.
[0052] The specific process of searching the dependency path of the current file may include the following steps: searching whether the target string is included in the abstract syntax tree corresponding to the current file, the abstract syntax tree is constructed based on the file content of the current file, and the target string is used to identify the dependency path of the current file; if included,
[0054] Then find the dependent path identified by the target string.
[0055] To find the dependency path of the current file, it is necessary to obtain the abstract syntax tree corresponding to the current file. The methods for obtaining the abstract syntax tree corresponding to the current file may include the following two methods: one is to extract the file content of the current file; and to construct the corresponding abstract syntax tree based on the file content by using a preset syntax tree construction tool. The other is to preset the abstract syntax tree corresponding to the file of the software project in advance, and obtain the abstract syntax tree corresponding to the current file from the preset abstract syntax tree.
[0056] For a file in a software project, if there is a file that it depends on, then the file must have a dependency path, and the corresponding abstract syntax tree of the file will contain a target string used to identify the file's dependency path. In other words, if there is a target string in the abstract syntax tree, then the corresponding file must have a dependency path. The target string can be flexibly set based on business needs, and may include but is not limited to import, require, etc.
[0057] When the target string is found in the abstract syntax tree corresponding to the current file, it indicates that the current file has a dependent path, so the dependent path identified by the target string is found as the dependent path of the current file. The dependent path can be extracted from the abstract syntax tree through a corresponding dependent path extraction model or extraction method.
[0058] When the target string is not included in the abstract syntax tree corresponding to the current file, it indicates that the current file does not have a dependent path, which means that the current file does not have a dependent file.
[0059] Furthermore, considering that usually only source code files have dependency paths, before searching for the dependency path of the current file, the software project splitting method may also include the following steps: determining whether the current file is a source code file; if so, executing the step of searching for the dependency path of the current file; if not, determining that the current file does not have a dependency path.
[0060] The specific process of determining whether the current file is a source code file is as follows: determining whether the file type identifier of the current file is an identifier corresponding to the source code file. If so, the current file is determined to be a source code file; if not, the current file is determined not to be a source code file, indicating that the current file may be a style sheet, image, or other file. The identifier corresponding to the source code file may be set based on specific business, and this embodiment does not limit this. For example, the identifier corresponding to the source code file may include, but is not limited to: SFC, js, ts.
[0061] 102C. Detect whether the file represented by the found dependency path is a file of the software project. If so, execute step 102D; if not, determine that the file represented by the found dependency path is not a file of the software project.
[0062] When the dependency path is found, it means that the current file may have a dependent file in the software project file, so it is necessary to detect whether the file represented by the found dependency path is a file of the software project. The method of detecting whether the file represented by the found dependency path is a file of the software project is related to the specific setting of the dependency path, so the detection method can include the following two methods:
[0063] First, if the software project uses the storage path of the file as the dependency path, then the specific process of detecting whether the file represented by the found dependency path is the file of the software project may include the following steps: matching the found dependency path with the storage path of the file of the software project; if the match is successful, detecting that the file represented by the found dependency path is the file of the software project.
[0064] If the software project uses the storage path of the file as the dependent path, the dependent path is the storage path of the file in the software project, so the searched dependent path can be directly matched with the storage path of the file of the software project.
[0065] If the match is successful, it means that the found dependency path is the storage address of the software system's file, and the file represented by the dependency path is the file corresponding to the successfully matched storage path. Therefore, it is detected that the file represented by the found dependency path is the file of the software project.
[0066] If the match fails, it means that the found dependency path is not the storage address of the software system's file. The file represented by the dependency path is not a file of the software system. It may be a file in a third-party library that exists independently of the software system but will be used by the software system.
[0067] Second, if the software project uses the data obtained by simplifying the storage path of the file as the dependent path, then the specific process of detecting whether the file represented by the found dependent path is the file of the software project may include the following steps: restoring the found dependent path to the corresponding target storage path; matching the target storage path with the storage path of the file of the software project; if the match is successful, detecting that the file represented by the found dependent path is the file of the software project.
[0068] Considering that the storage path of a file is usually a long string, it would be too cumbersome to use the storage path directly as the dependency path. Therefore, in order to simplify the dependency path, the software project can simplify the storage path of the file and use the data obtained as the dependency path. This not only simplifies the dependency path, but also does not affect the call of the file represented by the dependency path when the file is executed.
[0069] The method of restoring the found dependent path to the corresponding target storage path may include the following two methods: one is to determine the simplification algorithm used for the simplification process, and use the inverse operation corresponding to the simplification algorithm, that is, the restoration algorithm, to restore the found dependent path to the corresponding target storage path. The other is to maintain the mapping relationship between the dependent path and the storage path of the same file in advance, and restore the found dependent path to the corresponding target storage path through the preset mapping relationship. It should be noted that no matter which of the above methods is used, the storage path and the dependent path have a unique corresponding relationship.
[0070] After the target storage path is obtained through the restoration process, the target storage path is matched with the storage path of the software project's files. If the match is successful, it means that the found dependency path is the storage address of the software system's files, and the file represented by the dependency path is the file corresponding to the successfully matched storage path. Therefore, it is detected that the file represented by the found dependency path is the file of the software project. If the match fails, it means that the found dependency path is not the storage address of the software system's files, and the file represented by the dependency path is not a file of the software system. It may be a file in a third-party library that exists independently of the software system but will be used by the software system.
[0071] 102D. Determine the corresponding file as a target file that has a dependency relationship with the entry file.
[0072] If it is detected that the file represented by the found dependency path is a file of the software project, it means that the file represented by the dependency path is the file that the current file depends on, so the corresponding file is determined as a target file that has a dependency relationship with the entry file.
[0073] 102E. The determined target file is used as a new current file, and the step of searching for a dependent path of the new current file is executed in a loop until the dependent path is not found, or the dependent path is found and the file represented by the dependent path is not a file of the software project.
[0074] Through such a loop process, all files that have direct and indirect dependencies with the entry file can be found. When the dependency path of the current file is found, or the dependency path is found and the file represented by the dependency path is not a file of the software project, it means that all the files that the current file depends on in the software project have been found, so the loop process can be ended.
[0075] 103. Split micro-applications from the software project based on the entry file and the found target file.
[0076] If a target file with a dependency relationship is found for each entry file of the micro-application, it means that all the files of the micro-application in the project file have been found. Therefore, the micro-application can be split out from the software project based on the entry file and the found target file.
[0077] Based on the entry file and the found target file, there are two ways to split micro-applications from the software project:
[0078] First, based on the entry file and the found target file, the specific process of splitting the micro-application from the software project can include the following steps: migrating the entry file and the target file of the micro-application to the corresponding designated migration location of the micro-application; for the files migrated to the designated migration location, based on the storage address of the files on which the files depend in the designated migration location, modifying the corresponding dependency path of the files.
[0079] In the present embodiment, it is necessary to set a corresponding designated migration location for the micro-application, and the designated migration location is used to store files related to the micro-application separately. The entry file and the target file of the micro-application are migrated to the designated migration location corresponding to the micro-application, just to realize that the micro-application is split out from the software project. When the entry file and the target file of the micro-application are migrated to the designated migration location, in order to avoid the impact of migration on the software project, the entry file and the target file are essentially copied to the designated migration location.
[0080] Files that need to rely on other files when executed in a software project have dependency paths, which are used to characterize the files that the execution file depends on. After the entry file and the target file are migrated to the specified migration location, the storage addresses of these files will inevitably change relative to their previous storage addresses in the software project. Therefore, in order to ensure that these files can still call the files they depend on through the dependency path after migration, for files migrated to the specified migration location, it is necessary to modify the corresponding dependency path of the file based on the storage address of the file that the file depends on in the specified migration location.
[0081] Exemplarily, the corresponding files of micro application 1 include an entry file and a file 1 on which the entry file depends. After the entry file and file 1 of the micro application are migrated to the specified migration location, the corresponding dependency path of the entry file is modified based on the storage address 1 of file 1 in the specified migration location.
[0082] The second method is to split the micro-application from the software project based on the entry file and the found target file, and the specific process of splitting the micro-application from the software project may include the following steps: detect whether the entry file and the target file of the micro-application contain common files that are common to other micro-applications in the software project; if so, migrate the files except the common files in the entry file and the target file of the micro-application to the corresponding designated migration location of the micro-application, and migrate the common files to the common migration location; for the files migrated to the corresponding migration location, modify the corresponding dependency path of the file based on the storage address of the file on which the file depends in the corresponding migration location.
[0083] Considering that there may be common files in the software project files that are used by two or more micro-applications, in order to reduce the number of files of the split micro-applications, these common files can be placed in a common migration location for the corresponding micro-applications to call.
[0084] Methods for detecting whether the entry file and target file of a micro-application have common files common to other micro-applications in the software project may include the following two methods:
[0085] First, based on the dependency relationship between the entry file and the target file of the micro-application, a corresponding first dependency path is obtained; based on the dependency relationship between the entry file and the target file of other micro-applications in the software project, a corresponding second dependency path is obtained; and from the tail of the first dependency path and the second dependency path, a comparison is made from the front to the back to see whether there are identical files. If so, the identical files are determined as common files.
[0086] Exemplarily, the first dependency path is: entry file 1-file 1-file 2-file 3-file 4. The second dependency path is: entry file 2-file 5-file 3-file 4. After comparison, it is found that file 3 and file 4 are common files.
[0087] Second, based on the dependency relationship between the entry file and the target file of the micro-application and the dependency relationship between the entry file and the target file of other micro-applications in the software project, a topology map is obtained; if there is an intersection in the topology map, and the file at the intersection is associated with the micro-application and at least one of the other micro-applications, it is determined that there are common files common to other micro-applications in the software project.
[0088] In this embodiment, in order to more accurately and intuitively view the common files between a micro-application and other micro-applications in a software project, a corresponding topology map is constructed based on the dependency relationship between the entry file and the target file of the micro-application and the dependency relationship between the entry file and the target file of other micro-applications in the software project. The topology map is used to indicate the dependency relationship between files.
[0089] If there is an intersection in the topology map, and the file at the intersection is associated with the micro-application and at least one of the other micro-applications, it means that the file at the intersection is common to the micro-application and at least one of the other micro-applications. Therefore, it is determined that there is a common file common to other micro-applications in the software project, and the file at the intersection is determined as a common file.
[0090] If there is no intersection in the topology map, or there is an intersection in the topology map and the file at the intersection is only associated with the micro-application, it means that there is no file common to the micro-application and at least one of the other micro-applications, so it is determined that there is no common file common to other micro-applications in the software project.
[0091] After determining the common files, migrate the files other than the common files in the entry files and target files of the micro-application to the corresponding designated migration location of the micro-application, and migrate the common files to the common migration location. It should be noted that when migrating common files to the common migration location, in order to avoid duplicate storage in the common migration location, it is necessary to detect whether the common files already exist in the common migration location. If they are stored, it is determined that the corresponding common files do not need to be migrated to the common migration location. If they are not stored, the corresponding common files are migrated to the common migration location.
[0092] Files that need to rely on other files when executed in a software project have dependency paths, and dependency paths are used to characterize the files that the execution files rely on. After migrating the entry files and target files of the micro-application except for common files to the corresponding designated migration location of the micro-application, and migrating the common files to the common migration location, the storage addresses of these files will inevitably change relative to the previous storage addresses in the software project. Therefore, in order to ensure that these files can still be called to the files they depend on through the dependency path after migration, for files migrated to the corresponding migration location, the corresponding dependency path of the file is modified based on the storage address of the file on which the file depends in the corresponding migration location.
[0093] Specifically, if the dependent file is a file migrated to a specified migration location, the storage address is the storage address of the corresponding file in the specified migration location. If the dependent file is a file migrated to a universal migration location, the storage address is the storage address of the corresponding file in the universal migration location.
[0094] Exemplarily, the corresponding files of micro application 1 include entry file, file 1, file 2, file 3 and file 4. The dependency relationship between the entry file and other files is: entry file-file 1-file 2-file 3-file 4. After detection, it is determined that file 3 and file 4 are common files of micro application 1 and other micro applications in the software project. The entry file of micro application 1 and the files "file 1 and file 2" other than the common files "file 3 and file 4" are migrated to the corresponding designated migration position of micro application 1, and the common files "file 3 and file 4" are migrated to the common migration position. For the files migrated to the corresponding migration position, based on the storage address of the file on which the file depends in the corresponding migration position, the corresponding dependency path of the file is modified. For example, if the file on which the entry file depends is file 1 migrated to the designated migration position, then based on the storage address 1 of file 1 in the designated migration position, the corresponding dependency path of the entry file is modified. If the file on which file 1 depends is file 2 migrated to the designated migration position, then based on the storage address 2 of file 2 in the designated migration position, the corresponding dependency path of file 1 is modified. If the file that file 2 depends on is file 3 that is migrated to the universal migration location, then based on the storage address 3 of file 3 in the universal migration location, modify the corresponding dependency path of file 2. If the file that file 3 depends on is file 4 that is migrated to the universal migration location, then based on the storage address 4 of file 4 in the universal migration location, modify the corresponding dependency path of file 3.
[0095] The above two methods of splitting micro-applications from software projects based on the entry file and the found target file can be flexibly selected based on specific business, and this embodiment does not limit this. After splitting the micro-applications from the software project, the micro-applications can be independently deployed and managed.
[0096] The method for splitting a software project provided by an embodiment of the present application determines the micro-application to be split from the software project when it is necessary to split a micro-application from the software project. In the files of the software project, the entry file of the micro-application is determined, and the target file having a dependency relationship with the entry file is searched. Based on the entry file and the target file found, the micro-application is split from the software project. It can be seen that the scheme provided by the embodiment of the present application performs dependency analysis on the files of the software project based on the entry file corresponding to the micro-application, and splits the corresponding micro-application from the software project based on the entry file and the file having a dependency relationship with the entry file, so that errors such as missing files or extra files that do not belong to the split micro-application can be reduced.
[0097] Furthermore, an embodiment of the present application also provides a software project splitting device, such as Figure 2 As shown, the splitting device of the software project includes:
[0098] A determination module 21, used to determine the micro-application to be separated from the software project;
[0099] A search module 22 is used to determine the entry file of the micro-application in the files of the software project, and to search for a target file that has a dependency relationship with the entry file;
[0100] The splitting module 23 is used to split the micro-application from the software project based on the entry file and the found target file.
[0101] The software project splitting device provided in the embodiment of the present application determines the micro-application to be split from the software project when it is necessary to split the micro-application from the software project. In the files of the software project, the entry file of the micro-application is determined, and the target file with a dependency relationship with the entry file is found. Based on the entry file and the found target file, the micro-application is split from the software project. It can be seen that the solution provided in the embodiment of the present application performs dependency analysis on the files of the software project based on the entry file corresponding to the micro-application, and splits the corresponding micro-application from the software project based on the entry file and the file with a dependency relationship with the entry file, which can reduce the errors such as missing files or extra files that do not belong to the split micro-application.
[0102] In some embodiments of the present application, Figure 3 As shown, the search module 22 includes:
[0103] A first determining unit 221, configured to determine the entry file as a current file;
[0104] A search unit 222, used to search for a dependency path of the current file, where the dependency path is used to represent a file that the current file depends on when executing the current file;
[0105] The detection unit 223 is used to detect whether the file represented by the found dependency path is a file of the software project, and if so, trigger the second determination unit 224 to determine the corresponding file as a target file having a dependency relationship with the entry file;
[0106] The third determining unit 225 is used to use the target file determined by the second determining unit 224 as a new current file, and trigger the searching unit 222 to cyclically execute the step of searching for a dependent path of the new current file until the dependent path is not found, or the dependent path is found and the file represented by the dependent path is not a file of the software project;
[0107] The first determination unit 221 , the search unit 222 , the detection unit 223 , the second determination unit 224 , and the third determination unit 225 are configured to be executed for each entry file.
[0108] In some embodiments of the present application, Figure 3 As shown, the search unit 222 is specifically used to search whether the target string is included in the abstract syntax tree corresponding to the current file, the abstract syntax tree is constructed based on the file content of the current file, and the target string is used to identify the dependency path of the current file; if included, the dependency path identified by the target string is found.
[0109] In some embodiments of the present application, Figure 3 As shown, if the software project uses the storage path of the file as the dependent path, the detection unit 223 is specifically used to match the found dependent path with the storage path of the file of the software project; if the match is successful, it is detected that the file represented by the found dependent path is the file of the software project.
[0110] In some embodiments of the present application, Figure 3 As shown, if the software project uses the data obtained by simplifying the storage path of the file as the dependent path, then the detection unit 223 is specifically used to restore the found dependent path into a corresponding target storage path; match the target storage path with the storage path of the file of the software project; if the match is successful, it is detected that the file represented by the found dependent path is a file of the software project.
[0111] In some embodiments of the present application, Figure 3 As shown, the search module 22 also includes:
[0112] The judging unit 226 is used to judge whether the current file is a source code file; if so, trigger the searching unit 222 to execute the step of searching for the dependency path of the current file; if not, determine that the current file does not have a dependency path.
[0113] In some embodiments of the present application, Figure 3 As shown, there is a dependency path for files that need to rely on other files when executing in the software project, and the dependency path is used to characterize the files that the execution file depends on. Then, the splitting module 23 includes:
[0114] The first splitting unit 231 is used to migrate the entry file and the target file of the micro-application to the designated migration location corresponding to the micro-application; for the file migrated to the designated migration location, based on the storage address of the file on which the file depends in the designated migration location, modify the corresponding dependency path of the file.
[0115] In some embodiments of the present application, Figure 3As shown, there is a dependency path for files that need to rely on other files when executing in the software project, and the dependency path is used to characterize the files that the execution file depends on. Then, the splitting module 23 includes:
[0116] The second splitting unit 232 is used to detect whether the entry file and the target file of the micro-application have common files that are common to other micro-applications in the software project; if so, the files other than the common files in the entry file and the target file of the micro-application are migrated to the corresponding designated migration position of the micro-application, and the common files are migrated to the common migration position; for the files migrated to the corresponding migration position, based on the storage address of the files on which the files depend in the corresponding migration position, the corresponding dependency path of the files is modified; wherein, if the dependent file is a file migrated to the designated migration position, the storage address is the storage address of the corresponding file in the designated migration position, and if the dependent file is a file migrated to the common migration position, the storage address is the storage address of the corresponding file in the common migration position.
[0117] In some embodiments of the present application, Figure 3 As shown, the second splitting unit 232 is specifically used to obtain a topology map based on the dependency relationship between the entry file and the target file of the micro-application and the dependency relationship between the entry file and the target file of other micro-applications in the software project; if there is an intersection in the topology map, and the file located at the intersection is associated with the micro-application and at least one of the other micro-applications, it is determined that there are common files common to other micro-applications in the software project.
[0118] In some embodiments of the present application, Figure 3 As shown, the determination module 21 is specifically used to detect whether a split instruction is received in the command line tool; if so, the micro-application specified by the split instruction is determined as the micro-application to be split from the software project.
[0119] In the software project splitting device provided in the embodiment of the present application, the detailed explanation adopted during the operation of each functional module can be found in the corresponding detailed explanation of the above-mentioned software project splitting method embodiment, which will not be repeated here.
[0120] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein when the program is run, the device where the storage medium is located is controlled to execute the above-mentioned method for splitting the software project.
[0121] Furthermore, an embodiment of the present application also provides an electronic device, comprising: a memory for storing a program; and a processor, coupled to the memory, for running the program to execute the above-mentioned method for splitting a software project.
[0122] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0123] It is understandable that the related features in the above methods and devices can be referenced to each other. In addition, the "first", "second" and the like in the above embodiments are used to distinguish the embodiments, but do not represent the advantages and disadvantages of the embodiments.
[0124] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0125] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the application is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the application described herein, and the description of the above specific language is to disclose the preferred embodiment of the application.
[0126] In addition, the memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0127] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0128] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data cutover device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data cutover device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0129] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data switching device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0130] These computer program instructions can also be loaded onto a computer or other programmable data transfer device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0131] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0132] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0133] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0134] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0136] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for splitting a software project, characterized in that: The method comprises: Identify the micro-applications to be split out of the software project; In the files of the software project, determine the entry file of the micro-application, and search for the target file that has a dependency relationship with the entry file; Based on the entry file and the found target file, the micro-application is split out from the software project.
2. The method according to claim 1, characterized in that Find the target files that have dependencies with the entry file, including: For each of the entry files: the entry file is determined as the current file, and the dependency path of the current file is searched, the dependency path is used to represent the files that the current file depends on when executing, and it is detected whether the file represented by the found dependency path is a file of the software project. If so, the corresponding file is determined as a target file that has a dependency relationship with the entry file, and the determined target file is used as the new current file. The step of searching for the dependency path of the new current file is executed in a loop until the dependency path is not found, or the dependency path is found and the file represented by the dependency path is not a file of the software project.
3. The method according to claim 2, characterized in that Find the dependency path of the current file, including: Finding whether an abstract syntax tree corresponding to the current file includes a target string, the abstract syntax tree being constructed based on the file content of the current file, and the target string being used to identify a dependency path of the current file; If included, find out the dependent path identified by the target string.
4. The method according to claim 2, characterized in that: If the software project uses the storage path of the file as the dependent path, then detecting whether the file represented by the found dependent path is a file of the software project includes: Matching the found dependency path with the storage path of the files of the software project; If the match is successful, it is detected that the file represented by the found dependency path is a file of the software project.
5. The method according to claim 2, characterized in that: If the software project uses data obtained by simplifying the storage path of the file as the dependent path, then detecting whether the file represented by the found dependent path is a file of the software project includes: Restore the found dependent path to the corresponding target storage path; Matching the target storage path with the storage path of the files of the software project; If the match is successful, it is detected that the file represented by the found dependency path is a file of the software project.
6. The method according to any one of claims 2 to 5, characterized in that: The method further comprises: Determine whether the current file is a source code file; If yes, then executing the step of searching the dependency path of the current file; If not, it is determined that the current file does not have a dependent path.
7. The method according to claim 1, characterized in that There is a dependency path for files that need to rely on other files when executed in the software project, and the dependency path is used to characterize the files that the files depend on when executing. Then, based on the entry file and the found target file, the micro-application is split out from the software project, including: Migrate the entry file and target file of the micro-application to the designated migration location corresponding to the micro-application; For a file migrated to the designated migration location, a corresponding dependency path of the file is modified based on a storage address of a file on which the file depends in the designated migration location.
8. The method according to claim 1, characterized in that There is a dependency path for files that need to rely on other files when executed in the software project, and the dependency path is used to characterize the files that the files depend on when executing. Then, based on the entry file and the found target file, the micro-application is split out from the software project, including: Detect whether the entry file and the target file of the micro-application have common files that are common to other micro-applications in the software project; If it exists, migrate the entry file and target files of the micro-application except the common files to the designated migration location corresponding to the micro-application, and migrate the common files to the common migration location; For a file migrated to a corresponding migration location, the corresponding dependency path of the file is modified based on the storage address of the file on which the file depends in the corresponding migration location; wherein, if the dependent file is a file migrated to the designated migration location, the storage address is the storage address of the corresponding file in the designated migration location; if the dependent file is a file migrated to the universal migration location, the storage address is the storage address of the corresponding file in the universal migration location.
9. The method according to claim 8, characterized in that Detecting whether the entry file and the target file of the micro-application are common files common to other micro-applications in the software project includes: Based on the dependency relationship between the entry file and the target file of the micro-application and the dependency relationship between the entry files and the target files of other micro-applications in the software project, a topology map is obtained; If there is an intersection in the topology graph, and the file at the intersection is associated with the micro-application and at least one of the other micro-applications, it is determined that there is a common file that is common to other micro-applications in the software project.
10. The method according to any one of claims 1-5, 7-9, characterized in that: Identify the micro-applications to be separated from the software project, including: Check whether the splitting instruction is received in the command line tool; If so, the micro-application specified by the split instruction is determined as the micro-application to be split from the software project.
11. A software project splitting device, characterized in that: The device comprises: A determination module, used to determine the micro-applications to be separated from the software project; A search module, used to determine the entry file of the micro-application in the files of the software project, and to search for a target file that has a dependency relationship with the entry file; A splitting module is used to split the micro-application from the software project based on the entry file and the found target file.
12. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the method for splitting a software project as described in any one of claims 1 to 10.
13. An electronic device, characterized in that: The electronic device comprises: Memory, used to store programs; A processor, coupled to the memory, is used to run the program to execute the software project splitting method described in any one of claims 1 to 10.
Citation Information
Cited By
Component splitting, docking and loading processing method and device for application project
CN119225857A
A component splitting, interfacing and loading processing method and device for application project
CN119225857B
