A method of synthesizing application program source code
By automatically merging source code and generating scaffolding and dynamic source code in the platform, the software solves the problems of low efficiency and easy omissions in manual merging in existing technologies, and achieves efficient source code merging and management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2026-03-20
AI Technical Summary
In existing technologies, the source code merging process relies on manual processing, which is time-consuming, prone to omissions, and inefficient.
The software program automatically executes the merging process of scaffold source code and dynamic source code in the source code generation platform, including obtaining, copying, pasting and uploading to the GitLab management system, and using scheduled tasks or message queue services for automated processing.
It automates the source code merging process, saving labor costs, improving execution efficiency, and avoiding human error.
Smart Images

Figure CN115543427B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software development, and particularly relates to a method for synthesizing application program source code. BACKGROUND
[0002] With the progress of social technology, computer and Internet technology develops rapidly and matures day by day, and computer and other electronic terminal products have penetrated into all aspects of human life. These electronic products need to install various programs and software to realize corresponding functions, so that people's dependence on various software program products is also increasing. The demand for software products in today's society is increasing, which makes technical personnel face huge new software development needs. In order to improve the production efficiency of software, reduce the development cost and shorten the development cycle, the source code automatic generation technology appears. At present, some source code automatic generation platforms play a positive role in improving the software development efficiency of programmers, reducing the development intensity of software, and standardizing the development process of software.
[0003] In the conventional source code automatic generation platform, the source code is generally divided into two parts: scaffold source code and dynamic source code generated in real time; wherein the scaffold source code is mainly the framework part with strong universality; and the dynamic source code is the code part related to business logic function generated in real time for a specific application; in short, the complete source code of a specific application program needs to merge the two parts of source code according to certain specifications to obtain the complete source code that can realize the complete function. In the prior art, the merging of the two kinds of source codes is mainly based on manual processing, that is, the developer first manually obtains the scaffold source code through Gitlab (an open source project for repository management system, using Git as a code management tool, and a Web service built on this basis), and then puts the dynamic source code into the scaffold source code through copying, pasting and other methods to add and replace, so as to merge into the complete source code of the application program, and finally submit the complete source code of the successful merging to Gitlab for management. This processing method of merging source code takes a long time and is not efficient, and manual processing is also prone to omission.
[0004] Therefore, the present application aims to provide a method for synthesizing application program source code, which can automatically merge the scaffold source code and the dynamic source code in the source code automatic generation platform, thereby improving the automation degree of the source code generation platform and saving manpower. SUMMARY
[0005] The purpose of the present application is to overcome the above-mentioned deficiencies of the prior art and provide a method for synthesizing application program source code; the method can be automatically executed by software, that is, the scaffold source code and the dynamic source code in the source code automatic generation platform can be automatically merged, thereby saving manpower.
[0006] The technical solution of the present application is: a method for synthesizing application source code, which is automatically executed by a software program, comprising the following steps:
[0007] S1, obtaining an application to be synthesized; that is, obtaining an application that has not been merged and has generated dynamic source code;
[0008] S2, obtaining a scaffold source code through Gitlab calling, and storing the scaffold source code under a specified temporary folder;
[0009] S3, obtaining the folder path of the dynamic source code and all files under the folder;
[0010] S4, copying the files in the dynamic source code to the temporary folder, to realize replacement or addition of corresponding files in the temporary folder;
[0011] S5, uploading all source codes under the temporary folder after the previous step of processing to Gitlab for management through interface calling;
[0012] S6, marking the processed application as synthesized.
[0013] Further, in step S1, the application that has not been merged is obtained through a timing task or a message queue service.
[0014] Further, in step S1, the application to be synthesized is placed in a database, and then the corresponding data is obtained through message queue consumption or timing task query database for subsequent synthesis processing.
[0015] Further, before executing the step S2, the temporary folder is emptied first, and the scaffold source code includes front-end, back-end and SQL script files.
[0016] Further, in step S2, the temporary folder is dynamically generated according to the current time, to avoid problems caused by folder duplication.
[0017] Further, in step S4, the front-end, back-end and SQL script files in the dynamic source code are respectively replaced with corresponding files under the temporary folder or added to the specified path under the temporary folder through copy and paste operations.
[0018] Further, in step S4, the file stream method in Java (a programming language) is used to recursively obtain all files and contents in the dynamic source code, and the files are saved to the same relative path under the temporary folder through copy, paste or replacement.
[0019] Further, in the step S5, the Git repository corresponding to the application is found through the http request of Gitlab, and a new repository branch is created, and the folder after the successful merging is uploaded to Gitlab.
[0020] Further, before the step S6 is executed, the temporary folder and the folder saving the dynamic source code are deleted, so as to reduce the occupation and waste of the server space resources.
[0021] Compared with the prior art, the application has the beneficial effects that the application can realize the automatic merging of the application source code through software, saves the labor cost, greatly improves the execution efficiency, and can avoid the omission caused by human reasons through the automatic acquisition of the application source code merging task through the timing task or the message queue service. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is the flowchart of the application. DETAILED DESCRIPTION
[0023] The application will be further described in detail below in combination with specific embodiments, and the methods or functional components not specifically described in the embodiments are prior art.
[0024] Embodiment 1
[0025] As shown in the figure, the embodiment is a method for synthesizing application program source code, which is automatically executed by a synthesis program, and the core process includes the following steps: Figure 1
[0026] S1, acquiring the application to be synthesized through the timing task or the message queue;
[0027] For the application to be synthesized, the application is placed in the message queue or the database, and the corresponding data is acquired through the message queue consumption or the database query through the timing task to perform the subsequent synthesis processing. In the embodiment, the operation is performed in the form of the timing task in the Java language, the timing task is created by using Java, and the cycle period of the timing task is set to: executed once every 10 seconds, so that the synthesis program in the application acquires the application information of the source code to be synthesized every 10 seconds.
[0028] S2, acquiring the scaffold source code through Gitlab calling;
[0029] In the source code automatic generation platform, the source code of an application is divided into two parts: dynamic source code and scaffold source code. To facilitate code maintenance and acquisition, the scaffold source code is placed in Gitlab for management. In this step, the scaffold source code is downloaded from Gitlab and stored in a designated temporary folder. The temporary folder can be dynamically generated according to the current time to avoid problems caused by folder duplication, such as the path of the temporary folder: / usr / local / kepler / appGen / kepleradmin / 20220101140958445.
[0030] S3, obtaining the dynamic source code of the application to be synthesized;
[0031] According to the information of the application to be synthesized obtained in step S1, the program will automatically obtain the folder path and content of the dynamic source code of the application.
[0032] For example: / usr / local / kepler / beetlGen, the files in the path have been divided according to specific standards when generated, which are divided into: sql (sql script folder), web (front-end program folder), and admin (back-end program folder).
[0033] S4, merging all source codes through copying, pasting, replacing, etc.
[0034] The synthesis program in this embodiment will recursively obtain all files and contents in the dynamic source code through the file stream method in Java, and save the files to the same relative path under the scaffold temporary folder through copying, pasting, or replacing, for example:
[0035] Copy the file in the / usr / local / kepler / beetlGen folder with the path admin / kepler-appl / src / main / resources / mapper / JiZuXinXiMapper.xml to the / usr / local / kepler / appGen / kepleradmin / 20220906140958445 folder, and the relative path address is: admin / kepler-appl / src / main / resources / mapper / JiZuXinXiMapper.xml. Through this operation, the integration of all files is completed.
[0036] S5, uploading the synthesized application source code to Gitlab;
[0037] After the application source code merging is completed, the program finds the Git repository corresponding to the application through the http request of Gitlab and creates a new repository branch, and uploads the folder after the merging to Gitlab.
[0038] S6, emptying the temporary folder created by the synthesis operation;
[0039] After the code is pushed, the temporarily created folder is deleted: the temporary folder for saving the scaffold source code and the folder for saving the dynamic source code, so as to reduce the occupation and waste of server space resources.
[0040] S7, marking the application as a synthesized state
[0041] Accessing the database modifies the application source code synthesis state to be synthesized, avoiding repeated detection and execution of code merging.
[0042] The above is only some embodiments of the present application and is not used to limit the present application. For those skilled in the art, the present application can have combinations and variations of the foregoing various technical features, and those skilled in the art can improve, modify, replace, or use the structure or method of the present application in other fields to achieve the same effect without departing from the spirit and scope of the present application.
Claims
1. A method for synthesizing application source code, characterized in that, This method is executed automatically by a software program and includes the following steps: S1. Obtain the application to be merged; that is, obtain the application that has not been merged and has generated dynamic source code; S2. Obtain the scaffolding source code via GitLab and save the scaffolding source code to the specified temporary folder; S3. Obtain the folder path of the dynamic source code and all files in the folder; S4. Copy the files from the dynamic source code to the temporary folder to replace or add the corresponding files in the temporary folder; S5. Upload all the source code in the temporary folder processed in the previous step to GitLab for management via API call; S6. Mark the processed application as "composite"; In step S1, the application source code to be synthesized is placed into the database, and then the corresponding data is obtained by consuming the message queue or querying the database through a scheduled task for subsequent synthesis processing.
2. The method for synthesizing application source code according to claim 1, characterized in that: In step S1, applications that have not been merged are obtained through scheduled tasks or message queue services.
3. The method for synthesizing application source code according to claim 1, characterized in that: Before performing step S2, the temporary folder is cleared. The scaffolding source code includes front-end, back-end, and SQL script files.
4. The method for synthesizing application source code according to claim 1, characterized in that: In step S2, the temporary folder is dynamically generated based on the current time to avoid problems caused by duplicate folders.
5. The method for synthesizing application source code according to claim 1, characterized in that: In step S4, the front-end, back-end, and SQL script files in the dynamic source code are copied and pasted to replace the corresponding files in the temporary folder or add them to the specified path in the temporary folder.
6. The method for synthesizing application source code according to claim 1, characterized in that: In step S4, all files and contents in the dynamic source code are recursively obtained through Java's file stream methods, and the files are saved to the same relative path in the temporary folder by copying, pasting, or replacing.
7. The method for synthesizing application source code according to claim 1, characterized in that: In step S5, the Git repository for the corresponding application is located through an HTTP request to GitLab, a new repository branch is created, and the merged folder is uploaded to GitLab.
8. The method for synthesizing application source code according to claim 1, characterized in that: Before performing step S6, delete the temporary folder and the folder that stores dynamic source code to reduce the occupation and waste of server space resources.
Citation Information
Patent Citations
Automatic software development system, automatic software generation method and equipment
CN113434117A
Continuous integration method and device, computer equipment and storage medium
CN113703730A