CN114924788A - Code synchronization method and device - Google Patents

Code synchronization method and device Download PDF

Info

Publication number
CN114924788A
CN114924788A CN202210850796.4A CN202210850796A CN114924788A CN 114924788 A CN114924788 A CN 114924788A CN 202210850796 A CN202210850796 A CN 202210850796A CN 114924788 A CN114924788 A CN 114924788A
Authority
CN
China
Prior art keywords
module
modules
code synchronization
code
target module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210850796.4A
Other languages
Chinese (zh)
Other versions
CN114924788B (en
Inventor
陶超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210850796.4A priority Critical patent/CN114924788B/en
Publication of CN114924788A publication Critical patent/CN114924788A/en
Application granted granted Critical
Publication of CN114924788B publication Critical patent/CN114924788B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure relates to a code synchronization method and device, and belongs to the technical field of computers, wherein the code synchronization method comprises: in response to a start event of code synchronization, determining a target module in the selected module set; wherein, the target module is a module to be developed; replacing source code paths of other modules except the target module in the selected module set with dependent objects corresponding to the other modules, wherein the dependent objects are used for acquiring compiled files of the other modules; providing model information of the target module, wherein the model information is used for completing code synchronization of the target module. The method and the device solve the problem that the code synchronization process is accelerated, but the related functions of other modules depended on by the module to be developed cannot be used in the subsequent development process.

Description

Code synchronization method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a code synchronization method and apparatus.
Background
For a large single-bin multi-module engineering project with more than one million codes, an Integrated Development Environment (IDE) is started to be capable of normally writing codes, namely the IDE codes are synchronously completed and may wait for more than 20 minutes, thereby seriously affecting the Development efficiency.
In order to accelerate the code synchronization process of the IDE, the code quantity which needs to be understood by the IDE is effectively reduced in a manner of not loading other modules besides the module to be developed in the related art.
However, in this implementation manner, other modules except the module to be developed are completely ignored, so that all the dependency relationships between the modules are lost, and although the code synchronization process of the IDE is accelerated, the related functions of the other modules on which the module to be developed depends cannot be used in the subsequent development process, such as incapability of searching, incapability of modifying in batch, incapability of participating in compilation, and the like.
Disclosure of Invention
The present disclosure provides a code synchronization method and apparatus, so as to at least solve the problem that the code synchronization process is accelerated, but the related functions of other modules on which a module to be developed depends cannot be used in the subsequent development process.
According to an aspect of the embodiments of the present disclosure, there is provided a code synchronization method including:
in response to a start event of code synchronization, determining a target module in the selected module set; wherein the target module is a module to be developed;
replacing source code paths of other modules in the selected module set except the target module with dependent objects corresponding to the other modules, wherein the dependent objects are used for acquiring compiled files of the other modules;
providing model information of the target module, wherein the model information is used for completing code synchronization of the target module.
In a possible implementation manner, the replacing the source code paths of the other modules in the selected module set except the target module with the dependent objects corresponding to the other modules includes:
in response to a synchronization request generated for the other module in the code synchronization process, replacing a source code path of the other module with the dependent object corresponding to the other module;
in one possible embodiment, when the synchronization request generated for the other module in the process of code synchronization is responded, the code synchronization method further comprises the following steps:
and returning a null response, wherein the null response is used for enabling the model information analysis process of the other modules in the code synchronization process to be skipped.
In one possible embodiment, the determining a target module in the selected module set in response to a start event of code synchronization includes:
responding to the starting event, and acquiring a module identifier set for the selected module set;
determining the module corresponding to the module identification in the selected module set as the target module.
In one possible implementation, the code synchronization method further includes:
in response to completion of the determination of the target module, obtaining the dependent object corresponding to each of the other modules;
wherein the compiled file for each of the other modules is obtained via the dependent object.
In one possible embodiment, the replacing the source code paths of the other modules in the selected module set except the target module with the dependent objects corresponding to the other modules includes:
determining a storage area of a source code path of the other module;
emptying the storage area;
and adding the dependency objects corresponding to the other modules to the emptied storage area through transferable dependencies.
In one possible implementation, the providing model information of the target module includes:
returning the model information of the target module in response to a synchronization request generated for the target module during the code synchronization.
According to another aspect of the embodiments of the present disclosure, there is provided a code synchronization apparatus including:
a determination module configured to perform a start event in response to code synchronization, determining a target module of the selected set of modules; the target module is a module to be developed;
a replacing module configured to replace source code paths of other modules in the selected module set except the target module with dependent objects corresponding to the other modules, wherein the dependent objects are used for acquiring compiled files of the other modules;
a providing module configured to execute providing model information of the target module, wherein the model information is used to complete code synchronization of the target module.
According to another aspect of the embodiments of the present disclosure, there is provided an electronic device including:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the executable instructions to implement the code synchronization method of any of the above embodiments.
According to another aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein at least one instruction of the computer-readable storage medium, when executed by a processor of an electronic device, enables the electronic device to implement the code synchronization method of any one of the above embodiments.
According to another aspect of the embodiments of the present disclosure, there is provided a computer program product including a computer program, which when executed by a processor implements the code synchronization method of any of the above embodiments.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
by replacing the source code paths of other modules except the target module in the selected module set with the dependent objects corresponding to the other modules, the topological structure of each module in the selected module set is reserved, so that a compiled file can be obtained through the dependent objects in the subsequent development process, and the related functions of the other modules on which the module to be developed depends can be used in the subsequent development process; model information is only provided for the target module in the selected module set and is used for understanding the related codes of the target module so as to complete code synchronization of the target module, so that the analysis time of the model information in the synchronization process is greatly saved, namely the code synchronization time is saved; therefore, the scheme solves the problem that the code synchronization process is accelerated, but the related functions of other modules depended on by the module to be developed cannot be used in the subsequent development process.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a schematic diagram of an implementation environment of a code synchronization method according to an example embodiment;
FIG. 2 is a flow diagram illustrating a method of code synchronization in accordance with an illustrative embodiment;
FIG. 3 is a flow diagram illustrating a method for code synchronization based on null shell and null response in accordance with an illustrative embodiment;
FIG. 4 is an architectural diagram illustrating a code synchronization in accordance with an exemplary embodiment;
FIG. 5 is a schematic diagram illustrating a model information acquisition flow in code synchronization according to an example embodiment;
FIG. 6 is an initial module dependency diagram illustrating in accordance with an exemplary embodiment;
FIG. 7 is a diagram illustrating module dependencies in a code synchronization in accordance with an illustrative embodiment;
FIG. 8 is a block diagram illustrating the logical structure of a code synchronization apparatus in accordance with one illustrative embodiment;
fig. 9 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the disclosure, as detailed in the appended claims.
For a large single-bin multi-module engineering project with more than one million lines of codes, IDE (integrated development environment), such as Intelli JIDEA, android studio and the like, from the triggering of code synchronization to the completion of code synchronization, namely, the normal code writing can take more than 20 minutes, and the development efficiency is seriously influenced.
Moreover, if the memory or CPU resources of the development device deploying the IDE are insufficient, even the IDE cannot complete code synchronization, so that subsequent functions such as code prompting, skipping, searching and the like cannot be used, and meanwhile, the development device is stuck, and other operations are affected.
In order to solve the problems of long synchronization time of IDE codes and unsmooth locking of development equipment in the related art, the problems are solved by not loading other modules except for the module to be developed. Because the other modules are not loaded completely and neglected, although the synchronization process of the IDE codes is accelerated, if the modules to be developed depend on other modules in the subsequent development process, the related functions of other modules cannot be used, that is, the dependency relationship between the modules is destroyed, the related functions cannot be realized, and the real synchronization of the IDE codes cannot be realized.
Because the dependency relationship between modules is complex, the dependency relationship between modules cannot be configured one by one before code synchronization, or the configuration of the dependency relationship between modules needs high labor cost, so that the preprocessing of code synchronization is performed by knowing the dependency relationship between modules in advance, which needs high cost to implement.
In view of this, the embodiment of the present disclosure provides a code synchronization method, in which source code paths of other modules in a selected module set except for a target module are replaced with dependent objects corresponding to the other modules, and a topology structure of each module in the selected module set is maintained, so that a compiled file can be obtained through the dependent objects in a subsequent development process, and related functions of the other modules on which the module to be developed depends can be used in the subsequent development process; model information is only provided for a target module in the selected module set and is used for understanding relevant codes of the target module so as to complete code synchronization of the target module, and model information is not provided for other modules, so that analysis of the model information of other modules is skipped, and the analysis time of the model information in the code synchronization process is greatly saved, namely the code synchronization time is saved; therefore, the scheme can solve the problem that the code synchronization process is accelerated, but the related functions of other modules depended by the module to be developed cannot be used in the subsequent development process.
Fig. 1 is a schematic diagram of an implementation environment of a code synchronization method according to an exemplary embodiment, and referring to fig. 1, a local server 101 and a remote server 102 may be included in the implementation environment, which is described in detail below.
In an alternative embodiment, the local server 101 may be a stand-alone physical server, or may be a server cluster or distributed system composed of a plurality of physical servers.
In an alternative embodiment, the IDE code synchronization based on the Gradle Tooling API is taken as an example, wherein the Gradle Tooling API is a programming API provided by Gradle, allowing developers to execute and monitor builds, and query Gradle for build details. If the local server 101 is an independent physical server, a project automation open source construction tool (Gradle) and IDE based on the concepts of Apache Ant and Apache Maven can be operated on the local server 101; if the local server 101 is a server cluster or distributed system composed of a plurality of physical servers, the Gradle may run on at least one physical server in the local server 101, the IDE may run on at least one physical server in the local server 101, and the Gradle and the IDE may also run on at least one physical server in the local server 101 that is the same or different.
In an alternative embodiment, the remote server 102 may or may not exist, and for an implementation environment where the remote server does not exist, compiled files of modules other than the target module (module to be developed) may be stored on at least one local server 101; FIG. 1 illustrates the presence of a remote server 102; the remote server 102 may be configured to manage compiled files, such as a Maven (maiden) system deployed on the remote server 102 for managing compiled files after code compilation, and the compiled files may be binary archive files, but are not limited thereto, such as AAR (or aaar); wherein, aar (Android archive) is a binary archive file of an Android library item. The remote server 102 may be an independent physical server, a server cluster or a distributed system formed by multiple physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, Network service, cloud communication, middleware service, domain name service, security service, CDN (Content Delivery Network), big data, and an artificial intelligence platform.
The local server 101 may be directly or indirectly connected to the server 102 through a wired or wireless communication manner, which is not limited in the embodiment of the present disclosure.
Those skilled in the art will appreciate that the number of physical devices corresponding to the local server 101 may be greater or smaller. The number and the device type of the physical devices corresponding to the local server 101 are not limited in the embodiment of the present disclosure.
Fig. 2 is a flowchart illustrating a code synchronization method according to an exemplary embodiment, and referring to fig. 2, the code synchronization method is applied to a computer device, and the computer device is taken as a local server for example.
In step 201, in response to a start event of code synchronization, determining a target module in a selected module set; wherein, the target module is a module to be developed.
When a project needs module development, the code synchronization of the application software is triggered by a starting event aiming at the application software of the auxiliary development computer program, and the module development can be carried out after the code synchronization is finished.
For a project, a selected module set is corresponded, and the selected module set includes all modules that may be used by the project, because there is a dependency relationship between the modules, the dependency relationship is complex and not easy to mark, that is, it is not easy to determine modules that are not used at all through the dependency relationship, and only to determine modules to be developed, that is, modules that need to be developed.
In step 202, replacing the source code paths of other modules in the selected module set except the target module with the dependent objects corresponding to the other modules; and the dependent object is used for acquiring the compiled files corresponding to other modules.
In this step, the operation performed on the other modules except the target module is to replace the source code paths of the other modules except the target module in the selected module set with the dependent objects corresponding to the other modules, that is, replace the contents in the SourceSet of the other modules with the dependent objects, where the dependent objects may be path information.
Step 203, providing model information of the target module; wherein the model information is used to complete code synchronization of the target module.
In the embodiment, the source code paths of other modules except the target module in the selected module set are replaced by the dependent objects corresponding to the other modules, so that the topological structure of each module in the selected module set is reserved, compiled files can be obtained through the dependent objects in the subsequent development process, and the related functions of the other modules on which the module to be developed depends can be used in the subsequent development process; model information is only provided for the target module in the selected module set and is used for understanding the related code of the target module so as to complete the code synchronization of the target module, thereby greatly saving the analysis time of the model information in the synchronization process, namely saving the code synchronization time; therefore, the scheme solves the problem that the code synchronization process is accelerated, but the related functions of other modules depended on by the module to be developed cannot be used in the subsequent development process.
In some examples, determining the target module in the selected module set in response to the start event of the code synchronization in step 201 includes:
responding to a starting event, and acquiring a module identifier set for the selected module set;
and determining the corresponding module of the module identification in the selected module set as the target module.
By identifying the target module, the target module in the selected module set and other modules except the target module can be quickly determined. The implementation mode does not need to consider the code dependency relationship and is easy to operate.
In some examples, providing model information for the target module in step 203 includes:
returning model information of the target module in response to a synchronization request generated for the target module in the code synchronization process;
replacing the source code paths of other modules in the selected module set except the target module with the dependent objects corresponding to the other modules, including: in response to a synchronization request generated for other modules in the code synchronization process, replacing source code paths of the other modules with dependent objects corresponding to the other modules;
in response to a synchronization request generated for other modules in the process of code synchronization, the code synchronization method further includes: and returning a null response, wherein the null response is used for enabling the model information analysis process of other modules in the code synchronization process to be skipped.
In the example, the direct response model of the target module is given, and the model information is analyzed and synchronized; and for other modules, the source code path is replaced by a compiled file, so that not only is the dependency relationship between the modules reserved, but also the related functions of other modules on which the modules to be developed depend can be used in the subsequent development process, and when responding to model information, the model information analysis process of other modules in the code synchronization process is skipped by using null response, so that the code synchronization time is greatly saved.
In some examples, replacing the source code paths of the other modules in the selected module set except the target module with the dependent objects corresponding to the other modules in step 202 includes:
determining storage areas of source code paths of other modules;
emptying the storage area;
and adding the dependency objects corresponding to other modules to the emptied storage area through the transferable dependencies.
The source code path of the source code path storage area cannot be directly replaced, and the shell operation is needed, and then the transferable dependent API is used for adding the dependent object, so that the content of the storage area is replaced.
All the above optional technical solutions may be combined arbitrarily to form the optional embodiments of the present disclosure, and are not described herein again.
Fig. 3 is a flowchart illustrating a code synchronization method based on empty shell and empty response according to an exemplary embodiment, and referring to fig. 3, the code synchronization method is applied to a computer device, and the computer device is taken as a local server for example.
In step 301, in response to a start event of code synchronization, determining a target module in a selected module set; wherein, the target module is a module to be developed.
When a project needs module development, the code synchronization of the application software is triggered by a starting event aiming at the application software of the auxiliary development computer program, and the module development can be carried out after the code synchronization is finished.
For a project, a selected module set is corresponded, and the selected module set includes all modules that may be used by the project, because there is a dependency relationship between the modules, the dependency relationship is complex and not easy to mark, that is, it is not easy to determine modules that are not used at all through the dependency relationship, and only to determine modules to be developed, that is, modules that need to be developed.
In step 302, in response to the determination of the target module being completed, the dependent object corresponding to each of the other modules is obtained.
Wherein the compiled file for each other module is obtained by the dependent object.
After the target module is determined, the dependent object corresponding to each other module is obtained, where the dependent object may be path information of a compiled file, and the compiled file may be an AAR.
The dependent object may be obtained from a local server or a remote server.
The compiled file corresponding to the dependent object may be obtained from a local server or may be obtained from a remote server, which is not limited in this embodiment of the present application.
Step 302 gives the opportunity to acquire the dependent objects of the other modules.
In step 303, returning model information of the target module in response to a synchronization request generated for the target module during the code synchronization; wherein the model information is used to complete code synchronization of the target module. The flow is ended.
In step 303, the returning of the model information for all target modules is achieved by returning the model information for each target module in response to a synchronization request generated for the target module during the code synchronization.
In step 304, in response to the synchronization request generated for the other module in the code synchronization process, replacing the source code path of the other module with the dependent object corresponding to the other module, and returning a null response, where the null response is used to cause the model information parsing process of the other module in the code synchronization process to be skipped.
In step 304, source code path replacement for all other modules and empty response return are implemented by performing source code path replacement for each other module in response to synchronization requests generated for the other modules in the process of code synchronization and returning empty responses.
In some examples, during the code synchronization, a synchronization request is generated for each target module and other modules respectively, and in this embodiment, different responses are made to the synchronization requests of the target module and other modules, as implemented in step 303 and step 304.
In some examples, the synchronization request generated for different modules may be requested and responded to in a single-thread manner or a multi-thread manner, which is not limited in the embodiments of the present application.
In the embodiment, when a code synchronization event is started, dependent objects of a target module and other modules are obtained; and in response to a synchronization request generated for other modules in the code synchronization process, replacing the source code paths of the other modules with the dependent objects corresponding to the other modules, and returning a null response, wherein the null response is used for enabling the model information analysis process of the other modules in the code synchronization process to be skipped. Through the related processing on other modules, the single-point processing can be carried out on each module; the compiled file can be obtained through the dependent object in the subsequent development process, and then the related functions of other modules which are dependent on the module to be developed can be used in the subsequent development process; and all other modules skip the analysis of the model information through the null response, thereby greatly saving the analysis time of the model information in the code synchronization process, namely saving the code synchronization time; therefore, the scheme solves the problem that the code synchronization process is accelerated, but the related functions of other modules depended by the module to be developed cannot be used in the subsequent development process.
In some examples, determining the target module in the selected set of modules in response to the initiation event of the code synchronization in step 301 includes:
responding to a starting event, and acquiring a module identifier set for the selected module set;
and determining the corresponding module of the module identification in the selected module set as the target module.
By identifying the target module, the target module in the selected module set and other modules except the target module can be quickly determined. The implementation mode does not need to consider the code dependency relationship and is easy to operate.
In some examples, replacing the source code paths of other modules in the selected module set with dependent objects corresponding to other modules in step 304 includes:
determining storage areas of source code paths of other modules;
emptying the storage area;
and adding the dependency objects corresponding to other modules to the emptied storage area through the transferable dependencies.
Because the dependency relationship between the modules is a directed acyclic graph, the source code path cannot be directly replaced by the dependent object, that is, the dependent object cannot point to the source code module, in some examples of the present application, the storage area of the source code path is first subjected to an empty shell operation, and then the transferable dependent API is used to add the dependent object, so as to replace the content of the storage area.
All the above optional technical solutions may be combined arbitrarily to form the optional embodiments of the present disclosure, and are not described herein again.
A detailed description of a process of implementing code synchronization according to the present embodiment is given below in conjunction with a code synchronization architecture diagram according to the present embodiment. FIG. 4 is an architectural diagram illustrating one type of code synchronization, according to an exemplary embodiment. As shown in fig. 4, the schematic diagram includes a local server and a remote server. This embodiment comprises the steps of:
the first step, begin.
In some examples, when a project needs module development, for application software that assists in developing a computer program, code synchronization of the application software is triggered by a start event, and after the code synchronization is completed, module development can be performed.
The local server can be triggered by a certain button on the development interface, and by taking Intellij IDEA developed by IDE, android studio as an example, the local server can be realized by the button on the interface: the Sync Project with Gradle Files is started.
And secondly, the local server acquires the configuration information and determines a target module and other modules in the selected module set.
The target module is a module to be developed, and the other modules are modules except the target module, namely non-target modules.
The configuration information may include a selected module set and a target module in the selected module set.
For an item, a selected module set is corresponded, and the selected module set includes all modules that may be used by the item, because there is a dependency relationship between the modules, the dependency relationship is complex and is not easy to mark, that is, it is not easy to determine modules that are not used at all through the dependency relationship.
In specific implementation, the configuration may be performed in a configuration file manner, or the configuration information may be generated in a manner of clicking and selecting through a provided interface, and based on the selected module set, and the target module may determine which module is the target module and which module is another module than the target module.
During specific implementation, acquiring a module identifier set for a selected module set;
and determining the module corresponding to the module identifier in the selected module set as the target module.
And thirdly, the local server acquires the determined dependent object corresponding to each other module from the remote server.
The dependency object of another module is used to obtain the compiled file corresponding to the other module, so that the dependency object may be path information of the compiled file of the other module, where the compiled file may be an AAR.
Here, the dependent object may be obtained from a local server or a remote server, and this embodiment takes obtaining from a remote server as an example.
Fourthly, responding to a synchronization request generated for the target module in the code synchronization process, and returning the model information of the target module; wherein the model information is used to complete code synchronization of the target module. And executing the sixth step.
The return of model information for all target modules is accomplished by returning model information for each target module in response to a synchronization request generated for each target module during code synchronization.
And fifthly, in response to the synchronization request generated for other modules in the code synchronization process, replacing the source code paths of other modules with the dependent objects corresponding to other modules, and returning a null response, wherein the null response is used for enabling the model information analysis process of other modules in the code synchronization process to be skipped.
And performing source code path replacement on each other module in response to a synchronization request generated for each other module in the code synchronization process, and returning a null response to realize the replacement of the source code paths of all other modules and the response of the model information with null content.
Sixthly, analyzing the model information based on the returned model information of the target module to complete the code synchronization of the target module; and skipping the analysis of the model information of other modules based on the null responses of the other modules, and completing the code synchronization of the other modules.
In some examples, the acquisition of model information is triggered by a synchronization request based on interactions of an IDE process and an automated build open source tool (Gradle) process.
Taking the Tooling Api in the IDE as a programming API provided by the Gradle, allows the developer to execute and monitor the build, and query the Gradle for detailed information of the build, such as the interaction of the Android Studio with the Gradle when synchronizing. When an Android development environment (Android Studio) synchronizes one source code module, a Gradle process is inquired through cross-process communication to acquire Model information so as to perform subsequent source code understanding. Fig. 5 is a schematic diagram illustrating a process of obtaining model information in code synchronization according to an exemplary embodiment.
Step 501, the Android Studio sends a synchronization request (sync) to the Gradle through a open source tool interface (Gradle Tooling Api).
Step 502, Gradle returns model information (getModel).
If the Gradle determines that the module designated by the received synchronization request is the target module, acquiring synchronization information, and returning the model information of the corresponding target module to the Android Studio; and if the module designated by the received synchronization request is determined to be other modules, replacing the source code path of the module with the acquired dependent object of the other modules, and returning empty model information.
Because the dependency between modules is a Directed Acyclic Graph (DAG), the dependent object cannot point directly to other modules, and thus the dependent object cannot be used to directly replace the source code path, in one example, this replacement is implemented using a shell.
Determining storage areas of source code paths of other modules;
emptying the storage area;
and adding the dependency objects corresponding to other modules to the emptied storage area through the transferable dependencies.
The storing area condition here specifically refers to that sourceSet of other modules is emptied, and dependent objects of other modules are added to the emptied sourceSet through a transferable dependency (API).
FIG. 6 is an initial module dependency diagram shown in accordance with an exemplary embodiment. In FIG. 6, module C is the target module, and modules A, B, and D are the other modules; as indicated by the arrows in fig. 6, it can be seen that module a depends on module B and module C, and that both module C and module B depend on module D.
In the related art, the module a, the module B and the module D are not directly loaded, and such implementation may result in that a topological graph of the dependency relationship among the modules is not reserved, and the topological graph has a great influence on compilation, so that the topological graph should be reserved.
In some examples, to speed up the IDE code synchronization process, and to preserve the topology map corresponding to the dependencies between modules, the implementation of source code path replacement described above is employed.
FIG. 7 is a diagram illustrating module dependencies in code synchronization, according to an example embodiment. When the method is realized, the source code path of the module to be developed (module C) is not replaced; the source code path is replaced for the other modules (module a, module B and module D).
In specific implementation, taking implementation for the module a as an example:
the sourceSet containing the source code (. java,. kt) in the module A is emptied, and the transfer object corresponding to the module A is added to the emptied sourceSet through the transferable dependency (API).
Based on the implementation, the dependency relationship among the modules (the topological structure among the modules) can be reserved without knowing the dependency relationship among the modules in advance.
Too many source codes (. java,. kt) in a module result in IDE cards and slowness; when the corresponding other modules are used, the compiled file is used for replacing the source code, so that the related functions of the other modules can be used, the work required by the IDE for understanding the source code can be greatly reduced, and the effect of accelerating the synchronization of the IDE code is further achieved.
Step 503, the Android Studio parses model information (resolve model).
Analyzing the model information of the target module by adopting an analysis mode in the related technology;
the model information of the other module is empty, so that the analysis of the model information of the other module is skipped, and the subsequent other work is not performed.
Therefore, as in the dependency relationship in fig. 6, the IDE only needs to parse the model of the target module C to understand the code in the target module C, and skips parsing for the model codes in the other modules A, B and D, and then does not understand the code.
And step seven, finishing.
When the code synchronization of all other modules and the target module is completed, the code synchronization of the IDE is completed.
When the related functions of other modules need to be used, the compiled file corresponding to the other modules is obtained through the dependent object, and the compiled file meets the following conditions:
the POM (project object model) of the compiled file does not carry the dependency relationship between modules;
the compiled file includes the project source code (. java,. kt), and the source code generated during the compilation period (apt, buildConfig, etc.).
The compiled file may be an AAR, which may be published on a Maven at a remote server. If the AAR is published on the Maven, the AAR version number based on the rule needs to be generated for the correlation between the publisher and the user, for example, the git signature information git rev-parse HEAD: path of the module can be used as the version number.
The remote server may generate and publish the AAR to the Maven upon sensing a code change, such as MR joining trunk branch, etc.
When the present disclosure is specifically implemented, the AAR may be used without being limited to the above-described AAR production method as long as the AAR is produced in advance; in the process of accelerating IDE code synchronization, only the path information of the compiled file is acquired as a dependent object, and when the related functions of other modules are required to be used, the compiled file is acquired through the dependent object to be used for the related functions.
In the embodiment, when a code synchronization event is started, a target module and dependent objects of other modules are obtained; and in response to a synchronization request generated for other modules in the code synchronization process, replacing the source code paths of the other modules with the dependent objects corresponding to the other modules, and returning a null response, wherein the null response is used for enabling the model information analysis process of the other modules in the code synchronization process to be skipped. As described above, the single-point configuration can be performed on each module without considering the dependency relationship between the modules; the compiled file can be obtained through the dependent object in the subsequent development process, and then the related functions of other modules which are depended by the module to be developed can be used in the subsequent development process, such as searching, skipping (skipping is the source code of the compiled file but not the module) and the like; and all other modules skip the analysis of the model information through the null response, thereby greatly saving the analysis time of the model information in the code synchronization process, namely saving the code synchronization time and accelerating the code synchronization process of the IDE. Therefore, the scheme solves the problem that the code synchronization process is accelerated, but the related functions of other modules depended on by the module to be developed cannot be used in the subsequent development process.
Fig. 8 is a block diagram illustrating a logical structure of a code synchronization apparatus according to an exemplary embodiment, and referring to fig. 8, the code synchronization apparatus includes:
a determination module 801 configured to perform a start event in response to code synchronization, determining a target module in the selected set of modules; wherein, the target module is a module to be developed;
a replacing module 802 configured to replace the source code paths of the other modules in the selected module set except the target module with dependent objects corresponding to the other modules, where the dependent objects are used to obtain compiled files of the other modules;
a providing module 803 configured to execute providing model information of the target module, wherein the model information is used to complete code synchronization of the target module.
In one possible embodiment of the method according to the invention,
the replacing module 802 is specifically configured to perform replacing the source code path of the other module with the dependent object corresponding to the other module in response to the synchronization request generated for the other module in the code synchronization process.
In one possible embodiment of the method according to the invention,
a module 803 is provided, which is further configured to perform returning a null response in response to a synchronization request generated for other modules during the code synchronization, wherein the null response is used to cause the model information parsing process of other modules during the code synchronization to be skipped.
In one possible embodiment of the method according to the invention,
a determining module 801, specifically configured to execute, in response to a start event, acquiring a module identifier set for the selected module set; and determining the corresponding module of the module identification in the selected module set as the target module.
In one possible embodiment mode of the present invention,
a replacement module 802 further configured to perform, in response to completion of the determination of the target module, obtaining a dependent object corresponding to each of the other modules; wherein the compiled file of each other module is obtained by the dependent object.
In one possible embodiment of the method according to the invention,
a replacement module 802 specifically configured to perform determining a deposit area for source code paths of other modules; emptying the storage area; and adding the dependency objects corresponding to other modules to the emptied storage area through the transferable dependencies.
In one possible embodiment of the method according to the invention,
a providing module 803, specifically configured to perform returning the model information of the target module in response to a synchronization request generated for the target module in the process of code synchronization.
In one possible embodiment of the method according to the invention,
the compiled file is a binary archive file.
In the embodiment, when a code synchronization event is started, dependent objects of a target module and other modules are obtained; and in response to a synchronization request generated for other modules in the code synchronization process, replacing the source code paths of the other modules with the dependent objects corresponding to the other modules, and returning a null response, wherein the null response is used for enabling the model information analysis process of the other modules in the code synchronization process to be skipped. Through the relevant processing of other modules, the single-point processing can be carried out on each module; the compiled file can be obtained through the dependent object in the subsequent development process, and further, the related functions of other modules which are dependent on the module to be developed can be used in the subsequent development process; and all other modules skip the analysis of the model information through the null response, thereby greatly saving the analysis time of the model information in the code synchronization process, namely saving the code synchronization time; therefore, the scheme solves the problem that the code synchronization process is accelerated, but the related functions of other modules depended on by the module to be developed cannot be used in the subsequent development process.
All the above optional technical solutions may be combined arbitrarily to form optional embodiments of the present disclosure, and are not described in detail herein.
With regard to the code synchronization apparatus in the above embodiments, the specific manner in which each module performs the operation has been described in detail in the embodiments related to the code synchronization method, and will not be described in detail here.
It should be noted that: the foregoing embodiments are merely illustrated by the division of the functional modules, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above.
Fig. 9 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. In some embodiments, the electronic device is a local server. The electronic device 900 may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 901 and one or more memories 902, where the memory 902 stores at least one program code, and the at least one program code is loaded and executed by the processors 901 to implement the code synchronization method provided by the above embodiments. Certainly, the electronic device 900 may further have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input and output, and the electronic device 900 may further include other components for implementing device functions, which are not described herein again.
In an exemplary embodiment, a computer-readable storage medium comprising at least one instruction, such as a memory comprising at least one instruction, executable by a processor in a computer device to perform the code synchronization method in the above embodiments is also provided.
Alternatively, the computer-readable storage medium may be a non-transitory computer-readable storage medium, and the non-transitory computer-readable storage medium may include a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like, for example.
In an exemplary embodiment, a computer program product is also provided that includes one or more instructions executable by a processor of a computer device to perform the code synchronization method provided by the various embodiments described above.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (11)

1. A code synchronization method, characterized in that the code synchronization method comprises:
in response to a start event of the code synchronization, determining a target module in the selected module set; wherein the target module is a module to be developed;
replacing source code paths of other modules in the selected module set except the target module with dependent objects corresponding to the other modules, wherein the dependent objects are used for acquiring compiled files of the other modules;
providing model information of the target module, wherein the model information is used for completing code synchronization of the target module.
2. The code synchronization method according to claim 1, wherein replacing the source code paths of the other modules in the selected module set except the target module with the dependent objects corresponding to the other modules comprises:
and in response to a synchronization request generated for the other modules in the code synchronization process, replacing the source code paths of the other modules with the dependent objects corresponding to the other modules.
3. The code synchronization method according to claim 2, wherein the code synchronization method further comprises, in response to a synchronization request generated for the other module during the code synchronization:
and returning a null response, wherein the null response is used for enabling the model information analysis process of the other modules in the code synchronization process to be skipped.
4. The code synchronization method of claim 1, wherein determining a target module in the selected set of modules in response to a start event of code synchronization comprises:
responding to the starting event, and acquiring a module identifier set for the selected module set;
determining a module corresponding to the module identification in the selected module set as the target module.
5. The code synchronization method according to claim 1, wherein the code synchronization method further comprises:
in response to completion of the determination of the target module, obtaining the dependent object corresponding to each of the other modules;
wherein the compiled file for each of the other modules is obtained via the dependent object.
6. The method for code synchronization according to claim 1, wherein the replacing the source code paths of the other modules in the selected module set except the target module with the dependent objects corresponding to the other modules comprises:
determining a storage area of a source code path of the other module;
emptying the storage area;
and adding the dependency objects corresponding to the other modules to the emptied storage area through transferable dependencies.
7. The code synchronization method according to any one of claims 1 to 6, wherein the providing the model information of the target module comprises:
returning the model information of the target module in response to a synchronization request generated for the target module during the code synchronization.
8. A code synchronization apparatus, characterized in that the code synchronization apparatus comprises:
a determination module configured to perform a start event in response to code synchronization, determining a target module of the selected set of modules; wherein the target module is a module to be developed;
a replacing module configured to replace source code paths of other modules in the selected module set except the target module with dependent objects corresponding to the other modules, wherein the dependent objects are used for acquiring compiled files of the other modules;
a providing module configured to perform providing model information of the target module, wherein the model information is used to complete code synchronization of the target module.
9. An electronic device, comprising:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the executable instructions to implement the code synchronization method of any of claims 1 to 7.
10. A computer-readable storage medium, wherein at least one instruction of the computer-readable storage medium, when executed by a processor of an electronic device, enables the electronic device to implement the code synchronization method of any of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that the computer program realizes the code synchronization method according to any of claims 1 to 7 when executed by a processor.
CN202210850796.4A 2022-07-20 2022-07-20 Code synchronization method and device Active CN114924788B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210850796.4A CN114924788B (en) 2022-07-20 2022-07-20 Code synchronization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210850796.4A CN114924788B (en) 2022-07-20 2022-07-20 Code synchronization method and device

Publications (2)

Publication Number Publication Date
CN114924788A true CN114924788A (en) 2022-08-19
CN114924788B CN114924788B (en) 2022-12-27

Family

ID=82815730

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210850796.4A Active CN114924788B (en) 2022-07-20 2022-07-20 Code synchronization method and device

Country Status (1)

Country Link
CN (1) CN114924788B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160188439A1 (en) * 2014-12-30 2016-06-30 International Business Machines Corporation Managing assertions while compiling and debugging source code
CN111796831A (en) * 2020-06-24 2020-10-20 苏州大学 Compiling method and device for multi-chip compatibility
CN112965720A (en) * 2021-02-19 2021-06-15 上海微盟企业发展有限公司 Component compiling method, device, equipment and computer readable storage medium
CN113132805A (en) * 2019-12-31 2021-07-16 Tcl集团股份有限公司 Playing control method, system, intelligent terminal and storage medium
CN114153480A (en) * 2021-12-06 2022-03-08 北京金堤科技有限公司 Code synchronization method, component publishing method, device thereof and computer storage medium
CN114461217A (en) * 2021-12-23 2022-05-10 北京达佳互联信息技术有限公司 Code compiling method and device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160188439A1 (en) * 2014-12-30 2016-06-30 International Business Machines Corporation Managing assertions while compiling and debugging source code
CN113132805A (en) * 2019-12-31 2021-07-16 Tcl集团股份有限公司 Playing control method, system, intelligent terminal and storage medium
CN111796831A (en) * 2020-06-24 2020-10-20 苏州大学 Compiling method and device for multi-chip compatibility
CN112965720A (en) * 2021-02-19 2021-06-15 上海微盟企业发展有限公司 Component compiling method, device, equipment and computer readable storage medium
CN114153480A (en) * 2021-12-06 2022-03-08 北京金堤科技有限公司 Code synchronization method, component publishing method, device thereof and computer storage medium
CN114461217A (en) * 2021-12-23 2022-05-10 北京达佳互联信息技术有限公司 Code compiling method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
乔容等: "嵌入式软件源码级交叉调试器的设计与实现", 《舰船电子工程》 *

Also Published As

Publication number Publication date
CN114924788B (en) 2022-12-27

Similar Documents

Publication Publication Date Title
CN108229686B (en) Model training and predicting method and device, electronic equipment and machine learning platform
US20220046076A1 (en) Method And System For Real-Time Modeling Of Communication, Virtualization And Transaction Execution Related Topological Aspects Of Monitored Software Applications And Hardware Entities
US10740093B2 (en) Advanced packaging techniques for improving work flows
CN106708740B (en) Script testing method and device
CN111324571B (en) Container cluster management method, device and system
US8327341B2 (en) Integrating aspect oriented programming into the application server
CN110244942B (en) Page generation method, device and system
US10120658B2 (en) Method and system for realizing software development tasks
CN109491916A (en) A kind of test method of operating system, device, equipment, system and medium
US8640146B2 (en) Providing extensive ability for describing a management interface
CN109783533A (en) Collecting method, device, computer equipment and storage medium
CN111737139A (en) Method and device for generating preview two-dimensional code of applet
CN113661480A (en) Techniques for determining cloud computing deployment modifications for serverless applications
JP2017091531A (en) Exporting hierarchical data from source code management (scm) system to product lifecycle management (plm) system
CN114780138B (en) Flow field simulation software code version management method and device and storage medium
Gonçalves et al. Monolith modularization towards microservices: Refactoring and performance trade-offs
CN117693734A (en) Front-end item processing method, device, equipment, management system and storage medium
CN114528186A (en) Model management method and device and model management server
CN114924788B (en) Code synchronization method and device
US11307839B2 (en) Updating of container-based applications
CN112579077B (en) Page processing method and device in application, application service platform and equipment
US10958514B2 (en) Generating application-server provisioning configurations
JP2017091532A (en) Exporting hierarchical data from product lifecycle management (plm) system to source code management (scm) system
CN115469844A (en) Code processing method, system, computer cluster, medium, and program product
CN111752555B (en) Business scene driven visual insight support system, client and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant