Code generation method, and compiler, apparatus, device and computer-readable medium

通过在代码托管平台上封装接口和配置文件创建代码模板,并利用引擎服务动态解析配置文件生成可执行代码,解决了开发人员生成项目代码效率低下的问题,实现了代码的个性化定制和快速集成 , improves development efficiency.

WO2024250752A1PCT designated stage expired Publication Date: 2024-12-12EBAOTECH CORP

Patent Information

Application Number
PCT/CN2024/079359
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-06-05
Filing Date
2024-02-29
Publication Date
2024-12-12

AI Technical Summary

Technical Problem

Developers are inefficient when generating project code. The existing technology cannot provide fast generation of functional code templates. The templates of private platforms need to be purchased for a fee and cannot be customized in a personalized manner, resulting in a cumbersome and complicated development process.

Method used

Create code templates through encapsulation interfaces and configuration files, store them on the code hosting platform, and dynamically parse configuration files to generate executable code for target users, realizing personalized customization and rapid integration of the code.

Benefits of technology

Improve development efficiency, save development time, break the limitations of private platform management, allow developers to share the source code of the same functions or services, and simplify the code integration and customization process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079359_12122024_PF_FP_ABST
    Figure CN2024079359_12122024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computers, and particularly relates to a code generation method, and a compiler, an apparatus, a device and a computer-readable medium. The method comprises: a first electronic device packaging, in a first source code, at least one interface related to service integration, presetting a first configuration file, creating a first code template, and storing the first code template in a code hosting platform; in response to a received development requirement, a second electronic device acquiring, from the code hosting platform, the first code template related to the development requirement, and parsing a first configuration file which is packaged in the first code template, so as to obtain first configuration data related to a target user / used for modifying pre-configured modifiable content in the first code template; and the second electronic device modifying corresponding content in the first code template by using the first configuration data, so as to generate a target code meeting the development requirement, and storing the target code in the code hosting platform. In this way, an individual requirement can be met to generate a code, thereby facilitating the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Code generation method, compiler, device, equipment and computer-readable medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on June 5, 2023, with application number 202310655600.0 and application name “Code generation method, compiler, device, equipment and computer-readable medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present invention relates to the field of software technology, and in particular to a code generation method, compiler, device, equipment and computer-readable medium. Background Art

[0003] To speed up development and maximize code reusability, secondary development based on (code) templates is a growing trend. The primary function of code is integration with existing business services. Code templates provide reproducible executable code, or source code. This executable code eliminates the tedious process of integrating with business services, allowing developers to quickly integrate the generated code with existing business services based on the template.

[0004] How to quickly and correctly generate code based on existing templates and host the generated code on an external platform (such as GitHub). GitHub is a cloud service website for code hosting that helps developers store and manage their project source code and can track, record, and control user modifications to their code. However, the source code of some open source projects currently stored on GitHub is available for developers to access and learn, but it does not provide templates for quickly generating corresponding functional code. As a result, when developers need to develop project code for corresponding functions, they still need to develop it themselves, which is inefficient. Although other private platforms can provide code templates, such code templates often require payment, and the process of generating code based on such code templates usually involves downloading the source code provided by the template to the local computer for modification, rather than directly generating source code based on the template that can be directly applied to the developer's development environment. As a result, the process of developing code based on such templates is also cumbersome and complex, and inefficient.

[0005] In summary, currently developers still face the problem of difficulty in improving development efficiency when generating project codes.

[0006] Summary of the Invention

[0007] The present application provides a code generation method, compiler, apparatus, device and computer-readable medium, which can improve development efficiency, provide developers with executable code generated based on specific code templates and targeting different tenant data, and realize personalized customization of the code generation process.

[0008] In a first aspect, the present application provides a code generation method, which includes: a first electronic device encapsulates at least one interface in a first source code and presets a first configuration file to create a first code template, wherein at least one interface is an interface related to business integration, the first source code is an executable code that can implement a first type of function or service, and the first configuration file includes configuration data related to the target user configured for the first source code; the first electronic device stores the first code template on a code hosting platform; a second electronic device obtains a first code template related to the development requirements from the code hosting platform in response to received development requirements, wherein the development requirements include the requirement to integrate the first type of function or service in the target project to be developed; the second electronic device parses the first configuration file encapsulated in the first code template to obtain first configuration data related to the target user, wherein the first configuration data is used to modify the pre-configured modifiable content in the first code template; the second electronic device uses the first configuration data to modify the corresponding content in the first code template to generate a target code that meets the development requirements, and stores the target code on the code hosting platform, wherein the target code is used to implement the first type of function or service to process data related to the target user.

[0009] For example, the first electronic device may be a development terminal used by a developer to develop project code, and the first source code may be source code for executing a corresponding function or service in a previous project developed by the developer. After the first electronic device creates a first code template based on the developed project source code, it may designate the code template to be hosted on a code hosting platform, allowing the second electronic device to retrieve and generate the required executable code.

