Compilation methods, devices, equipment and media for software engineering

By loading custom configuration files, the automatic switching of binary to source code in software engineering is realized, which improves compilation efficiency and simplifies the debugging process, and solves the problem of intrusion of the overall project source code.

CN114138281BActive Publication Date: 2025-01-14JINGDONG TECH HLDG CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111493903.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-08
Publication Date
2025-01-14
Estimated Expiration
2041-12-08

AI Technical Summary

Technical Problem

In the prior art, the compilation process of software engineering requires manual modification of the compilation script configuration file, resulting in inefficient compilation efficiency, and the overall engineering source code is easily invaded, and binary type dependencies cannot be debugged, resulting in complex overall debugging of multiple modules.

Method used

By loading a pre-generated custom configuration file, including source code type dependency information, automatically replacing the dependency identifier and path in the compiled script configuration file, thereby realizing automatic switching between binary and source code, without manually modifying the configuration file, only in memory Data modification.

Benefits of technology

It improves the compilation efficiency of software engineering, realizes automatic replacement of dependency information, simplifies the overall debugging of multiple modules, avoids the problem of intrusion of the overall engineering source code, and does not require modification of the compilation script configuration file.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138281B_ABST
    Figure CN114138281B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a software engineering compilation method, device, equipment and medium. The method loads a pre-generated custom configuration file upon receiving a compilation command to load dependency information corresponding to the dependency of the source code type in the custom configuration file, and then searches for a dependency with the same dependency identifier as the dependency identifier of the current source code type in the configuration file of the loaded compilation script, replaces the found dependency information with the dependency information of the current source code type, and performs the compilation operation of the software engineering based on the configuration file of the updated compilation script, thereby realizing the automatic replacement of dependency information during the compilation process of the software engineering, thereby realizing the automatic switching from binary to source code; the developer does not need to manually modify the configuration file, and only needs to execute the compilation command to complete the switching from binary to source code, thereby improving the compilation efficiency of the software engineering and solving the technical problem of the overall engineering source code being invaded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a compilation method, device, equipment and medium for software engineering. Background Art

[0002] As the amount of engineering code in Android projects increases, the industry adopts a component-based development approach. All business modules are independent warehouses, and the business modules are decoupled from each other. Binary dependencies are used during packaging, and the aar library files compiled by the module are directly dependent on the Maven tool.

[0003] In the process of implementing the present invention, it is found that there are at least the following problems in the prior art:

[0004] After all business and basic modules are fully binarized, new problems are introduced: Under the existing model, if developers need to debug the code of a module, they need to modify the dependent type in the module to the source code type in the compilation script configuration file of the compilation tool (such as the gradle tool) before compilation, and the developer needs to actively download the dependent source code, write the local storage path of the source code in the compilation script configuration file, and then use the modified compilation script configuration file to perform the compilation operation. The above compilation process requires modifying the compilation script configuration file, which will intrude on the overall project source code, and requires multiple manual operations, resulting in low compilation efficiency. Summary of the invention

[0005] The embodiments of the present invention provide a software engineering compilation method, device, equipment and medium to improve the compilation efficiency of software engineering and solve the technical problem of the overall engineering source code being invaded.

[0006] In a first aspect, an embodiment of the present invention provides a software engineering compilation method, comprising:

[0007] When receiving a compile command, loading a pre-generated custom configuration file; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency;

[0008] For the dependencies of each source code type, in the configuration file of the loaded compilation script, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type, and replace the found dependency information with the dependency information of the current source code type;

[0009] Based on the updated configuration file of the compilation script, the software engineering compilation operation is performed.

[0010] In a second aspect, an embodiment of the present invention further provides a software engineering compilation device, the device comprising:

[0011] A configuration file loading module, used to load a pre-generated custom configuration file upon receiving a compile command; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency;

[0012] A dependency information replacement module is used to search for a dependency with a dependency identifier identical to the dependency identifier of the current source code type in the configuration file of the loaded compilation script for the dependency of each source code type, and replace the found dependency information with the dependency information of the current source code type;

[0013] The compile operation execution module is used to execute the software engineering compile operation based on the configuration file of the updated compile script.

[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0015] one or more processors;

[0016] a storage device for storing one or more programs,

[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the software engineering compilation method provided by any embodiment of the present invention.

[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a software engineering compilation method as provided in any embodiment of the present invention.

[0019] The embodiments of the above invention have the following advantages or beneficial effects:

[0020] When a compilation command is received, a pre-generated custom configuration file is loaded to load the dependency information corresponding to the dependency of the source code type in the custom configuration file, and then in the configuration file of the loaded compilation script, a dependency with a dependency identifier identical to the dependency identifier of the current source code type is searched, the dependency information found is replaced with the dependency information of the current source code type, and the compilation operation of the software project is performed based on the configuration file of the updated compilation script, thereby realizing automatic replacement of dependency information during the compilation process of the software project, thereby realizing automatic switching from binary to source code; there is no need for developers to manually modify the configuration file, and only the compilation command needs to be executed to complete the switching from binary to source code, thereby improving the compilation efficiency of the software project; and, the method does not need to modify the compilation script configuration file, and only the memory data needs to be modified to complete the switching from binary to source code, thereby solving the technical problem of the overall engineering source code being invaded. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A flowchart of a software engineering compilation method provided in the first embodiment of the present invention;

[0023] Figure 2A A schematic diagram of a flow chart of a software engineering compilation method provided in Embodiment 2 of the present invention;

[0024] Figure 2B A schematic diagram of a flow chart of a method for generating a custom configuration file provided in the second embodiment of the present invention;

[0025] Figure 3A A flowchart of a software engineering compilation method provided by Embodiment 3 of the present invention;

[0026] Figure 3B A schematic diagram of a flow chart of a method for generating an original configuration file provided in Embodiment 3 of the present invention;

[0027] Figure 4 A schematic diagram of the structure of a software engineering compiling device provided by a fourth embodiment of the present invention;

[0028] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0029] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0030] Embodiment 1

[0031] Figure 1 This is a flowchart of a software engineering compilation method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where binary to source code switching is automatically performed during the compilation process of the software engineering. The method can be executed by a software engineering compilation device, which can be implemented by hardware and / or software. The method specifically includes the following steps:

[0032] S110. When a compilation command is received, a pre-generated custom configuration file is loaded; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each dependency information includes a dependency identifier, a dependency type and a local storage path of the source code of the corresponding dependency.

[0033] In this embodiment, the compile command may be generated according to a manual trigger of a user, for example, if it is detected that a user triggers a compile control, a compile command is generated; or the compile command may also be automatically triggered and generated by a compile server.

[0034] Specifically, when receiving a compilation command, the present embodiment can load a pre-generated custom configuration file, and read the information in the custom configuration file into the memory to obtain the dependency information corresponding to each dependency in the custom configuration file. Among them, the custom configuration file may contain dependency information corresponding to at least one source code type dependency. It should be noted that the source code type dependency in the custom configuration file is obtained by type conversion of the binary type dependency, which is still a binary type dependency in the configuration file of the loaded compilation script. Therefore, it is necessary to further replace the dependency information of the source code type dependency in the configuration file of the compilation script. That is, for the source code type dependency in the custom configuration file, it is necessary to further replace its dependency information in the configuration file of the compilation script.

[0035] Of course, the custom configuration file may also contain dependency information corresponding to at least one binary type dependency. Among them, the binary type dependency in the custom configuration file may be a binary dependency that does not require binary to source code switching. Exemplarily, the source code type dependency may be a source dependency, and the binary type dependency may be a bin dependency.

[0036] Specifically, the dependency information of each source code type in the custom configuration file (i.e., the dependency information corresponding to the dependency of each source code type) includes the dependency identifier, the dependency type, and the local storage path of the source code. Among them, the local storage path of the source code can be the local storage information of the source code downloaded after the dependency type of the binary type (i.e., the dependency type of the dependency of the binary type) is changed to the source code type; the source code can be obtained based on the local storage path of the source code.

[0037] S120. For the dependencies of each source code type, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type in the configuration file of the loaded compilation script, and replace the found dependency information with the dependency information of the current source code type.

[0038] That is, for the dependency of each source code type, in the configuration file of the loaded compilation script, search for a dependency whose dependency identifier is the same as the dependency identifier of the dependency of the current source code type, and replace the dependency information of the found dependency with the dependency information of the current source code type.

[0039] In this embodiment, for the dependencies of each source code type in the custom configuration file, the dependency with the same dependency identifier can be searched in the configuration file of the loaded compilation script according to the dependency identifier of the current source code type (i.e., the dependency identifier of the dependency of the current source code type). Among them, the configuration file of the loaded compilation script can contain the dependency information of all dependencies of the software project. That is, the dependency information of all dependencies in the configuration file of the loaded compilation script has been read into the memory of the compilation tool.

[0040] Exemplarily, the dependency identifier may be a dependent project organization identifier (groupID) or a dependent project identifier (artifactID), or the dependency identifier may be a combination of groupID and artifactID, which is not limited in this embodiment.

[0041] Further, after finding a dependency whose dependency identifier is the same as the dependency identifier of the current source code type, the found dependency information can be replaced with the dependency information of the current source code type in the memory of the compilation tool to modify the dependency of the software engineering. That is, after finding a dependency whose dependency identifier is the same as the dependency identifier of the dependency of the current source code type, the dependency information of the dependency can be replaced with the dependency information of the dependency of the current source code type in the memory of the compilation tool.

[0042] S130: Execute a software engineering compilation operation based on the configuration file of the updated compilation script.

[0043] Specifically, this embodiment performs a software engineering compilation operation according to the configuration file of the updated compilation script in the memory.

[0044] In an optional implementation, the software engineering compilation method provided in this embodiment is executed by a plug-in module of a compilation tool. In another optional implementation, upon receiving a compilation command, the operation of loading a pre-generated custom configuration file, and, for each of the dependencies of the source code types, searching for a dependency with a dependency identifier that is the same as the dependency identifier of the current source code type (i.e., the dependency identifier of the dependency of the current source code type) in the configuration file of the loaded compilation script, and replacing the dependency information corresponding to the found dependency with the dependency information corresponding to the dependency of the current source code type, can be executed by the plug-in module of the compilation tool; the operation of executing the software engineering compilation operation based on the configuration file of the updated compilation script can be executed by the compilation module of the compilation tool.

[0045] That is, through the plug-in module of the compilation tool, a pre-generated custom configuration file is loaded, and for the dependencies of each source code type, in the configuration file of the loaded compilation script, a dependency with the same dependency identifier as the dependency identifier of the current source code type (i.e., the dependency identifier of the dependency of the current source code type) is searched, and the dependency information found (i.e., the dependency information of the found dependency) is replaced with the dependency information of the current source code type (i.e., the dependency information of the dependency of the current source code type); through the compilation module of the compilation tool, based on the configuration file of the updated compilation script, a software engineering compilation operation is performed. Exemplarily, the compilation tool is a Gradle tool.

[0046] It should be noted that in the prior art, when modifying a method or class of a library, due to the invisibility of binary code, if the developer is negligent and does not modify all the calling functions, it is very likely to generate runtime exceptions (such as ClassNotFoundException, MethodNotFoundException), that is, the problem is exposed after the software is released or run; the technical solution of this embodiment switches the project to source code mode compilation before compilation. If the problem of not all calling functions being modified occurs, the compilation fails, and the problem is exposed during the compilation period, which is convenient for developers to modify the problem in time. In addition, in the prior art, binary type dependencies cannot be debugged, and usually require R&D personnel to manually modify the configuration file of the compilation script to modify the binary type dependency to the source code type dependency, making the overall debugging of multiple modules complicated, and the technical solution of this application can automatically modify the configuration file of the compilation script, which is convenient for the overall debugging of multiple modules.

[0047] Considering that there is a situation where there is no custom configuration file locally during software engineering compilation, optionally, before loading the pre-generated custom configuration file in S110, this embodiment further includes: determining whether the local contains the custom configuration file, and if so, performing the operation of loading the custom configuration file. Optionally, if the local does not contain the custom configuration file, the software engineering compilation operation can be performed directly based on the configuration file of the loaded compilation script.

[0048] The technical solution of this embodiment is to load a pre-generated custom configuration file when a compilation command is received to load the dependency information corresponding to the dependency of the source code type in the custom configuration file, and then in the configuration file of the loaded compilation script, search for the dependency whose dependency identifier is the same as the dependency identifier of the current source code type, replace the found dependency information with the dependency information of the current source code type, and perform the compilation operation of the software project based on the updated configuration file of the compilation script, thereby realizing the automatic replacement of dependency information in the software project compilation process, thereby realizing the automatic switching from binary to source code, and improving the compilation efficiency of the software project; and, the method does not need to modify the compilation script configuration file, only the memory data can be modified to complete the switching from binary to source code, solving the technical problem of the overall project source code being invaded.

[0049] Embodiment 2

[0050] Figure 2A A flowchart of a software engineering compilation method provided in the second embodiment of the present invention, based on the above embodiment, optionally, before receiving the compilation command, the method further includes: loading a pre-generated original configuration file upon receiving a switch command; wherein the original configuration file contains dependency information corresponding to each binary type of dependency in the software engineering; modifying the dependency type of some or all dependencies in the original configuration file to a source code type according to the switch command; for each dependency modified to a source code type, obtaining the local storage path of the source code of the dependency currently modified to the source code type, adding the local storage path as the dependency information currently modified to the source code type to the original configuration file; and saving the current original configuration file as a custom configuration file. The explanations of the terms identical or corresponding to the above embodiments are not repeated here. See Figure 2A The software engineering compilation method provided in this embodiment includes the following steps:

[0051] S210. When a switching command is received, load a pre-generated original configuration file; wherein the original configuration file contains dependency information corresponding to each binary type dependency in software engineering.

[0052] The switching command may be generated by a user triggering a switching control, or may be automatically triggered by a compile server. In this embodiment, the switching command may include a dependency identifier for which a dependency type switching is required, that is, a dependency identifier corresponding to a dependency for which a dependency type switching is required.

[0053] Optionally, the switching command includes: dependency identifiers of binary types corresponding to the modules to be debugged in the software project, or dependency identifiers of all binary types in the software project. Specifically, if one or more modules in the software project are debugged, the switching command may include dependency identifiers of binary types corresponding to the modules to be debugged (i.e., dependency identifiers of dependencies of binary types); if the software project is debugged as a whole, the switching command may include dependency identifiers of all binary types (i.e., dependency identifiers of dependencies of all binary types). This optional implementation corresponds to the module compilation and debugging scenario and the software project general package compilation and debugging scenario respectively.

[0054] Specifically, when receiving the switching command, the present embodiment can load the pre-generated original configuration file, read the information in the original configuration file into the memory, and obtain the dependency information corresponding to the dependency of each binary type in the original configuration file. The original configuration file contains the dependency information corresponding to the dependency of each binary type in the software engineering.

