Program module compiling method, computer device and program product
Patent Information
- Application Number
- CN202211481777.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-11-24
AI Technical Summary
然而,通过该方式进行程序模块编译,会导致工作量增大
[0044] The aforementioned program module compilation method, apparatus, computer device, storage medium, and computer program product, upon receiving a compilation request for an application module to be compiled, replace the compilation plugin management class corresponding to the module to be compiled with a proxy compilation plugin management class, thereby determining that the compilation plugin used to compile the module to be compiled is an application plugin. It then obtains the class information contained in the module to be compiled, determines the startup logic information and interface information corresponding to the module based on the class information, and finally compiles the module to be compiled into an application based on the application plugin, startup logic information, and interface information. Compared to the traditional method of compiling by adding extra code logic, this solution reduces the workload of module compilation by modifying the management class corresponding to the compilation plugin at the underlying level and compiling the module to be compiled into an application based on the modified compilation plugin and module class information.
Smart Images

Figure CN115904387B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for compiling program modules. Background Technology
[0002] With the development of computer technology, computer software development has gradually matured. Currently, modular programming is used in software development, where each module can be compiled independently. When compiling a module, it's necessary to verify its functionality and usability; that is, the module needs to be run independently to verify its code logic. Since modules cannot be run directly, they require modification. Currently, the common method for enabling program module execution is to modify the module's compilation script and add extra code logic to compile and run the program module. However, this method of compiling program modules leads to a significant increase in workload.
[0003] Therefore, the current method of compiling program modules has the drawback of being too labor-intensive. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for compiling program modules that can reduce the workload of compiling program modules, in order to address the above-mentioned technical problems.
[0005] In a first aspect, this application provides a method for compiling a program module, the method comprising:
[0006] Obtain the compilation request for the module to be compiled;
[0007] If the compilation request is an application compilation request, the compilation plugin management class corresponding to the module to be compiled is replaced with a proxy compilation plugin management class; the target location is the root file of the project where the module to be compiled is located; the proxy compilation plugin management class is used to indicate that the compilation plugin type corresponding to the module to be compiled is an application plugin type;
[0008] Based on the instructions of the proxy compilation plugin management class, determine the application plugins that belong to the application plugin type;
[0009] Based on the class information contained in the module to be compiled, determine the startup logic information, interface content information, and interface jump information corresponding to the module to be compiled;
[0010] The application plugin compiles the module to be compiled into an application based on the startup logic information, the interface content information, and the interface jump information.
[0011] In one embodiment, before obtaining the compilation request for the module to be compiled, the method further includes:
[0012] Obtain the standalone compilation plugin corresponding to the application compilation request, and configure the standalone compilation plugin in the root project file of the project where the module to be compiled is located.
[0013] In one embodiment, replacing the compiler plugin management class corresponding to the module to be compiled with a proxy compiler plugin management class includes:
[0014] Generate an original proxy compiler plugin management class that inherits from the compiler plugin management class;
[0015] By using the independent compilation plugin set in the target location, the compilation plugin type in the original proxy compilation plugin management class is changed from the resource manifest plugin type to the application plugin type, thus obtaining the proxy compilation plugin management class.
[0016] In one embodiment, before determining the startup logic information, interface content information, and interface transition information corresponding to the module to be compiled based on the class information contained in the module to be compiled, the method further includes:
[0017] The global configuration file of the module to be compiled is traversed to obtain the class name, class initialization code, class interface code and class interface jump code in the global configuration file, which are used as the class information contained in the module to be compiled.
[0018] In one embodiment, the process of generating the global configuration file includes:
[0019] When the module to be compiled is created, the application identifier, application version number and application name corresponding to the module to be compiled are obtained, and the class information in the module to be compiled is obtained.
[0020] Based on the application identifier, application version number, application name, and class information, a global configuration file corresponding to the module to be compiled is generated.
[0021] In one embodiment, determining the startup logic information, interface content information, and interface transition information corresponding to the module to be compiled based on the class information contained in the module to be compiled includes:
[0022] Based on the initialization code of the classes in the global configuration file, determine the classes called when the module to be compiled starts and the order in which each class is called, and obtain the startup logic information corresponding to the module to be compiled.
[0023] The interface content of the class in the module to be compiled is determined based on the interface code of the class in the global configuration file, and the interface content and the class name in the global configuration file are determined as the interface content information corresponding to the module to be compiled.
[0024] Based on the interface jump code of the class in the global configuration file and the class name in the global configuration file, determine the interface content information corresponding to other class names and the interface jump information corresponding to the module to be compiled; the other class names are the class names of classes contained in other modules outside the module to be compiled in the project where the module to be compiled is located.
[0025] In one embodiment, determining the interface content information corresponding to other class names as the interface jump information corresponding to the module to be compiled, based on the interface jump code of the class in the global configuration file and the class name in the global configuration file, includes:
[0026] In the class name of the global configuration file, determine the main interface class name of the module to be compiled, and use the interface content information corresponding to the main interface class name as the startup interface information of the module to be compiled.
[0027] Obtain other class names corresponding to the class names in the global configuration file, and determine the interface content information corresponding to the other class names as other jump interface information corresponding to the interface content information of the class name;
[0028] The startup interface information and the other jump interface information are determined as the interface jump information corresponding to the module to be compiled.
[0029] In one embodiment, the step of compiling the module to be compiled into an application by the application plugin based on the startup logic information, the interface content information, and the interface jump information includes:
[0030] Obtain the source code set corresponding to the module to be compiled; the source code set includes the call path; the call path represents the acquisition path for compiling the module to be compiled into the files required by the application.
[0031] The application plugin obtains the class file corresponding to the startup logic information, the class file corresponding to the interface content information, and the class file corresponding to the interface jump information from the call path. Based on the class file corresponding to the startup logic information, it generates the startup logic of the application, generates the content of each interface of the application based on the class file corresponding to the interface content information, and generates the jump information between each interface of the application based on the class file corresponding to the interface jump information, thus obtaining the functionally compiled application.
[0032] The application identifier, application version number, and application name are used as the identification information of the compiled application to obtain the application corresponding to the module to be compiled.
[0033] In one embodiment, obtaining the source code set corresponding to the module to be compiled includes:
[0034] The call paths of the class files corresponding to the startup logic information, the class files corresponding to the interface content information, and the class files corresponding to the interface jump information are stored in the source code set corresponding to the module to be compiled.
[0035] Secondly, this application also provides a program module compilation apparatus. The apparatus includes:
[0036] The first acquisition module is used to acquire the compilation request for the module to be compiled;
[0037] The modification module is used to replace the compilation plugin management class corresponding to the module to be compiled with a proxy compilation plugin management class if the compilation request is an application compilation request; the target location is the root file of the project where the module to be compiled is located; the proxy compilation plugin management class is used to indicate that the compilation plugin type corresponding to the module to be compiled is an application plugin type;
[0038] The determination module is used to determine the application plugins belonging to the application plugin type based on the instructions of the proxy compilation plugin management class;
[0039] The second acquisition module is used to determine the startup logic information, interface content information and interface jump information corresponding to the module to be compiled based on the class information contained in the module to be compiled.
[0040] The compilation module is used by the application plugin to compile the module to be compiled into an application based on the startup logic information, the interface content information, and the interface jump information.
[0041] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0042] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0043] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0044] The aforementioned program module compilation method, apparatus, computer device, storage medium, and computer program product, upon receiving a compilation request for an application module to be compiled, replace the compilation plugin management class corresponding to the module to be compiled with a proxy compilation plugin management class, thereby determining that the compilation plugin used to compile the module to be compiled is an application plugin. It then obtains the class information contained in the module to be compiled, determines the startup logic information and interface information corresponding to the module based on the class information, and finally compiles the module to be compiled into an application based on the application plugin, startup logic information, and interface information. Compared to the traditional method of compiling by adding extra code logic, this solution reduces the workload of module compilation by modifying the management class corresponding to the compilation plugin at the underlying level and compiling the module to be compiled into an application based on the modified compilation plugin and module class information. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating a program module compilation method in one embodiment;
[0046] Figure 2 This is a flowchart illustrating the plug-in replacement steps in one embodiment;
[0047] Figure 3 This is a flowchart illustrating the compilation steps in one embodiment;
[0048] Figure 4 This is a flowchart illustrating the program module compilation method in another embodiment;
[0049] Figure 5 This is a structural block diagram of a program module compilation device in one embodiment;
[0050] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] In one embodiment, such as Figure 1 As shown, a method for compiling a program module is provided. This embodiment illustrates the application of this method to a terminal. It can be understood that this method can also be applied to a server, and to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. The method includes the following steps:
[0053] Step S202: Obtain the compilation request for the module to be compiled.
[0054] In Android projects, modules to be compiled can be project projects that need to be compiled into applications. To facilitate decoupling between business functions and maintenance of individual functions, a project is typically split into an app (application) module and multiple library (resources and manifest) modules. These library modules can have one-way dependencies and are independently compiled into AAR (Android Archive) files. During final release, the terminal can merge the library modules and app modules into a single APK (Android Application Package) file. An APK is an application package file format usable in the Android operating system, while an AAR file is an archive file containing Android resources and manifest files. An AAR file cannot be used independently in the Android system, but it can be used by other development modules during Android development. During Android development, each program module in the project needs to be compiled and run individually. For example, the terminal can obtain compilation requests for modules to be compiled. These compilation requests can be of various types, including requests to compile into AAR files and requests to compile into APK files. The default compilation request for the above-mentioned module to be compiled can be a compilation request for an aar file. The terminal can also receive compilation requests for applications, thereby determining whether the above-mentioned module to be compiled needs to be compiled into a runnable application.
[0055] When the compilation request is an application compilation request, the terminal can determine that the module to be compiled needs to be compiled independently. The terminal can modify the parameters of the classes managing the compilation of the module using an independent compilation plugin. This independent compilation plugin can be a plugin pre-configured within the project containing the module to be compiled.
[0056] For example, in one embodiment, before obtaining the compilation request for the module to be compiled, the method further includes: obtaining the independent compilation plugin corresponding to the application compilation request, and configuring the independent compilation plugin in the root project file of the project where the module to be compiled is located. In this embodiment, the plugin used to compile the module to be compiled into an application can be an application plugin, and the terminal can obtain the independent compilation plugin corresponding to the application compilation request. The independent compilation plugin can be a pre-generated compilation plugin corresponding to the module to be compiled. After the terminal generates the independent compilation plugin, it can also store the independent compilation plugin in the setting.gradle (module configuration file) of the project where the module to be compiled is located. The above-mentioned programming of the program module can be a metaprogramming technique, in which the written computer program can use other programs as data. Therefore, the terminal can dynamically modify the methods or parameters of the instance during program runtime. Thus, when the terminal receives the application compilation request, it can modify the code logic of the underlying plugin implementation of the module to be compiled based on the independent compilation plugin, so that the module to be compiled into an application can be compiled without modifying the original code.
[0057] Step S204: If the compilation request is an application compilation request, replace the compilation plugin management class corresponding to the module to be compiled with the proxy compilation plugin management class; the target location is the root file of the project where the module to be compiled is located; the proxy compilation plugin management class is used to indicate that the compilation plugin type corresponding to the module to be compiled is the application plugin type.
[0058] The aforementioned compilation requests include various types, such as manifest compilation requests and application compilation requests. A manifest compilation request can be a request to compile the module to be compiled into an AAR file, while an application compilation request can be a request to compile the module to be compiled into an APK file. When the terminal receives an application compilation request, the terminal can determine that a separate compilation plugin is needed to modify the underlying compilation plugin management class.
[0059] The compiler plugin management class can be a class used to manage the file types of the modules to be compiled, where each file type represents the type of file the module will ultimately be compiled into. The compiler plugin management class contains corresponding compiler plugins. For the modules to be compiled, the compiler plugin in the unmodified compiler plugin management class can be a resource manifest plugin. However, if the compilation request is an application compilation request, the terminal can obtain an independent compiler plugin from the target location. Based on the independent compiler plugin set in the target location, the compiler plugin management class corresponding to the module to be compiled is replaced with a proxy compiler plugin management class. The proxy compiler plugin management class can be a class obtained by modifying the plugin import logic in the compiler plugin management class. It is a proxy class that inherits from the compiler plugin management class, allowing the terminal to determine the compiler plugin used when compiling the module to be compiled, such as an application plugin type. The target location can be the root file of the project containing the module to be compiled. If the project containing the module to be compiled is an Android development project, then the root file of that project can be the root file of the Android development project.
[0060] Step S206: Based on the instructions of the proxy compilation plugin management class, determine the application plugin that belongs to the application plugin type.
[0061] The aforementioned proxy compiler plugin management class can be a proxy class obtained by modifying the default compiler plugin management class corresponding to the module to be compiled. The compiler plugin management class can include the usage logic of the compiler plugin needed when compiling the module. For example, for the default compiler plugin management class corresponding to the module to be compiled, the terminal can determine that the compiler plugin used to compile the module is a resource manifest plugin, which can compile the module into an AAR file. For the aforementioned proxy compiler plugin management class, the terminal can determine that the compiler plugin used to compile the module is an application plugin, which can compile the module into an APK file, allowing the terminal to run the module independently.
[0062] Step S208: Based on the class information contained in the module to be compiled, and the startup logic information and interface information corresponding to the module to be compiled.
[0063] The class information can be information about classes within the module to be compiled. Class information can be in the form of code. A module to be compiled may include multiple classes, each with corresponding class information. This class information can contain various details, such as the functionality implemented by the class, its corresponding interface, the navigation screen for that interface, and the execution order of the code within the class. The terminal can obtain the class information contained in the module to be compiled and determine the startup logic and interface information corresponding to the module based on this information. The interface information includes interface content and navigation information. Each class in the module to be compiled needs to be registered in the module's AndroidManifest.xml (Android application entry file). The AndroidManifest file describes the information of each class and the various data that can be processed within the module. Only classes registered in the AndroidManifest file can be read and executed correctly. Therefore, the AndroidManifest file contains information about all classes in the module to be compiled. The terminal can obtain the classes contained in the module from the AndroidManifest file and retrieve the detailed content of each class based on the class information. The class information of the module to be compiled may include the logic code for program startup, the code for the interface, and the interface jump code when it is necessary to jump to other interfaces. Therefore, the terminal can determine the startup logic information of the module to be compiled based on the logic code for program startup in the class information, determine the interface information implemented by the module to be compiled based on the code for the interface in the class information, and determine the interface jump information of the module to be compiled based on the interface jump code in the class information.
[0064] In step S210, the application plugin compiles the module to be compiled into an application based on the startup logic information, interface content information, and interface jump information.
[0065] The application plugin can be used to compile the module to be compiled into an APK file. During compilation, the terminal needs to determine the startup logic and interface information of the module to be compiled. The startup logic can be the order in which the code of the application corresponding to the module to be compiled executes when it starts, such as which class is called first, which interface is launched first, etc. The interface information can include interface content information and interface navigation information. The interface content information can be the interface information contained in the application corresponding to the module to be compiled. If navigation is possible between the various interfaces in the module to be compiled, then the interface navigation information can be the information on how the navigation occurs between the various interfaces. The terminal can use the application plugin to compile the module to be compiled into an application based on the above-mentioned startup logic information, interface content information, and interface navigation information. Thus, the terminal can implement the functions of the module to be compiled by running the application of the module to be compiled independently.
[0066] In the above-described program module compilation method, upon receiving a compilation request for the application module to be compiled, the compilation plugin management class corresponding to the module to be compiled is replaced with a proxy compilation plugin management class. This determines that the compilation plugin used to compile the module to be compiled is an application plugin. The class information contained in the module to be compiled is obtained, and the startup logic and interface information corresponding to the module to be compiled are determined based on the class information. Then, based on the application plugin, startup logic, and interface information, the module to be compiled is compiled into an application. Compared to the traditional method of compiling by adding extra code logic, this solution reduces the workload of module compilation by modifying the management class corresponding to the compilation plugin at the underlying level and compiling the module to be compiled into an application based on the modified compilation plugin and module class information.
[0067] In one embodiment, when the compilation request is an application compilation request, the compilation plugin management class corresponding to the module to be compiled is replaced with a proxy compilation plugin management class, including: generating an original proxy compilation plugin management class that inherits from the compilation plugin management class; and changing the compilation plugin type in the original proxy compilation plugin management class from the resource manifest plugin type to the application plugin type by setting an independent compilation plugin in the target location, thereby obtaining the proxy compilation plugin management class.
[0068] In this embodiment, after receiving an application compilation request, the terminal determines that the module to be compiled needs to be compiled into an APK file. The terminal can then pre-generate an original proxy compilation plugin management class that inherits from the compilation plugin management class. This original proxy compilation plugin management class represents a subclass that has not undergone plugin modification and is simply inherited from the aforementioned compilation plugin management class. The terminal can modify the compilation plugin type in the original proxy compilation plugin management class according to the application request, by setting an independent compilation plugin at the target location. The terminal can modify the compilation plugin management class by overriding it. After overriding the compilation plugin type in the compilation plugin management class, the terminal obtains a proxy compilation plugin management class that inherits from the compilation plugin management class.
[0069] Specifically, the compilation plugin in the aforementioned compilation plugin management class is a resource manifest plugin. This plugin can compile the module to be compiled into an AAR file. However, since the compilation request is an application compilation request, the terminal can modify the parameters of the compilation plugin management class. For example... Figure 2 As shown, Figure 2This is a flowchart illustrating the plugin replacement step in one embodiment. In the Android project compilation source code mentioned above, the project compilation plugin management class is the `DefaultPluginManager` class. This class is stored in the `Project` class that manages project compilation. Since the terminal uses the Groovy language for programming, and Groovy supports metaprogramming, the terminal can modify the parameters in the aforementioned compilation plugin management class. The terminal can define a proxy class that inherits from the aforementioned compilation plugin management class and override methods in the proxy class. This allows the imported compilation plugin type to be replaced from the resource manifest plugin type to the application plugin type when the program module needs to be compiled independently into an application, thus obtaining the proxy compilation plugin management class. Therefore, during the independent compilation process of the program module, the compilation plugin management class in the `Project` instance of the project containing the module to be compiled is replaced with the aforementioned proxy compilation plugin management class.
[0070] In this embodiment, the terminal can rewrite a proxy compiler plugin management class so that when a module to be compiled needs to be compiled independently, the default compiler plugin management class can be replaced with the proxy compiler plugin management class. This allows the terminal to compile the module to be compiled independently based on the proxy compiler plugin management class, thereby reducing the workload of independent module compilation.
[0071] In one embodiment, before determining the startup logic information, interface content information, and interface jump information corresponding to the module to be compiled based on the class information contained in the module to be compiled, the method further includes: traversing the global configuration file in the module to be compiled, and obtaining the class name, class initialization code, class interface code, and class interface jump code in the global configuration file as the class information contained in the module to be compiled.
[0072] In this embodiment, when the terminal compiles the module to be compiled independently, it needs to obtain the class information in the module to be compiled. Each time a class appears in the module to be compiled, the class information needs to be registered in the global configuration file of the module. Therefore, the class information can be stored in the global configuration file of the module to be compiled. The terminal can pre-configure the global configuration file. For example, if the module to be compiled has corresponding application information, the terminal can generate a global configuration file from the application information and class information corresponding to the module to be compiled, and the terminal can also store the global configuration file in the module to be compiled. Specifically, the application information can include the application identifier, application version number, and application name, etc., and the global configuration file can be the AndroidManifest file of the module to be compiled. The class information stored in the AndroidManifest file can include the class name, class initialization code, class UI code, and class UI transition code, etc. The terminal can traverse the global configuration file in the module to be compiled and obtain the class name, class initialization code, class UI code, and class UI transition code contained in the global configuration file as the class information in the module to be compiled. The initialization code of a class indicates the execution order when the class is initialized. Since the interface information of a class can include the interface content information and interface navigation information, the interface-related code of a class can include interface code and interface navigation code. The interface code of a class represents the content code in the interface contained in the class, and the interface navigation code of a class represents the code on how to navigate between interfaces of the class.
[0073] During the development of the module to be compiled, new classes may emerge, requiring updates to the class information in the global configuration file. For example, in one embodiment, after generating the global configuration file corresponding to the module to be compiled based on the application identifier, application version number, application name, and class information, the process further includes: when a new class is detected in the module to be compiled, obtaining the class information of the new class and registering it in the global configuration file to obtain an updated global configuration file. In this embodiment, new classes may appear during code editing of the module to be compiled. Each class needs to be registered in the global configuration file. Therefore, the terminal can obtain the class information of the new class when it detects a new class being generated in the module to be compiled, register it in the global configuration file, and obtain an updated global configuration file. The class information may include the class name, class initialization code, class UI code, and class UI navigation code, among other information.
[0074] Through the above embodiments, the terminal can pre-configure a global configuration file and obtain the class information corresponding to the module to be compiled from the global configuration file. Thus, the terminal can independently compile the module to be compiled based on the class information, reducing the workload of independent compilation.
[0075] In one embodiment, the process of generating a global configuration file includes: when a module to be compiled is created, obtaining the application identifier, application version number, and application name corresponding to the module to be compiled, and obtaining the class information in the module to be compiled; and generating a global configuration file corresponding to the module to be compiled based on the application identifier, application version number, application name, and class information.
[0076] In this embodiment, the terminal can pre-configure a global configuration file. For example, the terminal can configure the global configuration file when the module to be compiled is created. After the terminal detects that the module to be compiled has been created, it can obtain the application identifier, application version number, and application name corresponding to the module to be compiled. The terminal can also obtain the class information in the module to be compiled. Thus, the terminal can generate a global configuration file corresponding to the module to be compiled based on the application identifier, application version number, application name, and the aforementioned class information. Specifically, the global configuration file can be the AndroidManifest file of the module to be compiled. The application identifier can also be called APPID. The specific parameters of the application identifier, application version number, and application name can all be pre-set, such as using default parameters or configured by the developer. Furthermore, the class information of all interfaces in the module to be compiled needs to be registered in the global configuration file; otherwise, navigation will not be possible. Therefore, the terminal can register the class information in the module to be compiled to the global configuration file, so that the interface startup and navigation functions can be implemented normally during subsequent independent compilation.
[0077] Through this embodiment, the terminal can pre-configure a global configuration file based on the relevant information of the application corresponding to the module to be compiled and the class information in the module to be compiled, so that the terminal can independently compile the module to be compiled based on the global configuration file, reducing the workload of independent compilation.
[0078] In one embodiment, determining the class information contained in the module to be compiled based on class information, and determining the startup logic information, interface content information, and interface jump information corresponding to the module to be compiled, includes: determining the classes called when the module to be compiled starts and the order of calling each class based on the initialization code of the classes in the global configuration file, to obtain the startup logic information corresponding to the module to be compiled; determining the interface content of the classes in the module to be compiled based on the interface code of the classes in the global configuration file, and determining the interface content information corresponding to the module to be compiled based on the interface content content and the class names in the global configuration file; determining the interface content information corresponding to other class names as the interface jump information corresponding to the module to be compiled based on the interface jump code of the classes in the global configuration file and the class names in the global configuration file; the other class names are the class names of classes contained in other modules outside the module to be compiled in the project where the module to be compiled is located.
[0079] In this embodiment, the class information of the module to be compiled contains code of different types, each with different functions. This class information includes initialization code, UI code, and UI navigation code from the global configuration file. The terminal can determine the classes called during module startup and their order of call based on the initialization code, thus obtaining the startup logic information for the module. These classes can include those within the module itself, as well as other classes from other modules within the same project. For example, if certain functions in the module depend on these other classes, such as starting the UI before calling the database, and the database implementation code resides in another class, the terminal needs to determine the relevant information of the classes to be called when determining the startup logic information. In other words, the startup logic can be the startup order of the called classes.
[0080] The terminal can also determine the interface content of classes in the module to be compiled based on the interface code of classes in the global configuration file, and then use the interface content and class names in the global configuration file to determine the interface content information corresponding to the module to be compiled. The interface content can be the visual content contained within the interface. The module to be compiled can contain interface code corresponding to multiple interfaces, and the terminal can determine the corresponding interface content based on the interface code of each class. Furthermore, each interface has a corresponding name, which can be determined based on the class name.
[0081] When the module to be compiled contains multiple interfaces, the terminal can determine the interface content information of other class names based on the interface jump code and class names in the global configuration file. This information serves as the interface jump information for the module to be compiled, allowing the terminal to identify the interface information corresponding to the module. Here, "other class names" refers to the class names of classes contained in other modules within the same project as the module to be compiled. Specifically, if a class in the module to be compiled has a corresponding jump interface, that class will include information about other classes, such as their jump interface information and names. The terminal can detect whether each class in the module to be compiled contains the names of other classes; if so, it obtains the interface jump information based on the interface information corresponding to these other class names. This enables interface navigation.
[0082] Since the interface information corresponding to the aforementioned module to be compiled may include multiple components, the terminal needs to determine the startup order of the interfaces. For example, in one embodiment, based on the interface jump code of the class in the global configuration file and the class name in the global configuration file, the interface content information corresponding to other class names is determined as the interface jump information corresponding to the module to be compiled. This includes: determining the main interface class name of the module to be compiled from the class names in the global configuration file, and using the interface content information corresponding to the main interface class name as the startup interface information corresponding to the module to be compiled; obtaining other class names corresponding to the class names in the global configuration file, and determining the interface content information corresponding to the other class names as other jump interface information corresponding to the interface content information of the class names; and determining the startup interface information and other jump interface information as the interface jump information corresponding to the module to be compiled.
[0083] In this embodiment, when the module to be compiled includes multiple interfaces, it indicates that the module contains multiple classes. The terminal can then detect the class names of each class in the module, for example, by checking the class names in the global configuration file, and determine the main interface class name based on the class names. The terminal can then use the interface content information corresponding to the main interface class name as the startup interface corresponding to the module to be compiled. Furthermore, the terminal can also obtain other class names corresponding to the class names in the global configuration file and determine the interface content information corresponding to these other class names as the other jump interface information corresponding to the interface content information of the aforementioned class names. For example, if the startup interface has corresponding jump page information, and other interfaces besides the startup interface also have corresponding jump page information, the terminal can determine the jump page corresponding to each interface and determine the startup interface information and other jump interface information as the interface jump information corresponding to the module to be compiled. Therefore, when the terminal runs the application corresponding to the module to be compiled, it can know which startup page needs to be launched first, how to jump from the startup page to other interfaces, and the logic for jumping to the next interface from other pages.
[0084] Through this embodiment, the terminal can obtain interface jump information by determining the jump logic between the startup interface and other interfaces. As a result, the terminal can perform independent compilation based on the interface jump information without adding extra code, thus reducing the workload of independent compilation.
[0085] In one embodiment, the application plugin compiles the module to be compiled into an application based on startup logic information, interface content information, and interface transition information. This includes: obtaining the source code set corresponding to the module to be compiled; the source code set contains call paths; the call paths represent the paths to obtain the files required to compile the module to be compiled into the application; the application plugin obtains the class files corresponding to the startup logic information, the interface content information, and the interface transition information from the call paths, and generates the application's startup logic based on the class files corresponding to the startup logic information, generates the content of each interface of the application based on the class files corresponding to the interface content information, and generates transition information between the various interfaces of the application based on the class files corresponding to the interface transition information, thus obtaining the content-compiled application; and using the application identifier, application version number, and application name as the program information of the content-compiled application, thus obtaining the application corresponding to the module to be compiled.
[0086] In this embodiment, after obtaining the aforementioned application plugin, startup logic information, and interface information, the terminal can compile the module to be compiled into an application. During independent compilation, the terminal can inject the aforementioned relevant information into the source code set, allowing it to determine how to call the various files and information. For example, the terminal can obtain the source code set corresponding to the module to be compiled, which contains a call path representing the path to obtain the files required to compile the module into an application. Therefore, the terminal can use the application plugin to obtain the class files corresponding to the startup logic information, interface content information, and interface jump information of the module to be compiled based on the aforementioned call path. The terminal can also use the application plugin to obtain the application identifier, application version number, and application name based on the aforementioned call path. Thus, the terminal can compile the module to be compiled based on the aforementioned application plugin, the class files corresponding to the startup logic information, the class files corresponding to the interface content information, the class files corresponding to the interface jump information, the application identifier, the application version number, and the application name, thereby obtaining the application corresponding to the module to be compiled.
[0087] The application plugin provides the compilation logic for compiling the module to be compiled into an application. The startup logic information, interface content information, and interface transition information provide the functional logic of the application when the module to be compiled is compiled independently. For example, the terminal can use the application plugin to generate the application's startup logic based on the class file corresponding to the startup logic information, generate the content of each interface of the application based on the class file corresponding to the interface content information, and generate the transition information between the various interfaces of the application based on the class file corresponding to the interface transition information, thus obtaining the functionally compiled application. The application identifier, application version number, and application name provide the identification information of the application when the module to be compiled is compiled independently. For example, the terminal uses the application identifier, application version number, and application name as the identification information of the functionally compiled application to obtain the application corresponding to the module to be compiled. Specifically, when the terminal needs to compile the module to be compiled independently into an application, it needs to use the aforementioned global configuration file and the class information of the main startup interface, where the class information of the main startup interface is used to manage the transitions between other pages. The global configuration file contains information such as the application identifier, application version number, and application name. Information about the main launch screen can be determined from the class information in the global configuration file. During independent compilation, the terminal can parse the global configuration file to obtain the class information it contains. Based on this class information, the terminal can obtain the corresponding Activity class for the launch screen and manage the navigation logic between screens. If the aforementioned class information contains an existing screen, the terminal can directly obtain the screen content and navigation information for that class from the screen content information of the class. If the aforementioned class information does not contain an existing screen, the terminal can automatically generate the corresponding Activity class based on its functionality and the functionality of other screens that need to be used, allowing users to use the functionality of that class visually.
[0088] The aforementioned source code set can be generated before compilation after the terminal receives the application compilation request. For example, in one embodiment, obtaining the source code set corresponding to the module to be compiled includes: storing the call paths of the class files corresponding to the startup logic information, the call paths of the class files corresponding to the interface content information, and the call paths of the class files corresponding to the interface jump information into the source code set corresponding to the module to be compiled.
[0089] In this embodiment, the terminal can inject necessary files into the source code set of the module to be compiled before independently compiling the module. For example, the terminal can obtain the application identifier, application version number, and application name corresponding to the module to be compiled, and store the call paths of the class files corresponding to the startup logic information, the interface content information, and the interface jump information into the source code set corresponding to the module to be compiled. Additionally, in some embodiments, the aforementioned source code set may also include the call paths of application plugins, application identifiers, application version numbers, and application names, etc. Specifically, such as... Figure 3 As shown, Figure 3 As shown, Figure 3 This is a flowchart illustrating the compilation steps in one embodiment. The application identifier mentioned above can be the application's ID, the global configuration file mentioned above can be the AndroidManifest file in the module to be compiled, and the source code set mentioned above is also called SourceSet. The terminal can obtain information such as the application's ID, version number, and name, generate an AndroidManifest file, and obtain the startup interface class corresponding to the class information by parsing the AndroidManifest file in the module to be compiled. The terminal can obtain information such as the application's ID, version number, and name, as well as the interface information of the class, and inject the call paths of this information into the SourceSet folder. Thus, the terminal can use the files in the SourceSet folder to call relevant information and perform independent compilation.
[0090] Through the above embodiments, the terminal can inject the obtained independent compilation-related information into the source code set, and determine the calling path of each piece of information when independently compiling the module to be compiled through the source code set, thereby reducing the workload of independently compiling the module to be compiled.
[0091] In one embodiment, such as Figure 4 As shown, Figure 4This is a flowchart illustrating the program module compilation method in another embodiment. It includes the following steps: In this embodiment, the compilation of the module to be compiled can be modular. When it is necessary to compile the module to be compiled into an application, the terminal can import the aforementioned independent compilation plugin into the Setting.gradle file of its project. The independent compilation plugin modifies the underlying plugin implementation code logic without changing the module project script. It modifies the default compilation plugin management class, replacing the resource manifest plugin passed to the management class with the application plugin, thereby obtaining the aforementioned proxy compilation plugin management class. Furthermore, the terminal can analyze all class information in the module to be compiled, generating corresponding interface content information and interface jump information. By obtaining all registered jump interfaces in the module project, the terminal automatically generates interface jump logic and files required for independent compilation, such as the AndroidManifest.xml file, and automatically adds them to the module for compilation during independent compilation. The AndroidManifest file contains application-related information and the aforementioned class information. The terminal can inject the files used for independent compilation into the SourceSet, allowing the terminal to call these files from the corresponding call path based on the SourceSet folder and compile them to obtain the application APK file corresponding to the module to be compiled.
[0092] Through the above embodiments, the terminal reduces the workload of module compilation by modifying the management class corresponding to the compilation plugin at the underlying level and compiling the module to be compiled into an application based on the class information of the compilation plugin and module after the management class is modified.
[0093] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0094] Based on the same inventive concept, this application also provides a program module compilation apparatus for implementing the program module compilation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more program module compilation apparatus embodiments provided below can be found in the limitations of the program module compilation method described above, and will not be repeated here.
[0095] In one embodiment, such as Figure 5 As shown, a program module compilation device is provided, including: a first acquisition module 500, a modification module 502, a determination module 504, a second acquisition module 506, and a compilation module 508, wherein:
[0096] The first acquisition module 500 is used to acquire the compilation request for the module to be compiled.
[0097] Modify module 502 to replace the compiler plugin management class corresponding to the module to be compiled with a proxy compiler plugin management class if the compilation request is an application compilation request; the target location is the root file of the project where the module to be compiled is located; the proxy compiler plugin management class is used to indicate that the compiler plugin type corresponding to the module to be compiled is an application plugin type.
[0098] Module 504 is used to determine application plugins that belong to the application plugin type based on the instructions of the proxy compilation plugin management class.
[0099] The second acquisition module 506 is used to determine the startup logic information, interface content information and interface jump information corresponding to the module to be compiled based on the class information contained in the module to be compiled.
[0100] Compilation module 508 is used by the application plugin to compile the module to be compiled into an application based on startup logic information, interface content information, and interface jump information.
[0101] In one embodiment, the above apparatus further includes: a configuration module, configured to obtain the independent compilation plugin corresponding to the application compilation request, and configure the independent compilation plugin in the root project file of the project where the module to be compiled is located.
[0102] In one embodiment, the modification module 502 is specifically used to generate an original proxy compilation plugin management class that inherits from the compilation plugin management class; by setting an independent compilation plugin in the target location, the compilation plugin type in the original proxy compilation plugin management class is changed from the resource manifest plugin type to the application plugin type, thus obtaining the proxy compilation plugin management class.
[0103] In one embodiment, the second acquisition module 506 is specifically used to traverse the global configuration file of the module to be compiled, and obtain the class name, class initialization code, class interface code and class interface jump code in the global configuration file as class information contained in the module to be compiled.
[0104] In one embodiment, the second acquisition module 506 is specifically used to acquire the application identifier, application version number, and application name corresponding to the module to be compiled when the module to be compiled is created, and to acquire the class information in the module to be compiled; and to generate a global configuration file corresponding to the module to be compiled based on the application identifier, application version number, application name, and class information.
[0105] In one embodiment, the above apparatus further includes: an update module, configured to obtain class information of the new class when a new class is detected to be generated in the module to be compiled, and register it in the global configuration file to obtain the updated global configuration file.
[0106] In one embodiment, the second acquisition module 506 is specifically used to determine, based on the initialization code of the classes in the global configuration file, the classes called when the module to be compiled starts and the order in which each class is called, and to obtain the startup logic information corresponding to the module to be compiled; to determine the interface content of the classes in the module to be compiled based on the interface code of the classes in the global configuration file, and to determine the interface content information corresponding to the module to be compiled based on the interface content content and the class names in the global configuration file; to determine the interface content information corresponding to other class names as the interface jump information corresponding to the module to be compiled based on the interface jump code of the classes in the global configuration file and the class names in the global configuration file; the other class names are the class names of classes contained in other modules outside the module to be compiled in the project where the module to be compiled is located.
[0107] In one embodiment, the second acquisition module 506 is specifically used to determine the main interface class name of the module to be compiled from the class names in the global configuration file, and use the interface content information corresponding to the main interface class name as the startup interface information corresponding to the module to be compiled; acquire other class names corresponding to the class names in the global configuration file, and determine the interface content information corresponding to the other class names as other jump interface information corresponding to the interface content information of the class names; and determine the startup interface information and other jump interface information as the interface jump information corresponding to the module to be compiled.
[0108] In one embodiment, the compilation module 508 is specifically used to obtain the source code set corresponding to the module to be compiled; the source code set includes a call path; the call path represents the acquisition path of the files required to compile the module to be compiled into the application; the application plugin obtains the class files corresponding to the startup logic information, the class files corresponding to the interface content information, and the class files corresponding to the interface jump information from the call path, and generates the startup logic of the application based on the class files corresponding to the startup logic information, generates the content of each interface of the application based on the class files corresponding to the interface content information, and generates the jump information between the various interfaces of the application based on the class files corresponding to the interface jump information, thereby obtaining the functionally compiled application; the application identifier, application version number, and application name are used as the identifier information of the functionally compiled application to obtain the application corresponding to the module to be compiled.
[0109] In one embodiment, the compilation module 508 is specifically used to store the call paths of the class files corresponding to the startup logic information, the class files corresponding to the interface content information, and the class files corresponding to the interface jump information into the source code set corresponding to the module to be compiled.
[0110] Each module in the aforementioned program module compilation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0111] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a program module compilation method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0112] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0113] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the program module compilation method described above.
[0114] In one embodiment, a computer-readable storage medium is provided on which a computer program is stored, which, when executed by a processor, implements the above-described program module compilation method.
[0115] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the above-described program module compilation method.
[0116] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0117] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0118] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for compiling a program module, characterized in that, The method includes: Obtain the compilation request for the module to be compiled; the module to be compiled is a resource and manifest module in the project that is compiled into an archive file by default; the project includes an application module and multiple resource and manifest modules; If the compilation request is an application compilation request, the compilation plugin management class corresponding to the module to be compiled is replaced with a proxy compilation plugin management class, including: modifying the compilation plugin type in the original proxy compilation plugin management class from the resource manifest plugin type to the application plugin type by setting an independent compilation plugin in the target location, thus obtaining a proxy compilation plugin management class; the original proxy compilation plugin management class inherits from the compilation plugin management class; the target location is the root file of the project where the module to be compiled is located; the compilation plugin in the compilation plugin management class is a resource manifest plugin, and the compilation plugin management class is used to compile the module to be compiled into an archive file through the resource manifest plugin; the proxy compilation plugin management class is used to indicate that the compilation plugin type corresponding to the module to be compiled is an application plugin type; Based on the instructions of the proxy compilation plugin management class, determine the application plugins that belong to the application plugin type; Based on the class information contained in the module to be compiled, determine the startup logic information, interface content information, and interface jump information corresponding to the module to be compiled; The application plugin compiles the module to be compiled into an application based on the startup logic information, the interface content information, and the interface jump information.
2. The method according to claim 1, characterized in that, Before obtaining the compilation request for the module to be compiled, the process also includes: Obtain the standalone compilation plugin corresponding to the application compilation request, and configure the standalone compilation plugin in the root project file of the project where the module to be compiled is located.
3. The method according to claim 1, characterized in that, Before determining the startup logic information, interface content information, and interface transition information corresponding to the module to be compiled based on the class information contained in the module to be compiled, the method further includes: The global configuration file of the module to be compiled is traversed to obtain the class name, class initialization code, class interface code and class interface jump code in the global configuration file, which are used as the class information contained in the module to be compiled.
4. The method according to claim 3, characterized in that, The process of generating the global configuration file includes: When the module to be compiled is created, the application identifier, application version number and application name corresponding to the module to be compiled are obtained, and the class information in the module to be compiled is obtained. Based on the application identifier, application version number, application name, and class information, a global configuration file corresponding to the module to be compiled is generated.
5. The method according to claim 3, characterized in that, The step of determining the startup logic information, interface content information, and interface transition information corresponding to the module to be compiled based on the class information contained in the module to be compiled includes: Based on the initialization code of the classes in the global configuration file, determine the classes called when the module to be compiled starts and the order in which each class is called, and obtain the startup logic information corresponding to the module to be compiled. The interface content of the class in the module to be compiled is determined based on the interface code of the class in the global configuration file, and the interface content and the class name in the global configuration file are determined as the interface content information corresponding to the module to be compiled. Based on the interface jump code of the class in the global configuration file and the class name in the global configuration file, the interface content information corresponding to other class names is determined to be the interface jump information corresponding to the module to be compiled; the other class names are the class names of classes contained in other modules outside the module to be compiled in the project where the module to be compiled is located.
6. The method according to claim 5, characterized in that, The step of determining the interface content information corresponding to other class names as the interface jump information corresponding to the module to be compiled, based on the interface jump code of the class in the global configuration file and the class name in the global configuration file, includes: In the class name of the global configuration file, determine the main interface class name of the module to be compiled, and use the interface content information corresponding to the main interface class name as the startup interface information of the module to be compiled. Obtain other class names corresponding to the class names in the global configuration file, and determine the interface content information corresponding to the other class names as other jump interface information corresponding to the interface content information of the class name; The startup interface information and the other jump interface information are determined as the interface jump information corresponding to the module to be compiled.
7. The method according to claim 4, characterized in that, The process of compiling the module to be compiled into an application by the application plugin based on the startup logic information, the interface content information, and the interface jump information includes: Obtain the source code set corresponding to the module to be compiled; the source code set includes the call path; the call path represents the acquisition path for compiling the module to be compiled into the files required by the application. The application plugin obtains the class file corresponding to the startup logic information, the class file corresponding to the interface content information, and the class file corresponding to the interface jump information from the call path. Based on the class file corresponding to the startup logic information, it generates the startup logic of the application, generates the content of each interface of the application based on the class file corresponding to the interface content information, and generates the jump information between each interface of the application based on the class file corresponding to the interface jump information, thus obtaining the functionally compiled application. The application identifier, application version number, and application name are used as the identification information of the compiled application to obtain the application corresponding to the module to be compiled.
8. The method according to claim 7, characterized in that, The step of obtaining the source code set corresponding to the module to be compiled includes: The call paths of the class files corresponding to the startup logic information, the class files corresponding to the interface content information, and the class files corresponding to the interface jump information are stored in the source code set corresponding to the module to be compiled.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Application construction method and system, computer equipment and storage medium
CN108287694A
Installation package generation method and device
CN114527988A
Application program compiling method and device
CN114968261A