[0010] Furthermore, when a developer needs to integrate the functions or services provided by the first source code into a project to be developed, they can request a second electronic device, such as a compilation server or other server or server cluster with corresponding configuration functions, to obtain the first code template from the code hosting platform and dynamically interpret and modify the corresponding configuration content in the code template based on the preset configuration file (such as the first configuration file) in the code template, i.e., the pre-configured modifiable content. In this way, the executable code generated based on the first code template can directly obtain the corresponding configured tenant data or other data required for operation related to the target user based on the above configuration, and realize the processing function for the corresponding data.

[0011] As can be seen, based on the code generation method provided in the first aspect above, developers do not need to spend time manually configuring the source code encapsulated in the code template, but can directly obtain executable code for the target user's relevant data. This can greatly improve development efficiency and save developers time in developing subsequent project code.

[0012] In a possible implementation of the first aspect above, the first electronic device stores the first code template in a code hosting platform, including: the first electronic device sends the created first code template to the code hosting platform, and instructs the code hosting platform to store the first code template in a correspondingly created template library, wherein the template library is a storage space created based on the first code library corresponding to the first source code and used to store the corresponding code template.

[0013] That is, after the first electronic device creates a first code template based on the developed project source code, it can specify that the code template be hosted in a corresponding template library created by the code hosting platform. This allows the code hosting platform to categorize, store, and manage code templates created based on source code corresponding to different functions or services, and also facilitates the subsequent acquisition of the code template and its use to generate the corresponding executable code.

[0014] In a possible implementation of the first aspect above, the first electronic device encapsulates at least one interface in the developed first source code and presets a first configuration file to create a first code template, including: the first electronic device encapsulates the calling logic and context data between one or more interfaces related to business integration into the first source code to generate a second code template; the first electronic device presets the first configuration file in the second code template and presets the calling path corresponding to the first configuration file in the second code template to create the first code template.

[0015] Specifically, a code template can be created by encapsulating business integration-related interfaces and the calling logic between these interfaces within a first source code, along with pre-configured configuration files for configuring tenant data or other user-related content. The calling logic between these interfaces can be related to the business integration, such as the business scenario used when the first source code was developed. This code template, when dynamically interpreted, can automatically generate user-specific executable code.

[0016] In a possible implementation of the first aspect above, the second electronic device includes a preset engine service for parsing the first configuration file, and the second electronic device parses the first configuration file encapsulated in the first code template to obtain first configuration data related to the target user, including: the second electronic device runs the engine service to parse the first configuration file to obtain the first configuration data.

[0017] In a possible implementation of the first aspect, the development requirement corresponds to a requirement of the third electronic device to generate target code for compiling project code of the target project, and the method includes:

[0018] After determining that the target code has been stored in the second code library of the code hosting platform, the second electronic device or the code hosting platform sends a notification message to the third electronic device, wherein the notification message is used to notify the third electronic device that the target code has been stored in the second code library, wherein the second code library is a storage space for storing the target code created based on the template library; the third electronic device requests the code hosting platform to obtain the target code based on the received notification message.

[0019] For example, the third electronic device is a development terminal used by developers to develop project codes. This electronic device can be the same as or different from the first electronic device. When the third electronic device needs to use the generated target code, it can request the second electronic device to generate the corresponding target code, and then obtain the target code stored in the code hosting platform based on the notification of the second electronic device or the code hosting platform. In this way, the management limitations of the private platform on the code template can be broken, which is conducive to developers of various business platforms sharing the source code of the same function or service, thereby improving development efficiency.

[0020] In a possible implementation of the first aspect, the notification message is a broadcast message sent by the code hosting platform, or the notification message is a communication message sent by the second electronic device based on a communication connection between the second electronic device and the third electronic device.

[0021] In a possible implementation of the first aspect above, the target code is stored in the second code library in the form of an executable code file, and the target code is stored in the code hosting platform, including: the second electronic device packages the executable code file corresponding to the target code and sends it to the code hosting platform, and instructs the code hosting platform to store the executable code file in the second code library.

[0022] In a possible implementation of the first aspect above, the format of the first configuration file includes any one of a JSON format, a Java format, and a properties format.

[0023] In a possible implementation of the first aspect above, the first configuration data includes at least one of tenant information, a tenant data acquisition path, and an acquisition path for running data required for target code execution.

[0024] In a second aspect, the present application provides a compiler, which is provided in a second electronic device, and the second electronic device executes the code generation method provided by the first aspect and various possible implementations of the first aspect through the compiler.

[0025] In a third aspect, the present application provides a compilation device, including the compiler provided in the second aspect, and the compilation device serves as a second electronic device, configured to execute the code generation method provided in the first aspect and various possible implementations of the first aspect.

[0026] In a fourth aspect, the present application provides an electronic device comprising: one or more processors; one or more memories; one or more memories storing one or more programs, wherein when one or more programs are executed by one or more processors, the device executes the code generation method provided by the first aspect and various possible implementations of the first aspect.