[0055] S220. Modify the dependency type of part or all of the dependencies in the original configuration file to a source code type according to the switching command.

[0056] In this embodiment, part or all of the dependencies in the original configuration file that need to switch dependency types can be determined according to the dependency identifier carried in the switching command, and further, the dependency types of the part or all of the dependencies can be modified to the source code type.

[0057] For example, if the switch command includes the dependency identifier "abcdf", then modifying it to the source type may be: gradle yolanda install id="abcdf" dependent_type="source". Specifically, the purpose of modifying the dependency type of a binary dependency is to facilitate debugging and avoid runtime exceptions when building a release package.

[0058] S230. For each dependency modified to a source code type, obtain a local storage path of the source code of the dependency currently modified to a source code type, and add the local storage path to the original configuration file as dependency information currently modified to a source code type.

[0059] That is, for each dependency modified to a source code type, obtain the local storage path of the source code of the dependency currently modified to a source code type, and add the local storage path as the dependency information of the dependency currently modified to a source code type to the original configuration file. In this embodiment, for each dependency modified to a source code type, it is necessary to obtain the local storage path of the source code of the dependency. The local storage path may be the storage location of the downloaded binary type dependency source code.

[0060] In a specific implementation, obtaining the local storage path of the source code of a dependency that is currently modified to a source code type includes: searching the local disk for the source code of the dependency that is currently modified to a source code type; if found, determining the storage path of the found source code on the local disk as the local storage path of the source code of the dependency that is currently modified to a source code type; if not found, downloading the source code according to the source code address in the dependency information corresponding to the dependency that is currently modified to a source code type, storing the downloaded source code on the local disk, and determining the storage path of the source code on the local disk as the local storage path of the source code of the dependency that is currently modified to a source code type.

[0061] Among them, the dependency information corresponding to the binary type dependency includes the source code address; when the code source of the dependency currently modified to the source code type is not available in the local disk, the source code can be requested and downloaded according to the source code address, and the downloaded source code can be stored in the local disk.

[0062] Furthermore, after obtaining the local storage path of the source code of the dependency currently modified to the source code type, the local storage path can be added to the original configuration file as the dependency information currently modified to the source code type (i.e., the dependency information of the dependency currently modified to the source code type).

[0063] S240: Save the current original configuration file as a custom configuration file, and when a compile command is received, load the pre-generated custom configuration file.

[0064] Specifically, in this embodiment, the original configuration file to which the local storage path of the source code of the dependency modified to the source code type is added can be used as a custom configuration file. The custom configuration file contains dependency information corresponding to at least one source code type dependency, each of which includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency.

[0065] S250. For the dependencies of each source code type in the custom configuration file, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type in the configuration file of the loaded compilation script, and replace the found dependency information with the dependency information of the current source code type.

[0066] That is to say, for the dependencies of each source code type in the custom configuration file, in the configuration file of the loaded compilation script, search for dependencies whose dependency identifiers are the same as the dependency identifiers of the dependencies of the current source code type, and replace the dependency information of the found dependencies with the dependency information of the current source code type.

[0067] S260: Execute a software engineering compilation operation based on the configuration file of the updated compilation script.

[0068] like Figure 2B As shown, a flow chart of a method for generating a custom configuration file is shown, the method comprising: loading a plug-in of a compilation tool; loading a pre-generated original configuration file, and changing the dependency type of some or all dependencies in the original configuration file to a source code type according to a dependency identifier in a switching command; determining whether there is source code for the dependency changed to a source code type on a local disk; if not, downloading the source code; and then adding the local storage path of the source code as dependency information of the corresponding dependency to the original configuration file to obtain a custom configuration file.

[0069] The technical solution of this embodiment, when receiving a switching command, loads a pre-generated original configuration file to obtain dependency information corresponding to all binary type dependencies in the software project, and then modifies the dependency type of some or all dependencies in the original configuration file to a source code type according to the switching command, and for each dependency modified to a source code type, adds the local storage path of its source code to the original configuration file to obtain a custom configuration file, thereby realizing the automatic generation of the custom configuration file, and then realizing the automatic replacement of dependency information during the compilation process of the software project, thereby improving the compilation efficiency of the software project; and, the method does not need to modify the compilation script configuration file, and only needs to modify the memory data to complete the binary to source code switch, thereby solving the technical problem of the overall project source code being invaded.

[0070] Embodiment 3

[0071] Figure 3A A flowchart of a software engineering compilation method provided in the third embodiment of the present invention. Based on the above embodiments, this embodiment optionally includes, before receiving a switching command, the method further comprising: upon receiving an analysis command, obtaining dependency types and dependency information storage paths corresponding to each dependency in the software engineering based on a configuration file of the loaded compilation script; for each binary type of dependency, remotely querying dependency information corresponding to the current binary type of dependency based on the dependency information storage path of the current binary type, and storing the dependency information in the original configuration file. Explanations of terms that are identical or corresponding to the above embodiments are not repeated here. See Figure 3A The software engineering compilation method provided in this embodiment includes the following steps:

[0072] S310: When an analysis command is received, the dependency type and dependency information storage path corresponding to each dependency in the software project are obtained based on the configuration file of the loaded compilation script.

[0073] The analysis command may be generated by a user through triggering an analysis control, or may be automatically triggered by a compile server. In this embodiment, the configuration file of the compile script contains dependency information of all dependencies of the software project; by loading the configuration information of the compile script, the dependency information of all dependencies contained in the configuration information of the compile script is loaded into the memory, and further, the dependency types and dependency information storage paths corresponding to all dependencies in the memory are read.

[0074] Optionally, the configuration file of the compilation script includes the compilation version of the software project, the version of the build tool of the software project, the package name of the software project, the minimum compatible version of the software project, the version number, the version name, the signature configuration, whether to obfuscate, and the dependency types and dependency information storage paths of all dependencies. For example, the configuration file of the compilation script includes: compileSdkVersion (the compilation version of the software project, that is, the compilation version used to specify the project), buildToolsVersion (the version of the build tool of the software project, that is, the version of the build tool used to specify the project), applicationId (the package name of the software project, that is, the package name used to specify the project), minSdkVersion (the minimum compatible version of the software project, that is, the minimum compatible version of the project), versionCode (version number), versionName (version name), signingConfig (signature configuration), minifyEnabled (whether to obfuscate), dependencies (including the dependency types and dependency information storage paths of all dependencies, that is, the dependency types and dependency information storage paths of all dependencies of the project). Specifically, the plug-in can obtain the dependency types and dependency information storage paths of all dependencies in the software project by loading the configuration file of the compilation tool. Exemplarily, a project dependency tree can be generated by loading the configuration file of the compilation tool, and then the dependency types and dependency information storage paths of all dependencies in the software project can be obtained based on the project dependency tree. Among them, the project dependency tree can be binary data in memory, and each dependency can include three fields, namely scope (dependency scope, such as compile, compileOnle), path (dependency information storage path, which can be a local project path or a library file (arr or jar file) storage path on the server), and type (dependency type).

[0075] In this embodiment, dependency types include binary type and source code type. Among them, the dependency information storage path of the binary type (i.e., the dependency information storage path of the binary type dependency) can be the storage path of the library file on the remote server; the dependency information storage path corresponding to the source code type dependency can be the local project path or the local library file path.

[0076] S320. For dependencies of each binary type, based on the dependency information storage path of the current binary type, remotely query the dependency information corresponding to the dependency of the current binary type, and store the dependency information in the original configuration file.

[0077] That is, for each binary type of dependency, based on the dependency information storage path of the current binary type of dependency, remotely query the dependency information corresponding to the current binary type of dependency. In this embodiment, for the binary type dependency in each dependency obtained, it is necessary to query its corresponding dependency information according to the dependency information storage path. Specifically, when the library files of the binary type dependency (such as arr, jar) are released, the dependency information will be uploaded to the server through the interface. When querying the binary type dependency information (i.e., the dependency information of the binary type dependency), the server can be queried based on the dependency information storage path to obtain the corresponding dependency information.

[0078] Furthermore, after querying the dependency information corresponding to the dependency of the current binary type, the dependency information of the dependency can be stored in the original configuration file. It should be noted that this embodiment can store the dependency information of all binary types in the software engineering into the original configuration file respectively in the above manner, that is, store the dependency information of all binary types of dependencies into the original configuration file.

[0079] Exemplarily, the dependency information corresponding to the dependency of the current binary type includes: dependency scope, dependency information storage path, dependency identifier, dependency type, and source code address. That is, the dependency information corresponding to the dependency of the binary type in the original configuration file may include dependency scope, dependency information storage path, dependency identifier, dependency type, and source code address. For example, the original configuration file is as follows:

[0080] "scope":"compile", / / Dependency scope

[0081] "path":"com.jd.stock.bm:jdstock:3.5.0_210727-20210727.154709-SNAPSHOT", / / Dependency information storage path. Specifically, the dependency information storage path consists of: groupID:artifactID:Version,

[0082] "id":"com.jd.stock.bm:jdstock", / / Dependency ID, use groupID:artifactID to form a dependency ID

[0083] "pathType":"bin", / / Dependency type (bin: binary type source: source code type)

[0084] "localPath":"xxxxx", / / Local storage path (if the source code has not been downloaded, this field is empty)

[0085] "source":{"git_path":"https: / / jcode.jdfmgt.com / git / JDStockSDK_v2_Android.git","git_tag":"jrpaas_3.5.0_210727"} / / When the dependency type is binary, the source code address of the binary dependency.

