Disclosure of Invention
The embodiment of the application provides a compiling method, a compiling device, equipment and a storage medium, which are used for solving the following technical problems: platform compilation efficiency is low.
The embodiment of the application adopts the following technical scheme:
the embodiment of the application provides a compiling method. When detecting that the source code file is changed, compiling the source code file; if the error is reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining a related dependent unit; building a dependent 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 information is collected and analyzed to determine the required dependent unit, so that the compiling mechanism of the package guiding according to the requirement is realized. The embodiment of the application does not need to call all Jar packages. The compiling speed is greatly improved compared with the traditional compiling speed.
In an implementation manner of the present application, analyzing error information and determining a related dependency unit specifically includes: analyzing the collected error reporting information, extracting the relevant information missing from the Jar packet in the error reporting information, and introducing the Jar packet into a dependent unit.
In an implementation manner of the present application, when compiling is successful, determining a dependency unit set required for compiling and a source code file after compiling is successful, specifically including: and after the compiling is successful, obtaining a minimum dependency unit set required by the compiling and a source code file after the compiling is successful, and caching the minimum dependency unit set so as to carry out the compiling according to the minimum dependency unit set when the source code file change is detected again.
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, the compilation is directly carried out according to the minimum dependency unit set. Therefore, the compiling speed is improved, so that the development time is saved, the delivery speed is accelerated, and the development efficiency is improved.
In an implementation manner of the present application, after determining a dependency unit set required for compilation and a source code file after successful compilation, the method further includes: performing a hot deployment operation on a current platform, specifically comprising: 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 an 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 context of the current platform operation according to the context updater and the class object so as to replace the work object in the current platform context with the class object.
In an 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 replacing 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 work object which is the same as the class name of the class object in the context of the current platform operation in the source code file so as to replace the work object in the current platform context with the class object.
According to the method and the device, the working objects which are the same as the class names of the class objects in the context of the current platform operation are replaced, so that hot deployment is achieved. The method and the device greatly improve the compiling speed of the program, reduce the restarting times of the platform, and effectively improve the compiling efficiency of the Java program, thereby saving the development time.
In an implementation manner of the present application, before compiling the source code file, the method further includes: detecting a change in source code; collecting a change source code file; and submitting the source code file to a rapid 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 that the source code file is changed; an error information collecting unit for collecting error information if an error is reported in the compiling process; the error information analysis unit is used for analyzing the error information and determining a related dependence unit; the compiling environment constructing unit is used for constructing the dependent unit into the compiling environment of the current platform; and the recompilation unit is used for recompiling the source code file, and determining a dependency unit set required by compilation and the source code file after successful compilation.
An embodiment of the present application provides a compiling apparatus, including: 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 to cause the at least one processor to: when detecting that the source code file is changed, compiling the source code file; if the error is reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining a related dependent unit; building a dependent 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, and the computer-executable instructions are configured to: when detecting that the source code file is changed, compiling the source code file; if the error is reported in the compiling process, collecting error reporting information; analyzing the error reporting information and determining a related dependent unit; building a dependent 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 adopts at least one technical scheme which can achieve the following beneficial effects: according to the embodiment of the application, the error information is collected and analyzed to determine the required dependent unit, so that the compiling mechanism of the package guiding according to the requirement is realized. The embodiment of the application does not need to call all Jar packages. The compiling speed is greatly improved compared with the traditional compiling speed.
Detailed Description
The embodiment of the application provides a compiling method, a compiling device, compiling equipment and a storage medium.
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any inventive step based on the embodiments of the present disclosure, shall fall within the scope of protection of the present application.
The existing platform is required to adapt to various services, a large number of Jar packages and the dependence of middleware are integrated, and therefore the compiling performance is low when the platform is developed.
In addition, in the conventional compiling method, the compiling needs to be restarted each time after being finished, and the restarting speed is slow. Therefore, the compiling speed and the restarting speed are important bottlenecks affecting the efficiency of the platform development.
In order to solve the above problem, embodiments of the present application provide a compiling method, apparatus, device, and storage medium. And (4) trying to compile without introducing any dependency, and constructing the lacking dependency class file into a compiling environment by analyzing error reporting information, so as to realize the compiling mode of the package-on-demand. Therefore, the compiling efficiency and the restarting speed of the platform can be greatly improved, and the waiting time of platform development is saved.
The technical solutions proposed in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a compiling method provided in the application embodiment. As shown in fig. 1, the compiling method includes the following steps:
s101, when detecting that the source code file is changed, compiling the source code file.
In one embodiment of the present application, source sniffing is performed first to detect changes to the source code file. 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 the error is reported in the compiling process, collecting error report information.
In an embodiment of the application, the collected source code file with the change is initially compiled, and no Jar package is imported in the compiling process. Errors may occur if the compilation is not passed, and at this time, the compilation mechanism may collect error information.
S103, analyzing the error information and determining a relevant dependent unit.
In an embodiment of the application, the collected error information is analyzed through a compiling mechanism, and a dependency unit which is lacked in a compiling process is determined.
Specifically, the collected error information is analyzed. Extracting the relevant information missing from the Jar packet in the error reporting information, and introducing the Jar packet into a dependent unit.
It should be noted that the Jar package is a software package file format, and is generally used for aggregating a large number of Java class files, related metadata and resource (text, picture, etc.) files into one file. In order to develop Java platform applications or libraries.
And S104, constructing the dependent unit into the compiling environment of the current platform.
In one embodiment of the present application, the dependent units will be determined from the error information. And building the determined dependent unit into the current platform compiling environment.
And 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, the source code file with the change is recompiled after the missing dependent unit is built into the compilation environment.
In an embodiment of the present application, in the case of successful recompilation, a set of dependent units required for compilation and a source code file after successful compilation are determined. Wherein the set of dependency units includes one or more dependency units.
Specifically, after the compilation is successful, a minimum dependency unit set required by the compilation and a source code file after the compilation is successful are obtained. And caching the minimum dependent unit set so as to compile according to the cached minimum dependent unit set when the source code file change is detected again.
In another embodiment of the present application, in case the recompilation fails, new error information that appears is collected and parsed to determine the missing dependent units. And constructing the missing dependent units into the compiling environment of the current platform, and compiling the source code file again. The above operations are repeated. And when the compiling is successful, determining a dependency unit set required by the compiling and a source code file after the compiling is successful. And the minimum dependency unit set is cached, so that compiling is carried out according to the cached minimum dependency unit set when the source code file change is detected again.
The embodiment of the application determines the missing dependent units by reporting error information, so as to realize the compiling mode of the package guiding according to the requirement. Compared with the traditional compiling mode, the method has the advantages that the performance and the speed are greatly improved, and the compiling efficiency of the Java program is effectively improved. Therefore, the development time is saved, the delivery speed is accelerated, and the development efficiency is improved.
In an embodiment of the present application, a hot deployment operation is performed on a current platform according to a determined dependency unit set required for compilation and a source code file after successful compilation.
In one embodiment of the present application, the work objects in the current platform context are replaced with class objects. Namely, replacing the java objects in work in the platform context with the objects built by the completely new compiled class files.
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 the 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 operation is updated according to the context updater and the class object, so as 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 work object with the same class name as the class object in the context of the current platform operation is searched in the source code file. To accomplish the replacement of the work object in the current platform context with the class object.
It should be noted that a class object is an abstract collection of objects having the same properties and functions. An instance is a real object in a class object.
In one embodiment of the present application, the hot deployment operation is performed on the current platform, and further comprises updating the pre-established platform framework according to the class object.
Specifically, the CXF endpoint is reestablished by replacing the endpoint before the CXF framework with the class object generated after the compilation is successful, thereby updating the CXF framework.
It should be noted that CXF inherits the features of the two major open source projects, Celtix and XFire, and provides comprehensive support for JAX-WS. And according to the needs of actual projects, the release and use of the Web Services can be realized by adopting Code First or WSDL First.
In one embodiment of the application, the thermal deployment engineering management interface includes configuration parameters such as unit name, source address, Jar package deployment path, description, and the like. The unit name is used for setting the functional unit needing hot deployment, and the source address is used for displaying the involved 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 application, the thermal deployment engineering management interface further comprises basic operations of adding, editing, deleting and the like. And, also include refresh, auto-compile switch, global managed switch operations. After the refreshing operation is used for manual compiling, the context of the platform can be automatically updated by using the refreshing operation, and the class file generated after compiling is loaded into the context. The automatic compiling switch is used for starting automatic compiling, the tool can automatically detect the change of the source code and compile the changed source code, and automatic calling and refreshing are carried out after compiling is successful. The global escrow switch must turn on global escrow before the tool can take effect.
In one embodiment of the application, the core algorithm and related business logic of hot compilation and hot deployment are encapsulated in a jar package named gntest-widget-fastdingfront-comp-0.1.0-snap shot.
In one embodiment of the present application, tool deliverables for hot compilation and hot deployment are contained in the three folders jstack, metadata, and web. And the folders are respectively placed at the platform deployment corresponding positions.
It should be noted that, the embodiment of the present application is not limited to placing the tool deliveries in the three folders, and different numbers and names of the folders may be set according to actual application 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 flows:
in an embodiment of the present application, the detected source code file with the change is compiled, and in case of successful compilation, the compiled class file is directly obtained. And under the condition of unsuccessful compiling, acquiring error reporting information, analyzing the error reporting information, processing the missing Jar package according to the error reporting information, and constructing the missing Jar package into the current compiling environment. And compiling the changed source code file again, and determining a dependency unit set required by compiling and a class file after compiling is successful after compiling is successfully carried out.
Fig. 3 is a flowchart of thermal deployment according to an embodiment of the present application. As shown in fig. 3, thermal deployment includes the following processes:
in one embodiment of the present application, a class loading mechanism in the context updater may load the class files generated by the fast compilation mechanism and initialize the class files as class objects back to the context updater.
In one embodiment of the present application, the context updater replaces work objects in the current platform context with class objects. And updating the CXF endpoint in the pre-established CXF framework by using the class object by the context updater so as to update the CXF framework.
The embodiment of the application realizes the hot deployment by using the class object to respectively replace the working object in the platform context and the endpoint in the CXF framework. Therefore, the compiling efficiency and the restarting speed of the platform are greatly improved, and the waiting time of the platform development is saved.
Fig. 4 is a block diagram of a hot compiling flow provided by an embodiment of the present application, and as shown in fig. 4, the hot compiling includes the following processes:
in one embodiment of the present application, the source code file that is changed is sniffed. And submitting the changed file to a fast compiler to compile the source code file.
In one embodiment of the present application, in case no error occurs in the compilation, it indicates that the compilation was successful. And under the condition of error reporting during compiling, 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 successful compiling when no error is reported in the compiling process, namely when the compiling is successful.
Fig. 5 is a schematic structural diagram of a compiling apparatus according to an embodiment of the present application, where the apparatus includes: the compiling unit S501, the error information collection unit S502, the error information analysis unit S503, the compiling environment construction unit S504, and the recompiling unit S505.
A compiling unit S501, when detecting that the source code file is changed, compiling the source code file;
an error information collecting unit S502, for collecting error information if an error is reported in the compiling process;
an error information analysis unit S503, which analyzes the error information and determines a relevant dependent unit;
a compiling environment constructing unit S504, which constructs the dependency unit into the compiling environment of the current platform;
and a recompilation unit S505 that recompiles the source code file, and determines a dependency unit set required by the 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; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
when detecting that the source code file is changed, compiling the source code file;
if the error is reported in the compiling process, collecting error reporting information;
analyzing the error reporting information to determine a related dependent unit;
building the dependent 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 successful compiling.
A non-volatile computer storage medium provided in an embodiment of the present application stores computer-executable instructions configured to:
when detecting that the source code file is changed, compiling the source code file;
if the error is reported in the compiling process, collecting error reporting information;
analyzing the error reporting information to determine a related dependent unit;
building the dependent 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 successful compiling.
The embodiments in the present application are described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the device, and the nonvolatile computer storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
The foregoing description of specific embodiments of the present application has been presented. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may 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 may also be possible or may be advantageous.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art to which the embodiments of the present application pertain. 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.