[0027] In a fifth aspect, the present application provides a computer-readable medium having instructions stored thereon. When the instructions are executed on a computer, the computer executes the code generation method provided by the first aspect and various possible implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] FIG1 is a schematic diagram showing an application scenario of a code generation method.

[0029] FIG2 is a schematic diagram showing an implementation scenario of a code generation method provided in an embodiment of the present application.

[0030] FIG3 is a schematic diagram showing an implementation flow of a code generation method provided in an embodiment of the present application.

[0031] FIG4 shows a schematic diagram of a GitHub interface provided in an embodiment of the present application.

[0032] FIG5 is a schematic diagram showing the hardware structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to facilitate understanding of the present application, the concepts of some technical fields involved in the embodiments of the present application are first explained below.

[0034] (1) Repository, which is generally referred to as a warehouse in this field, is essentially a space or location for data storage. A warehouse can contain all files corresponding to one or more development projects and can store revision records for each file.

[0035] (2) Code library, a storage space used to store project source code, also known as a code warehouse.

[0036] FIG1 shows a schematic diagram of an application scenario of a code generation method.

[0037] As shown in Figure 1, the scenario includes a development terminal 100, a server 200, and a code hosting platform 300. The code hosting platform 300 can be, for example, a platform such as GitHub, which is used to manage the source code of the hosted project so that the host can track, record, and control the modification process of the corresponding code. It is understood that the host can modify the code hosting method on GitHub, such as changing the naming convention of the code repository storing the hosted source code, changing the git URL (uniform resource locator) of the code repository, etc. However, the host cannot change the code hosting method of other users' repositories unless they are authorized to make changes.

[0038] Continuing with Figure 1 , while developing project code on development terminal 100, a developer can request managed code from code hosting platform 300. This code can be, for example, source code from an already developed project. The developer can then load the source code returned by code hosting platform 300 into a development tool for compilation, completing the code development process for the new project. Currently, code hosting platform 300 only provides managed source code, but not code templates.

[0039] Other private platforms that can provide code templates, such as WeChat TM The platform for mini-program templates provides code templates that can be stored on the server 200. If developers want to obtain such code templates, they need to access the server 200 of the private platform and usually need to pay to purchase them, which is very costly. In addition, the server 200 cannot support personalized customization when providing these code templates. Developers can only choose to download the required code templates to the local development environment running on the development terminal before they can modify the relevant content during the execution of the source code provided by the code template. Therefore, the development efficiency of generating code based on these code templates is still very low.

[0040] In order to solve the above problems, the present application provides a code generation method, which is applied to an electronic device with a compilation function or capable of running a development environment.

[0041] Specifically, the method pre-develops some code templates related to the project to be developed based on the developed project code, and designs a corresponding configuration file for the code template to configure the configuration data required for the execution of the executable code generated by the above code template and the template file that needs to be processed. The configuration data can, for example, configure the corresponding tenant information, the data acquisition path of the corresponding tenant, etc. Based on this, the above configuration file can, for example, be used to configure tenant data for the generated executable code, and the executable code can obtain the corresponding configuration data according to the tenant when it is running. In this way, developers do not need to spend energy to configure the data required for the operation of the corresponding generated executable code, and can achieve personalized customization of the executable code for different tenant data, which is conducive to improving development efficiency.

[0042] The generated template file can then be pushed to a code hosting platform and configured as a template library. Project developers who need to use the code template can select it and generate the project's executable code library with a single click. Subsequent project development can then be tailored to their needs. This secondary development process, for example, involves editing the code execution logic based on the loaded executable code, following pre-analyzed business logic corresponding to the project being developed, to complete the development of the corresponding project code.

[0043] It can be understood that the electronic devices applicable to the code generation method provided in this application may include terminal electronic devices used by developers (hereinafter referred to as development terminals), servers or server clusters, cloud platforms, etc. The server may be, for example, a compilation server, etc., which is not limited here. The development terminal may include but is not limited to tablet computers, desktop computers, laptop computers, handheld computers, netbooks, mobile phones, and augmented reality (AR) / virtual reality (VR) devices, smart TVs, smart watches and other wearable devices, car equipment, large-screen devices in which one or more processors are embedded or coupled, or other devices that can access the Internet.

[0044] FIG2 shows a schematic diagram of an implementation scenario of a code generation method according to an embodiment of the present application.

[0045] As shown in Figure 2, in this scenario, the development terminal 100 can run, for example, a client tool that can interact with the code hosting platform 300, such as a git client tool. Based on the source code of the developed project, the developer can pre-encapsulate some application programming interfaces (APIs), API call logic corresponding to the corresponding business scenario, and related context data, and further develop a code template that can generate the corresponding functional code. At the same time, the developer can also preset a configuration file for dynamically interpreting the code template in the developed code template based on some general development requirements, such as customized requirements for corresponding tenant data. The configuration file can be parsed by the corresponding engine to dynamically interpret the corresponding code template and generate the executable code required by the developer.