[0086] For example, Figure 3B As shown, a flow chart of a method for generating an original configuration file is shown. The method includes: loading a plug-in of a compilation tool; analyzing all dependencies of a software project based on the plug-in; generating original dependency structure data of the software project; obtaining dependency information of each binary type based on the original dependency structure data; and generating an original configuration file based on the dependency information of each binary type. Wherein, obtaining dependency information of a binary type (i.e., dependency information of dependencies of a binary type) based on the original dependency structure data may be: obtaining dependency information of dependencies from an mPaas server according to a storage path of dependency information of each binary type in the original dependency structure data (i.e., storage path of dependency information of dependencies of each binary type).

[0087] It should be noted that, in this embodiment, optionally, the original configuration file only contains binary dependency information that can query the source code. Specifically, since the binary library file on Maven can be developed by a third party, the binary library file developed by the third party does not have the corresponding source code and cannot query the corresponding source code. The original configuration file in this embodiment can be saved to a local disk (local project directory).

[0088] S330. When a switching command is received, load a pre-generated original configuration file, and modify the dependency type of part or all of the dependencies in the original configuration file to a source code type according to the switching command.

[0089] S340. For each dependency modified to a source code type, obtain a local storage path of the source code of the dependency currently modified to a source code type, and add the local storage path to the original configuration file as dependency information currently modified to a source code type.

[0090] That is, for each dependency that is modified to a source code type, obtain the local storage path of the source code of the dependency that is currently modified to a source code type, and add the local storage path as the dependency information of the dependency that is currently modified to a source code type to the original configuration file. Exemplarily, following the above example, after obtaining the local storage path of the source code of the dependency that is currently modified to a source code type, the localPath field in the original configuration file can be replaced with the local storage path.

[0091] S350: Save the current original configuration file as a custom configuration file, and when a compile command is received, load the pre-generated custom configuration file.

[0092] S360. For the dependencies of each source code type of the custom configuration file, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type in the configuration file of the loaded compilation script, and replace the found dependency information with the dependency information of the current source code type.

[0093] That is, for the dependencies of each source code type of the custom configuration file, in the configuration file of the loaded compilation script, search for dependencies whose dependency identifiers are the same as the dependency identifiers of the dependencies of the current source code type, and replace the dependency information of the found dependencies with the dependency information of the current source code type.

[0094] S370: Execute a software engineering compilation operation based on the configuration file of the updated compilation script.

[0095] Exemplarily, the steps of the software engineering compilation method provided in this embodiment are as follows:

[0096] Step 1: After receiving the analysis command, the compilation module of the compilation tool loads the configuration file of the compilation script and loads the plug-in module of the compilation tool. The plug-in module of the compilation tool obtains the dependency type and dependency information storage path corresponding to each dependency included in the current software project based on the loaded configuration file of the compilation script;

[0097] Step 2: The plug-in module of the compilation tool remotely queries the dependency information corresponding to each binary type based on the dependency information storage path of each binary type, and stores the dependency information in the original configuration file;

[0098] That is, in this step, the plug-in module of the compilation tool can remotely query the dependency information corresponding to each binary type of dependency according to the dependency information storage path of each binary type of dependency;

[0099] Step 3: After receiving the switching command, the compilation module of the compilation tool loads the configuration file of the compilation script and the plug-in module of the compilation tool, the plug-in module of the compilation tool loads the original configuration file, and modifies the dependency type in the dependency information specified by the switching command to the source code type in the original configuration file;

[0100] In this step, the plug-in module of the compilation tool can modify the dependency type in the dependency information of the dependency specified by the switch command to the source code type in the original configuration file;

[0101] Step 4: For the dependency of the current source code type in the original configuration file, the plug-in module of the compilation tool downloads the source code of the dependency according to the source code address in the dependency information corresponding to the dependency, and adds the local storage path of the source code as the dependency information corresponding to the dependency to the original configuration file to generate a custom configuration file; wherein the source code of the dependency may also be pre-downloaded to the local computer. If the source code of the dependency is not found locally, the source code of the dependency may be downloaded based on the source code address;

[0102] Step 5: After receiving the compile command, the compile module of the compile tool loads the configuration file of the compile script and the plug-in module of the compile tool. The plug-in module of the compile tool loads the custom configuration file. For each dependency in the custom configuration file, the plug-in module of the compile tool replaces the dependency information of the dependency that has been loaded into the memory from the configuration file of the compile script with the dependency information of the dependency in the custom configuration file.

[0103] Step 6: The compilation module of the compilation tool performs the project compilation operation based on the dependency information of each dependency currently in the memory.

[0104] The technical solution of this embodiment, when receiving an analysis command, can obtain the dependency types and dependency information storage paths corresponding to all dependencies in the software project through the configuration file of the loaded compilation script, query the corresponding dependency information according to the dependency information storage path for each binary type of dependency, and store the dependency information in the original configuration file, thereby realizing the generation of the original configuration file, and then realizing the automatic replacement of dependency information during the compilation process of the software project, and can automatically switch from binary to source code without the developer manually modifying the configuration file. The switch from binary to source code can be completed by executing the compilation command, thereby improving the compilation efficiency of the software project; and, the method does not need to modify the compilation script configuration file, and only needs to modify the memory data to complete the switch from binary to source code, thereby solving the technical problem of the overall project source code being invaded.

