Disclosure of Invention
The embodiment of the application provides a compiling method, device, equipment and storage medium, which are used for solving the following technical problems: the platform compiling efficiency is low.
The embodiment of the application adopts the following technical scheme:
the embodiment of the application provides a compiling method. Compiling the source code file when the source code file change is detected; if errors are reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining relevant dependent units; constructing a dependency unit into a compiling environment of a current platform; and compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
According to the embodiment of the application, the error reporting information is analyzed by collecting the error reporting information to determine the needed dependent units, so that the compiling mechanism of the on-demand package is realized. The embodiment of the application does not need to call all Jar packets. The compiling speed is greatly improved compared with the traditional compiling speed.
In one implementation manner of the present application, the error reporting information is parsed, and relevant dependency units are determined, which specifically includes: analyzing the collected error reporting information, extracting the related information of the Jar packet missing in the error reporting information, and introducing the Jar packet into a dependent unit.
In one implementation manner of the present application, when compiling is successful, determining the dependency unit set required for compiling and the source code file after compiling is successful, specifically includes: and after the compiling is successful, obtaining a minimum dependency unit set required by the compiling and the source code file after the compiling is successful, and caching the minimum dependency unit set so as to compile according to the minimum dependency unit set when the source code file is detected again to change.
According to the embodiment of the application, the minimum dependency unit set is cached, so that when the source code file change is detected again, compiling is directly carried out according to the minimum dependency unit set. Therefore, the compiling speed is improved, the development time is saved, the delivery speed is increased, and the development efficiency is improved.
In one implementation manner of the present application, after compiling is successful, determining the dependency unit set required for compiling and the source code file after compiling is successful, the method further includes: performing hot deployment operation on the current platform, which specifically comprises the following steps: replacing the work object in the current platform context with a class object; and updating the pre-established platform framework according to the class object.
In one implementation manner of the present application, replacing a work object in a current platform context with a class object specifically includes: converting a source code file in the current platform context into a temporary class file through a predefined class loading mechanism, initializing the temporary class file into a class object, and sending the class object to a context updater; and updating the running context of the current platform according to the context updater and the class object to finish replacing the work object in the current platform context with the class object.
In one implementation manner of the present application, updating a context of a current platform operation according to a context updater and a class object to complete replacement of a work object in the current platform context with the class object, specifically includes: and creating an instance according to the context updater and the class object, and searching a working object with the same class name as the class object in the context of the current platform operation in the source code file to finish replacing the working object in the current platform context with the class object.
In the embodiment of the application, the working object with the same class name as the class object in the context of the current platform operation is replaced to realize hot deployment. The compiling speed of the program is greatly improved, the restarting times of the platform are reduced, and the compiling efficiency of the Java program is effectively improved, so that the development time is saved.
In one implementation of the present application, before compiling the source code file, the method further includes: detecting a change of the source code; collecting a change source code file; and submitting the source code file to a quick compiling mechanism for compiling.
An embodiment of the present application provides a compiling apparatus, including: the compiling unit is used for compiling the source code file when detecting the change of the source code file; the error reporting information collecting unit is used for collecting error reporting information if errors are reported in the compiling process; the error reporting information analysis unit analyzes the error reporting information and determines related dependent units; the compiling environment construction unit constructs the dependency unit into the compiling environment of the current platform; and the recompilation unit recompilates the source code file, and determines a dependency unit set required by compilation and the source code file after the compilation is successful.
The embodiment of the application provides compiling equipment, which comprises the following components: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to enable the at least one processor to: compiling the source code file when the source code file change is detected; if errors are reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining relevant dependent units; constructing a dependency unit into a compiling environment of a current platform; and compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
The embodiment of the application provides a nonvolatile computer storage medium, which stores computer executable instructions, wherein the computer executable instructions are configured to: compiling the source code file when the source code file change is detected; if errors are reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining relevant dependent units; constructing a dependency unit into a compiling environment of a current platform; and compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
The above-mentioned at least one technical scheme that this application embodiment adopted can reach following beneficial effect: according to the embodiment of the application, the error reporting information is analyzed by collecting the error reporting information to determine the needed dependent units, so that the compiling mechanism of the on-demand package is realized. The embodiment of the application does not need to call all Jar packets. The compiling speed is greatly improved compared with the traditional compiling speed.
Detailed Description
The embodiment of the application provides a compiling method, device, equipment and storage medium.
In order to better understand the technical solutions in the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
The existing platform is suitable for various services, and a large amount of Jar packages and middleware dependencies are integrated, so that the compiling performance is low during platform development.
In addition, in the traditional compiling mode, the device needs to be restarted after each compiling is completed, and the restarting speed is low. Therefore, the compiling speed and the restarting speed are important bottlenecks affecting the development efficiency of the platform.
In order to solve the above problems, embodiments of the present application provide a compiling method, device, apparatus, and storage medium. Under the condition of not introducing any dependence, compiling is attempted, and the missing dependence class file is constructed into a compiling environment by analyzing error reporting information, so that a compiling mode of on-demand package guiding is realized. Therefore, the compiling efficiency and restarting speed of the platform can be greatly improved, and the waiting time of platform development is saved.
The following describes in detail the technical solution proposed in the embodiments of the present application through the accompanying drawings.
Fig. 1 is a flowchart of a compiling method according to an embodiment of the application. As shown in fig. 1, the compiling method includes the steps of:
s101, compiling the source code file when the source code file change is detected.
In one embodiment of the present application, source sniffing is first performed to detect changes in source files. And collecting the minimum set of the changed source code files, and submitting the collected source code files to a quick compiling mechanism for Java compiling.
S102, if errors are reported in the compiling process, collecting error reporting information.
In one embodiment of the present application, the collected source code file with the change is initially compiled, and any Jar package is not imported in the compiling process. Errors can occur when the compiling is not passed, and at this time, the compiling mechanism can collect error reporting information.
S103, analyzing the error reporting information and determining relevant dependent units.
In one embodiment of the present application, the collected error reporting information is parsed by a compiling mechanism, and the dependency units lacking in the compiling process are determined.
Specifically, the collected error reporting information is analyzed. And extracting related information of the Jar packet missing in the error reporting information, and introducing the Jar packet into a dependent unit.
It should be noted that, jar package is a software package file format, which is generally used to aggregate a large number of Java class files, related metadata and resource (text, picture, etc.) files into one file. To develop Java platform applications or libraries.
S104, building the dependent unit into the compiling environment of the current platform.
In one embodiment of the present application, the dependent units will be determined based on the error information. And constructing the determined dependent units into the current platform compiling environment.
S105, compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
In one embodiment of the present application, after the missing dependency units are built into the compilation environment, the source code file that changed is compiled again.
In one embodiment of the present application, under the condition that the recompilation is successful, a set of dependency units required for compilation and a source code file after the compilation is successful are determined. Wherein the set of dependent units comprises one or more dependent units.
Specifically, after compiling is successful, the minimum dependency unit set required by compiling and the source code file after compiling is successful are obtained. And caching the minimum dependency unit set so as to compile according to the cached minimum dependency unit set when detecting the source code file change again.
In another embodiment of the present application, in the case that recompilation fails, new error reporting information is collected, and the new error reporting information is parsed to determine missing dependent units. And constructing the lacking dependent units into the compiling environment of the current platform, and compiling the source code file again. The above operation is repeated. And after the compiling is successful, determining the dependency unit set required by the compiling and the source code file after the compiling is successful. And caching the minimum dependency unit set so as to compile according to the cached minimum dependency unit set when detecting the source code file change again.
According to the embodiment of the application, the missing dependent units are determined through error reporting information, so that the compiling mode of the on-demand package is realized. Compared with the traditional compiling mode, the method has the advantages of greatly improving the performance and the speed, and effectively improving the compiling efficiency of Java programs. Therefore, development time is saved, delivery speed is increased, and development efficiency is improved.
In one embodiment of the present application, a hot deployment operation is performed on a current platform according to the determined set of dependency units required for compilation and the source code file after the compilation is successful.
In one embodiment of the present application, the work object in the current platform context is replaced with a class object. Namely, the java object in the work in the platform context is replaced by the object constructed by the brand new class file after compiling.
Specifically, the source code file in the current platform context is converted into a temporary class file through a predefined class loading mechanism. The temporary class file is initialized to a class object and the class object is sent to the context updater.
In one embodiment of the present application, the context of the current platform run is updated according to the context updater and the class object to complete the replacement of the work object in the current platform context with the class object.
Specifically, an instance is created according to the context updater and the class object, and a working object with the same class name as the class object in the context operated by the current platform is searched in the source code file. To complete the replacement of the work object in the current platform context with a class object.
It should be noted that a class object is an abstract collection of objects having the same attributes and functions. An instance is a real object in a class object.
In one embodiment of the present application, performing the hot deployment operation on the current platform further includes updating the pre-established platform framework according to the class object.
Specifically, the CXF endpoint is reestablished according to the endpoint before the CXF frame is replaced by the class object generated after the compiling is successful, so that the CXF frame is updated.
It should be noted that CXF inherits the characteristics of Celtix and XFIre two large open source projects, and provides comprehensive support for JAX-WS. And the release and use of Web Services can be realized by adopting Code First (Code First) or WSDL First (WSDL First) according to the requirements of actual projects.
In one embodiment of the present application, the hot deployment engineering management interface contains configuration parameters such as unit name, source address, jar package deployment path, description, etc. The unit name is used for setting the functional units requiring hot deployment, and the source address is used for displaying the related engineering address. The Jar package deployment path is used for displaying the actual deployment position of the project, and the description is used for displaying the description of the current functional unit.
In one embodiment of the present application, the hot deployment project management interface further includes basic operations such as adding, editing, deleting, and the like. And, further including refreshing, auto-compiling switching, global escrow switching operations. The refreshing operation is used for automatically updating the context of the platform by using the operation after manual compiling, and the class file generated after compiling is loaded into the context. The automatic compiling switch is used for automatically detecting the change of the source code and compiling the changed source code after the automatic compiling switch is started, and automatically calling and refreshing after the compiling is successful. The global escrow switch must turn on the global escrow before the tool can take effect.
In one embodiment of the present application, the core algorithms and associated business logic for hot compilation and hot deployment are encapsulated in a jar packet named gntest-widget-fastdinggfront-comp-0.1.0-snapshot.
In one embodiment of the present application, tool deliverables used for hot compilation and hot deployment are contained in three folders jstack, metadata, web. And folders are respectively placed at corresponding positions of the platform deployment.
It should be noted that, the embodiment of the application is not limited to placing the tool delivery object in the three folders, and different numbers and names of folders may be set according to actual requirements. And the folders can be placed at different positions according to actual requirements.
Fig. 2 is a flowchart of a fast compiling mechanism according to an embodiment of the present application. As shown in fig. 2, the fast compilation mechanism includes the following flow:
in one embodiment of the present application, the source code file that is detected to be changed is compiled, and under the condition that the compiling is successful, the compiled class file is directly obtained. Under the condition that compiling is unsuccessful, error reporting information is obtained, the error reporting information is analyzed, missing Jar packets are processed according to the error reporting information, and the missing Jar packets are built into a current compiling environment. And compiling the change source code file again, and determining a dependency unit set required by compiling and a class file after compiling is successful.
Fig. 3 is a flowchart of a heat deployment provided in an embodiment of the present application. As shown in fig. 3, the hot deployment includes the following process:
in one embodiment of the present application, a class loading mechanism in a context updater may load a class file generated by a fast compilation mechanism and return the class file as a class object to the context updater.
In one embodiment of the present application, the context updater replaces the work object in the current platform context with a class object. And updating the CXF framework by the context updater by updating the CXF endpoint in the CXF framework established in advance with the class object.
The embodiment of the application realizes hot deployment by using class objects to replace the work objects in the platform context and the endpoints in the CXF framework respectively. Therefore, the compiling efficiency and restarting speed of the platform are greatly improved, and the waiting time of platform development is saved.
FIG. 4 is a block diagram of a hot compiling process according to an embodiment of the present application, and as shown in FIG. 4, the hot compiling process includes the following steps:
in one embodiment of the present application, the source code file that has changed is sniffed. And submitting the changed file to a quick compiler to compile the source code file.
In one embodiment of the present application, the compilation is indicated as successful in the event that no error has occurred in the compilation. Under the condition that the compiling has error reporting, analyzing error reporting information, determining a missing dependent unit according to the error reporting information, and constructing the missing dependent unit into the current compiling environment. And compiling the changed source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful when errors are not reported in the compiling process, namely after compiling is successful.
Fig. 5 is a schematic structural diagram of a compiling apparatus according to an embodiment of the present application, where the compiling apparatus includes: the system comprises a compiling unit S501, an error information collecting unit S502, an error information analyzing unit S503, a compiling environment constructing unit S504 and a recompilation unit S505.
A compiling unit S501, configured to compile a source code file when detecting a change of the source code file;
the error reporting information collecting unit S502 is used for collecting error reporting information if errors are reported in the compiling process;
the error reporting information analyzing unit S503 analyzes the error reporting information and determines relevant dependent units;
a compiling environment construction unit S504, configured to construct the dependency unit into a compiling environment of the current platform;
and the recompilation unit S505 recompilates the source code file, and determines a dependency unit set required by compilation and the source code file after the compilation is successful.
Fig. 6 is a schematic structural diagram of a compiling apparatus according to an embodiment of the present application, where the apparatus includes:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
compiling the source code file when the source code file change is detected;
if errors are reported in the compiling process, collecting error reporting information;
analyzing the error reporting information and determining relevant dependent units;
constructing the dependency unit into a compiling environment of a current platform;
and compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
A non-volatile computer storage medium provided in an embodiment of the present application stores computer executable instructions configured to:
compiling the source code file when the source code file change is detected;
if errors are reported in the compiling process, collecting error reporting information;
analyzing the error reporting information and determining relevant dependent units;
constructing the dependency unit into a compiling environment of a current platform;
and compiling the source code file again, and determining a dependency unit set required by compiling and the source code file after compiling is successful.
All embodiments in the application are described in a progressive manner, and identical and similar parts of all embodiments are mutually referred, so that each embodiment mainly describes differences from other embodiments. In particular, for apparatus, devices, non-volatile computer storage medium embodiments, the description is relatively simple, as it is substantially similar to method embodiments, with reference to the section of the method embodiments being relevant.
The foregoing describes specific embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the embodiments of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present application should be included in the scope of the claims of the present application.