[0046] Developers can upload the developed code templates to the code hosting platform 300 for hosting. At this point, the developer can modify the hosting method, for example, specifying that the code templates be stored in a template library 300a preset on the code hosting platform 300. The template library 300a can be a storage space provided by the code hosting platform 300 for corresponding code templates. The code templates stored in the template library 300a can be retrieved by the server 200 for code generation. The engine service for parsing the corresponding configuration file can also be set up on the server 200.

[0047] Based on this, when some users need to call the code templates stored in template library 300a to generate corresponding executable code, they can first use the preset engine service on server 200 to dynamically interpret the corresponding code templates from template library 300a. Server 200 can obtain configuration files from code hosting platform 300 and process them, completing the above dynamic interpretation process of the corresponding code templates to generate the corresponding executable code. Server 200 can also push the generated executable code to the code hosting platform 300 for further hosting, such as storing it in the preset code library 300b. The development terminal 100 can then directly obtain the required executable code from the code hosting platform 300 for secondary development.

[0048] It is understood that the code library 300b can be used to store the customized executable code generated by dynamically interpreting the code template, and the executable code can meet the developer's personalized development needs. Therefore, the code library 300b can also be called a personalized code library or a customized code library.

[0049] It will be appreciated that the user may be any developer who needs to use the code template to generate the required executable file. In certain embodiments, the user may be or may not be the person who develops the code template, without limitation.

[0050] Based on the implementation scenario of the embodiment of the present application shown in FIG2 above, the specific implementation process of the solution of the present application is described in detail below in combination with other drawings.

[0051] FIG3 shows a schematic diagram of an implementation flow of a code generation method according to an embodiment of the present application.

[0052] As shown in FIG3 , the implementation process involves the interaction between the development terminal 100, the server 200 and the code hosting platform 300. Specifically, the process includes the following steps:

[0053] 301: The development terminal 100 encapsulates the developed project code and develops a code template that can generate corresponding function code.

[0054] For example, developers can use the development terminal 100 to encapsulate some common functional logic or business-related code logic based on project development and integration requirements, such as API call logic and context data related to the corresponding business integration. The encapsulated APIs can be one or more, each of which implements corresponding interface functions. The above code template configuration files will be described in detail below and are not detailed here.

[0055] It can be understood that in the embodiments of the present application, code hosting platforms such as GitHub can provide the function of creating a corresponding code library based on the template library. For example, the server 200 can quickly generate the required executable code for the developer on GitHub by parsing the address of the template library and calling the GitHub API.

[0056] The encapsulated API call logic may be related to the business integration applied by the developed project code, so that the developed code template can meet the functional requirements of the corresponding business scenario when it is subsequently used to generate executable code.

[0057] In addition, the encapsulated context data may include, for example, user information, token information, etc., for verifying the identity of a user (eg, a developer) who requests to obtain the corresponding code template.

[0058] 302: The development terminal 100 presets a configuration file for dynamically interpreting the code template in the code template according to development requirements.

[0059] Exemplarily, the configuration file can be used to configure the configuration data required for the execution of the executable code generated by the corresponding code template. In some embodiments, the configuration data can be files and data to be processed corresponding to different tenant configurations, as well as configuration information based on which the corresponding files or data are processed. In this way, the corresponding code template served by the configuration file can generate source code for different tenant information. Based on the above configuration file, the engine service on the server 200 can also determine which configured files need to be processed and based on which configurations the processing needs to be done, etc. in the process of generating the corresponding source code. This is not limited here and will not be elaborated on.

[0060] In some embodiments, the configuration file can be a ".json" format file, such as "configCenter.json" or "design.json." This type of file can track changes in file data and process them accordingly. For details, please refer to the relevant descriptions in the following steps and will not be repeated here.

[0061] As an example, taking "design.json" as an example, the structure of the configuration file may include but is not limited to the following parts:

[0062] The files to be processed, such as "template_files";

[0063] The name of the file to be processed, such as "design", "pom.xml";

[0064] The address of the file to be processed relative to the root directory (base_path);

[0065] The key to be replaced, for example, use "replace_keys": "tenantCode, serviceName";

[0066] It is understood that the calling path of the configuration file can be preset in the execution code of the code template, and after parsing, the configuration file can provide business integration-related interfaces, such as the encapsulated interface described above, to the engine service. The logic for parsing the configuration file is pre-designed in the engine service preset on server 200. Therefore, the configuration file can be located and the address of the file can be obtained based on the name and base_path.

[0067] In other embodiments, the configuration file may also be a file of other formats / types, such as ".java", ".properties", etc., which is not limited here.

[0068] 303: The development terminal 100 pushes the code template including the corresponding configuration file to the code hosting platform 300 for hosting.