[0105] Embodiment 4

[0106] Figure 4 A structural diagram of a compilation device for software engineering provided in Embodiment 4 of the present invention is provided. This embodiment is applicable to the situation where binary to source code is automatically switched during the compilation process of the software engineering. The device specifically includes: a configuration file loading module 410, a dependency information replacement module 420 and a compilation operation execution module 430.

[0107] The configuration file loading module 410 is used to load a pre-generated custom configuration file upon receiving a compile command; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of which includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency;

[0108] The dependency information replacement module 420 is used to search for a dependency with the same dependency identifier as the dependency identifier of the current source code type in the configuration file of the loaded compilation script for the dependency of each source code type, and replace the found dependency information with the dependency information of the current source code type;

[0109] The compiling operation execution module 430 is used to execute the software engineering compiling operation based on the configuration file of the updated compiling script.

[0110] Optionally, the device also includes a custom saving module, which is used to load a pre-generated original configuration file when a switching command is received before a compilation command is received; wherein the original configuration file contains dependency information corresponding to each binary type of dependency in software engineering; according to the switching command, the dependency type of some or all dependencies in the original configuration file is modified to a source code type; for each dependency modified to a source code type, the local storage path of the source code of the dependency currently modified to the source code type is obtained, and the local storage path is added to the original configuration file as the dependency information currently modified to the source code type; and the current original configuration file is saved as a custom configuration file.

[0111] Optionally, the custom save module includes a local path acquisition unit, which is used to search the local disk for the source code of the dependency currently modified to the source code type; if found, the storage path of the found source code on the local disk is determined as the local storage path of the source code of the dependency currently modified to the source code type; if not found, the source code is downloaded according to the source code address in the dependency information corresponding to the dependency currently modified to the source code type, the downloaded source code is stored in the local disk, and the storage path of the source code on the local disk is determined as the local storage path of the source code of the dependency currently modified to the source code type.

[0112] Optionally, the switching command includes: a dependency identifier of a binary type corresponding to a module to be debugged in the software project, or dependency identifiers of all binary types in the software project.

[0113] Optionally, the device also includes an original file generation module, which is used to obtain the dependency type and dependency information storage path corresponding to each dependency in the software project based on the configuration file of the loaded compilation script before receiving the switching command when receiving the analysis command; for each binary type of dependency, based on the dependency information storage path of the current binary type, remotely query the dependency information corresponding to the dependency of the current binary type, and store the dependency information in the original configuration file.

[0114] Optionally, the dependency information corresponding to the dependency of the current binary type includes: dependency scope, dependency information storage path, dependency identifier, dependency type and source code address.

[0115] Optionally, the configuration file loading module 410 and the dependency information replacing module 420 are plug-in modules of a compilation tool, and the compilation operation execution module 430 is a compilation module of the compilation tool.

[0116] Optionally, the compilation tool is a Gradle tool.

[0117] In this embodiment, a pre-generated custom configuration file is loaded through a configuration file loading module when a compilation command is received, so as to load dependency information corresponding to the dependency of the source code type in the custom configuration file, and then through a dependency information replacement module, in the configuration file of the loaded compilation script, a dependency having a dependency identifier identical to the dependency identifier of the current source code type is searched, and the found dependency information is replaced with the dependency information of the current source code type, and the compilation operation of the software project is executed based on the configuration file of the updated compilation script through a compilation operation execution module, thereby realizing automatic replacement of dependency information during the compilation process of the software project, and thus realizing automatic switching from binary to source code; there is no need for developers to manually modify the configuration file, and only the compilation command needs to be executed to complete the switching from binary to source code, thereby improving the compilation efficiency of the software project; and, the method does not need to modify the compilation script configuration file, and only the memory data needs to be modified to complete the switching from binary to source code, thereby solving the technical problem of the overall engineering source code being invaded.

[0118] The software engineering compilation device provided in the embodiment of the present invention can execute the software engineering compilation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0119] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.

[0120] Embodiment 5

[0121] Figure 5 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The device 12 is typically an electronic device that undertakes the compilation function of determining software engineering.

[0122] like Figure 5 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 connecting the various components (including the memory 28 and the processing unit 16).

[0123] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0124] The electronic device 12 typically includes a variety of computer readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0125] The memory 28 may include computer device readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, the storage device 34 may be used to read and write non-removable, non-volatile magnetic media (non-removable, non-volatile magnetic media in Figure 5 is not shown, usually referred to as a "hard drive"). Although Figure 5Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a read-only optical disk (Compact Disc-ReadOnly Memory, CD-ROM), a digital video disk (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product 40, which has a set of program modules 42, which are configured to perform the functions of various embodiments of the present invention. The program product 40 may be stored in, for example, the memory 28, and such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment. The program module 42 generally performs the functions and / or methods in the embodiments described in the present invention.

[0126] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, mouse, camera, etc., and display), may also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) devices, tape drives, and data backup storage devices.

[0127] The processor 16 executes various functional applications and data processing by running the program stored in the memory 28, for example, the software engineering compilation method provided in the above embodiment of the present invention includes:

[0128] When receiving a compile command, loading a pre-generated custom configuration file; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency;

[0129] For the dependencies of each source code type, in the configuration file of the loaded compilation script, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type, and replace the found dependency information with the dependency information of the current source code type;

[0130] Based on the updated configuration file of the compilation script, the software engineering compilation operation is performed.

[0131] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the software engineering compilation method provided by any embodiment of the present invention.

[0132] Embodiment 6

[0133] Embodiment 6 of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the software engineering compilation method provided in any embodiment of the present invention are implemented. The method includes:

[0134] When receiving a compile command, loading a pre-generated custom configuration file; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency;

[0135] For the dependencies of each source code type, in the configuration file of the loaded compilation script, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type, and replace the found dependency information with the dependency information of the current source code type;

[0136] Based on the updated configuration file of the compilation script, the software engineering compilation operation is performed.

[0137] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0138] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0139] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0140] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0141] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A software engineering compilation method, characterized in that: include: When receiving a compile command, loading a pre-generated custom configuration file; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency; For the dependencies of each source code type, in the configuration file of the loaded compilation script, search for a dependency whose dependency identifier is the same as the dependency identifier of the current source code type, and replace the found dependency information with the dependency information of the current source code type; Based on the updated configuration file of the compilation script, perform the software engineering compilation operation; Before receiving the compile command, the method further includes: When receiving the switching command, loading the pre-generated original configuration file; wherein the original configuration file contains dependency information corresponding to each binary type dependency in the software engineering; Modify the dependency type of part or all of the dependencies in the original configuration file to a source code type according to the switching command; For each dependency modified to a source code type, obtain a local storage path of the source code of the dependency currently modified to a source code type, and add the local storage path as dependency information currently modified to a source code type to the original configuration file; Save the current original profile as a custom profile.

2. The method according to claim 1, characterized in that Get the local storage path of the source code of the dependency that is currently modified to the source code type, including: Search the local disk for the source code of the dependency that is currently modified to the source code type; If found, the storage path of the found source code on the local disk is determined as the local storage path of the dependent source code currently modified to the source code type; If not found, the source code is downloaded according to the source code address in the dependency information corresponding to the dependency currently modified to the source code type, the downloaded source code is stored in the local disk, and the storage path of the source code on the local disk is determined as the local storage path of the source code of the dependency currently modified to the source code type.

3. The method according to claim 1, characterized in that The switching command includes: a dependency identifier of a binary type corresponding to a module to be debugged in a software project, or dependency identifiers of all binary types in the software project.

4. The method according to claim 1, characterized in that: Before receiving the switching command, the method further includes: When receiving the analysis command, the dependency type and dependency information storage path corresponding to each dependency in the software project are obtained based on the configuration file of the loaded compilation script; For dependencies of each binary type, based on the dependency information storage path of the current binary type, the dependency information corresponding to the dependency of the current binary type is remotely queried, and the dependency information is stored in the original configuration file.

5. The method according to claim 4, characterized in that The dependency information corresponding to the dependency of the current binary type includes: The scope of dependency, dependency information storage path, dependency identifier, dependency type, and source code address.

6. The method according to any one of claims 1 to 5, characterized in that Loading a pre-generated custom configuration file and dependencies for each of the source code types through a plug-in module of the compilation tool, searching for a dependency with a dependency identifier identical to the dependency identifier of the current source code type in the configuration file of the loaded compilation script, and replacing the found dependency information with the dependency information of the current source code type; The software engineering compilation operation is performed through the compilation module of the compilation tool based on the configuration file of the updated compilation script.

7. The method according to claim 6, characterized in that The compilation tool is the Gradle tool.

8. A compiling device for software engineering, characterized in that: The device comprises: A configuration file loading module, used to load a pre-generated custom configuration file upon receiving a compile command; wherein the custom configuration file contains dependency information corresponding to at least one source code type dependency, each of the dependency information includes a dependency identifier, a dependency type, and a local storage path of the source code of the corresponding dependency; A dependency information replacement module is used to search for a dependency with a dependency identifier identical to the dependency identifier of the current source code type in the configuration file of the loaded compilation script for the dependency of each source code type, and replace the found dependency information with the dependency information of the current source code type; A compiling operation execution module, used to execute a software engineering compiling operation based on the updated compiling script configuration file; The device further comprises a custom saving module, which is used to load a pre-generated original configuration file before receiving a compile command and when receiving a switch command; wherein the original configuration file contains dependency information corresponding to each binary type of dependency in software engineering; according to the switch command, the dependency type of part or all of the dependencies in the original configuration file is modified to a source code type; for each dependency modified to a source code type, the local storage path of the source code of the dependency currently modified to the source code type is obtained, and the local storage path is added to the original configuration file as the dependency information currently modified to the source code type; and the current original configuration file is saved as a custom configuration file.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the software engineering compilation method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the software engineering compilation method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Application compiling method and device, electronic equipment and storage medium

    CN110659031A