[0069] For example, the template code template-service that has been developed can be pushed by the development terminal 100 to the GitHub platform for hosting. At this time, the developer can modify the hosting storage directory, for example, specify storage in the template library 300a.

[0070] As an example, the data package hosting the code template "template-service" may include a directory storage structure defining the template. The directory storage structure may include:

[0071] Template folder name, for example "template-service";

[0072] Maven dependency management files, such as "pom.xml";

[0073] Configuration data, such as "configCenter.json";

[0074] Configuration files, such as "design.json," control the files and content to be processed. For example, based on the contents of a configuration file like "design.json," tenant-related data in a corresponding code template can be modified to the corresponding tenant's configuration data, thereby generating executable code that can execute normally based on the correct tenant data.

[0075] Module service, such as "xxx-service-app". The service startup configuration file corresponding to the module service, such as "bootstrap.properties"; and the service source code folder, such as "src".

[0076] Test files, such as "docs / postman / env / xxxx_xxxx.postman_environment.json".

[0077] Actual code, such as #java source code "src / main / java", "src / test / java", etc.

[0078] 304: The code hosting platform 300 creates a corresponding template library for storing code templates based on the received code template hosting request.

[0079] For example, in response to a development terminal 100's request to host code templates, the code hosting platform 300 can create a template library for storing code templates, such as the template library 300a shown in FIG2 . It will be appreciated that the template library 300a created by the code hosting platform 300 can be used to store code templates uploaded by the development terminal 100, and can be accessed by the corresponding server 200 to dynamically interpret the code templates stored therein. The server 200 can, for example, be a server used by the hosting entity of the development terminal 100, and has access rights to the template library 300a.

[0080] It is understood that template library 300a can be created on code hosting platform 300 by, for example, modifying the repository configuration to set an existing code library used for hosting code as a template library. This facilitates the code hosting platform to categorize, store, and manage code templates created based on source code corresponding to different functions or services. For details, please refer to the relevant description in step 309 below and will not be repeated here.

[0081] 305 : The development terminal 100 sends a request to the server 200 to generate executable code for the required function.

[0082] For example, the development terminal 100 may request the server 200 to generate executable codes of required functions in response to the user's operational requirements for developing project codes.

[0083] It is understood that the development terminal 100 requesting to generate the executable code in this step and the development terminal 100 creating the code template and storing the code template in the code hosting platform in steps 301 to 303 can be the same device or different devices. This is not limited here.

[0084] 306 : The server 200 obtains the corresponding code template from the code hosting platform 300 .

[0085] Exemplarily, in response to the received generation request, the server 200 may obtain a corresponding code template from the template library 300a of the code hosting platform 300 based on a pre-integrated API to generate executable code that meets the above generation request.

[0086] 307: The server 200 uses a preset engine service to parse the content of the configuration file in the acquired code template.

[0087] Exemplarily, the code template acquired by the server 200 includes a corresponding preset configuration file, and the configuration file can be parsed by an engine service preset on the server 200 .

[0088] It is understood that after the code template is parsed by the engine service on server 200 and used to modify the preset modifiable content in the code template, the generated executable code structure may no longer contain the relevant content of the configuration file, such as the configuration file "design.json" in the code template "template-service" in the example of step 303 above. Accordingly, the content of the configuration file "configCenter.json" in the root directory will be changed accordingly.

[0089] The changed content in the configCenter.json file replaces the tenant information, tenant data access path, and other user-related content configured in the design.json configuration file. For example, "env" is configured as "xxx_env", "profile" is configured as "aaa", "application" is configured as "project-service", and "pathString" is configured as " / aaa / xxx_env / project-service / ".

[0090] 308: The server 200 processes the corresponding content in the obtained code template according to the content of the parsed configuration file to generate the executable code required by the user.

[0091] Exemplarily, the server 200 runs a preset engine service, which can dynamically interpret the corresponding code template based on the content parsed from the configuration file, process the part that needs to be modified or specifies tenant information, and then generate executable code that meets the actual data processing needs for subsequent project code development. In this way, the executable code generated by the code template based on the dynamic interpretation of the configuration file content can automatically modify the personalized part corresponding to the tenant information, etc. during the generation process. The executable code can obtain the required data under the corresponding tenant information based on the above modification during actual operation. Thereby, it avoids the developer from setting the corresponding data acquisition path, tenant permissions, etc. according to the project development requirements, which is conducive to improving development efficiency.

[0092] It is understood that the executable code generated above can exist in the form of a code file. The server 200 can continue to execute the following step 309 to push the corresponding code file to the code hosting platform 300 for hosting. The code hosting platform 300 can also package the code files stored in the code library and send them to the development terminal 100 in need. The project code generated by secondary development based on the loaded code files on the development terminal 100 can also be packaged and released under the operation of the developer. This application does not elaborate on this.

[0093] 309 : The server 200 pushes the generated executable code to the code hosting platform 300 .

[0094] For example, the server 200 can push the generated executable code back to the code hosting platform 300, and the code hosting platform 300 can store the portion of executable code in a preset code library 300b. In other embodiments, the server 200 can also specify that the portion of executable code be stored in the code library 300b when pushing the executable code to the code hosting platform 300. This is not a limitation.

[0095] Among them, the process in which the above-mentioned server 200 pushes the generated executable code to the code hosting platform 300 can be automatically implemented based on the settings. For example, when creating a template library 300a and a code library 300b on the code hosting platform 300, the existing code library for hosting the code can be set as a template library by modifying the repository configuration. Furthermore, the GitHub API can be integrated to automatically generate a code library corresponding to the above-mentioned template library for storing the executable code generated according to the code template. In this way, an association relationship can be established between the storage space of the code template and the storage space of the executable code generated based on the code template, so that the server 200 can accurately obtain the corresponding code template from the template library 300a and automatically store the corresponding generated executable code in the corresponding storage space.

[0096] Referring to the schematic diagram of the GitHub interface shown in Figure 4, using the template service "template-service" as an example, developers can select the Create Template Repository option 411 on the GitHub interface 410 and then rename the created template repository, for example, to "xxx-service," by modifying the original template-service name in the Rename box 412. This allows the code repository hosting the developed project code on GitHub to be set as the template repository 300a for the corresponding template. By integrating the API corresponding to the template repository on GitHub, a code repository 300b can be generated to store the executable code generated by the templates in the template repository.

[0097] The code library 300b generated by the template library 300a can be, for example, a dedicated code library corresponding to the project to be developed. As an example, the directory storage structure of the code library created based on the "xxx-service" template library created in FIG4 does not include the configuration file "design.json" described above, but only includes the newly created service startup configuration file "bootstrap.properties" under the module service "xxx-service-app", the service source code folder "src", and the test file "docs / postman / env / xxxx_xxxx.postman_environment.json" created under "docs". The created service source code folder "src" can store the corresponding generated executable code, such as the #java source code "src / main / java" and "src / test / java".

[0098] It is understood that, except for not including the configuration file design.json, the directory storage structure of the code library created based on the template library matches the directory storage structure predefined for the code template in step 303. Therefore, in the embodiment of the present application, the code for creating the template library can be the same as the code for creating the corresponding code library, and the directory storage structure predefined for the template library can be the same as the directory storage structure of the correspondingly created code library.

[0099] In this way, the server 200 executes the above steps 306 to 308, parses the configuration file through the engine service to dynamically interpret the corresponding code template, and finally generates the executable code with the corresponding personalized information configuration, and then the generated executable code can be directly pushed to the corresponding code library for storage. In view of the fact that the directory storage structure of the above template library and the corresponding code library are the same, the server 200 can obtain the code template and push the generated executable code without any obstacles, without the need to reconfigure the access path or permissions and other information corresponding to the template library or code library. In other embodiments, the process of the above server 200 executing step 309 to push the generated executable code to the code hosting platform 300 can also be described as the process of continuing to host the generated executable code on the code hosting platform 300, which is not limited here.

[0100] It is understood that by pushing the generated executable code to the code hosting platform 300, it can be provided to different developers across regions and platforms. In this way, the executable code generated based on the code generation method provided by this application can be more widely used, providing convenience for developers in various regions and platforms, and helping to improve development efficiency.

[0101] In other embodiments, the generated executable code may also be stored in the cloud space of a private platform, which is not limited here. In this case, the private platform may also provide the generated executable code to developers who need corresponding functions through tenant management.

[0102] 310: The code hosting platform 300 broadcasts the generated executable code stored in the code library.

[0103] For example, after receiving the executable code generated based on the code template pushed by the server 200, the code hosting platform 300 can store the received executable code in the corresponding code library 300b according to the hosting instruction and send a broadcast message to notify the development terminal 100. For example, the code hosting platform 300 can send a broadcast message to the development terminal 100 to inform the development terminal 100 that the executable code in the code library 300b has been updated. The specific notification form is not limited in this application.

[0104] In other embodiments, after the server 200 pushes the generated executable code to the code hosting platform 300 for continued hosting, it can also notify the development terminal 100 that the process has been completed, so as to trigger the development terminal 100 to execute the following step 311 to obtain the required executable code.

[0105] 311: The development terminal 100 obtains the executable code from the code hosting platform 300 to the local development environment.

[0106] For example, the development terminal 100 may request the executable code stored in the code library 300b from the code hosting platform 300 and capable of implementing the corresponding functions, and load the executable code returned by the code hosting platform 300 into the local development environment for execution to continue developing the project code.

[0107] It can be understood that the executable code generated based on the code template is mainly used for the framework and general function entry of the developed project. When developing a project, developers can perform secondary development based on the executable code generated above to complete their own business logic implementation or the implementation of other requirements. That is, the executable code generated by the code generation method provided in the embodiment of the present application can be used as the source code for developers to develop target projects. For example, when a customer has new requirements for the insurance policy issuance process, the developers of the insurance business service platform need to perform business logic analysis and develop and implement it based on the business requirements.

[0108] It is understood that the code templates used to generate executable code can encapsulate the details of the integration of the source code used to create the code template with the corresponding business platform. For example, developers can use certain data interfaces integrated in the corresponding code templates, such as access interfaces for corresponding tenant data, based on the business functionality requirements of the corresponding business platform. In this way, when developers load the executable code generated based on the corresponding code templates into their development environment, they can directly obtain the required tenant data to support the execution of the executable code.

[0109] FIG5 shows a schematic diagram of the hardware structure of a server 500 according to an embodiment of the present application.

[0110] It is understandable that the server 500 may be a server that supports the operation of the above-mentioned server, and may include an application server, a database server, a content management server, etc., which is not limited here.

[0111] As shown in Figure 5, in some embodiments, the server 500 may include one or more processors 504, a system control logic 508 connected to at least one of the processors 504, a system memory 512 connected to the system control logic 508, an NVM (non volatile memory) 516 connected to the system control logic 508, and a network interface 520 connected to the system control logic 508.

[0112] In some embodiments, the processor 504 may include one or more single-core or multi-core processors. In some embodiments, the processor 504 may include any combination of general-purpose processors and specialized processors (e.g., graphics processors, application processors, baseband processors, etc.). In embodiments where the server 500 employs an eNB (evolved node b) or a RAN (radio access network) controller, the processor 504 may be configured to execute various embodiments, such as those shown in Figures 2 to 4.

[0113] In some embodiments, system control logic 508 may include any suitable interface controller to provide any suitable interface to at least one of processors 504 and / or any suitable device or component in communication with system control logic 508 .

[0114] In some embodiments, the system control logic 508 may include one or more memory controllers to provide an interface to the system memory 512. The system memory 512 may be used to load and store data and / or instructions. In some embodiments, the memory 512 of the server 500 may include any suitable volatile memory, such as a suitable DRAM (dynamic random access memory).

[0115] NVM 516 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, NVM 516 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of an HDD (hard disk drive), a CD (compact disc) drive, and a DVD (digital versatile disc) drive.

[0116] NVM 516 may include a portion of storage resources on the device where server 500 is installed, or it may be accessible to the device but not necessarily part of the device. For example, NVM 516 may be accessed over a network via network interface 520.

[0117] In particular, system memory 512 and NVM 516 may include, respectively, a temporary copy and a permanent copy of instructions 524. Instructions 524 may include instructions that, when executed by at least one of processors 504, cause server 500 to implement the method illustrated in FIG3 . In some embodiments, instructions 524, hardware, firmware, and / or software components thereof may additionally or alternatively be located in system control logic 508, network interface 520, and / or processor 504.

[0118] The network interface 520 may include a transceiver for providing a radio interface for the server 500, thereby communicating with any other suitable devices (such as a front-end module, an antenna, etc.) via one or more networks. In some embodiments, the network interface 520 may be integrated with other components of the server 500. For example, the network interface 520 may be integrated with at least one of the processor 504, the system memory 512, the NVM 516, and a firmware device (not shown) having instructions. When at least one of the processors 504 executes the instructions, the server 500 implements the method shown in FIG. 4 above.

[0119] The network interface 520 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 520 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.

[0120] In one embodiment, at least one of the processors 504 may be packaged together with logic for one or more controllers of the system control logic 508 to form a system-in-package (SiP). In one embodiment, at least one of the processors 504 may be integrated with logic for one or more controllers of the system control logic 508 on the same die to form a SoC (system on chip).

[0121] Server 500 may further include input / output (I / O) devices 532. I / O devices 532 may include a user interface to enable a user to interact with server 500; peripheral component interfaces may also be designed to enable peripheral components to interact with server 500. In some embodiments, server 500 may also include sensors for determining at least one of environmental conditions and location information related to server 500.

[0122] In some embodiments, the user interface may include, but is not limited to, a display (e.g., an LCD display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., an LED flash), and a keyboard.

[0123] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.

[0124] In some embodiments, the sensors may include, but are not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit may also be part of or interact with the network interface 520 to communicate with components of a positioning network (e.g., global positioning system satellites).

[0125] References in the specification to "one embodiment" or "an embodiment" mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one exemplary implementation or technique disclosed according to the embodiment of the present application. The appearances of the phrase "in one embodiment" in various places in the specification do not necessarily all refer to the same embodiment.

[0126] The disclosure of the embodiments of the present application also relates to an operating device for executing the text. The device can be constructed specifically for the required purpose or it can include a general-purpose computer that is selectively activated or reconfigured by a computer program stored in the computer. Such a computer program can be stored in a computer-readable medium, such as, but not limited to, any type of disk, including a floppy disk, an optical disk, a CD-ROM, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an EPROM, an EEPROM, a magnetic or optical card, an application-specific integrated circuit (ASIC) or any type of medium suitable for storing electronic instructions, and each can be coupled to a computer system bus. In addition, the computer mentioned in the specification can include a single processor or can be an architecture involving multiple processors for increased computing power.

[0127] In addition, the language used in this specification has been primarily selected for readability and instructional purposes and may not be selected to describe or limit the disclosed subject matter. Therefore, the present disclosure of embodiments is intended to illustrate, not to limit, the scope of the concepts discussed herein.

Claims

1. A code generation method, characterized in that: include: The first electronic device encapsulates at least one interface in a first source code and presets a first configuration file to create a first code template, wherein the at least one interface is an interface related to business integration, the first source code is an executable code capable of implementing a first type of function or service, and the first configuration file includes configuration data related to a target user configured for the first source code; The first electronic device stores the first code template in the code hosting platform; The second electronic device obtains the first code template related to the development requirement from the code hosting platform in response to the received development requirement, wherein the development requirement includes a requirement to integrate the first type of function or service into a target project to be developed; The second electronic device parses the first configuration file encapsulated in the first code template to obtain first configuration data related to the target user, wherein the first configuration data is used to modify the modifiable content pre-configured in the first code template; The second electronic device uses the first configuration data to modify the corresponding content in the first code template, generates a target code that meets the development requirements, and stores the target code to the code hosting platform, wherein the target code is used to implement the first type of function or service to process data related to the target user.

2. The method according to claim 1, characterized in that The first electronic device storing the first code template in the code hosting platform includes: The first electronic device sends the first created code template to the code hosting platform, and instructs the code hosting platform to store the first code template into a correspondingly created template library, wherein the template library is a storage space for storing corresponding code templates created based on the first code library hosted corresponding to the first source code.

3. The method according to claim 1, characterized in that The first electronic device encapsulates at least one interface in the developed first source code, presets a first configuration file, and creates a first code template, including: The first electronic device encapsulates the call logic and context data between one or more interfaces related to the business integration into the first source code to generate a second code template; The first electronic device presets the first configuration file in the second code template, and presets a calling path corresponding to the first configuration file in the second code template, to create the first code template.

4. The method according to claim 1, characterized in that: The second electronic device includes a preset engine service for parsing the first configuration file, and the second electronic device parses the first configuration file encapsulated in the first code template to obtain first configuration data related to the target user, including: The second electronic device runs the engine service to parse the first configuration file to obtain the first configuration data.

5. The method according to claim 1, characterized in that The development requirement corresponds to a requirement of the third electronic device to generate the target code for compiling the project code of the target project, and The method comprises: It is determined that the target code has been stored in the second code library of the code hosting platform, and the second electronic device or the code hosting platform sends a notification message to the third electronic device, wherein: The notification message is used to notify the third electronic device that the target code has been stored in the second code library, wherein the second code library is a storage space for storing the target code created corresponding to the template library; The third electronic device requests the code hosting platform to obtain the target code based on the received notification message.

6. The method according to claim 5, characterized in that The notification message is a broadcast message sent by the code hosting platform, or, The notification message is a communication message sent by the second electronic device based on the communication connection between the second electronic device and the third electronic device.

7. The method according to claim 5, characterized in that The object code is stored in the second code library in the form of an executable code file, and the object code is stored in the code hosting platform, including: The second electronic device packages the executable code file corresponding to the target code and sends it to the code hosting platform, and instructs the code hosting platform to store the executable code file in the second code library.

8. The method according to any one of claims 1 to 7, characterized in that The format of the first configuration file includes any one of a json format, a java format and a properties format.

9. The method according to any one of claims 1 to 7, characterized in that The first configuration data includes at least one of tenant information, a tenant data acquisition path, and an acquisition path for running data required for executing the target code.

10. A compiler, characterized in that The method is set in a second electronic device, and the second electronic device executes the code generation method according to any one of claims 1 to 9 through the compiler.

11. A compiling device, characterized in that: The device comprises the compiler according to claim 10, and the compiling device serves as a second electronic device, and is used to execute the code generation method according to any one of claims 1 to 9.

12. An electronic device, characterized in that: include: one or more processors; One or more memories; wherein the one or more memories store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device executes the code generation method according to any one of claims 1 to 9.

13. A computer readable medium, characterized in that The computer-readable medium stores instructions, and when the instructions are executed on a computer, the computer is caused to execute the code generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Front-end project code generation method and device, computer equipment and storage medium

    CN114371841A

  • Code generation method, device and equipment

    CN115712416A

  • Code generation method and device, storage medium and computer equipment

    CN115756495A

  • Code construction method and device, computer equipment and storage medium

    CN116009852A

  • Code generation method, compiler, device, equipment and computer readable medium

    CN116820546A

Cited By

  • Code development method and related equipment

    CN114721650A

  • Computer firmware generation method based on dynamic configuration injection

    CN121680800A