CN108304175B - Code file isolation packaging method and device - Google Patents

Code file isolation packaging method and device Download PDF

Info

Publication number
CN108304175B
CN108304175B CN201810083363.4A CN201810083363A CN108304175B CN 108304175 B CN108304175 B CN 108304175B CN 201810083363 A CN201810083363 A CN 201810083363A CN 108304175 B CN108304175 B CN 108304175B
Authority
CN
China
Prior art keywords
file
isolation
code
programming language
processing
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.)
Active
Application number
CN201810083363.4A
Other languages
Chinese (zh)
Other versions
CN108304175A (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.)
Koubei Shanghai Information Technology Co Ltd
Original Assignee
Koubei Shanghai 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 Koubei Shanghai Information Technology Co Ltd filed Critical Koubei Shanghai Information Technology Co Ltd
Priority to CN201810083363.4A priority Critical patent/CN108304175B/en
Publication of CN108304175A publication Critical patent/CN108304175A/en
Application granted granted Critical
Publication of CN108304175B publication Critical patent/CN108304175B/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/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

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

Abstract

The invention discloses a code file isolation packaging method and a device, wherein the method comprises the following steps: pre-labeling code files related to different branches in one project file; acquiring parameters transmitted in different branch packing processes; according to the parameters, carrying out isolation processing on the code file to obtain the code file after the isolation processing; and packaging the code files subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters. The invention uses the same project file, and carries out pre-labeling processing on the code file contained in the project file, so that one project file contains different branches. And according to the parameters transmitted by the packaging, correspondingly packaging into a package file corresponding to the parameters. The invention not only solves the problem of merging and maintaining different branch codes, but also solves the problems of incomplete isolation of processing logic in each packet of files after packaging, overlarge packet files and the like.

Description

Code file isolation packaging method and device
Technical Field
The invention relates to the field of software, in particular to a code file isolation packaging method and device.
Background
When different applications all require the same function, for example, a certain page of the public praise App shown in fig. 1a and a certain page of the pay pal App shown in fig. 1b include partially the same function, such as quick-robbing with big card, preferential attachment, and the like. The inclusion of the same functionality in different applications is generally achieved in the prior art by:
the method adopts a plurality of branches for management, namely, codes of two or more different engineering files are maintained, and the realization of functions is completed in the codes of each engineering file according to specific application requirements, so that the codes of the two or more engineering files contain the same code, the codes of the multiple engineering files need to be maintained during maintenance, and the workload is large. Meanwhile, after the code of one project file is modified, the modified content needs to be manually merged with the code of another project file or multiple project files. With the updating of the code implementation function, the updating of the version, and the like, it is necessary to spend more time, labor, and other costs for merging, and it is also necessary to solve the problems of code conflict, large business regression amount, and the like, which may be caused during merging.
Or, the whole codes of the same project file are adopted, judgment is carried out according to different application apps during running, and codes which do not accord with the applications are isolated. For example, the public praise app and the pay baby app both use the same code of one project file, and the code of one project file contains both the code and the resource for realizing the same function of the public praise app and the pay baby app and also contains a differentiated code for realizing different functions of the public praise app and the pay baby app. Where the differentiated codes are distinguished by, for example, if determination. However, this method requires packaging the entire amount of codes and resources, which may cause the problems of too large size of packaged files, incomplete logic isolation in codes, redundant logic inclusion, and the like. Meanwhile, different applications are distinguished through branch judgment when the applications are operated, so that the performance of application operation is slowed down, and adverse effects are caused to the application operation.
Disclosure of Invention
In view of the above, the present invention is proposed to provide a code file isolation packaging method and apparatus that overcomes or at least partially solves the above problems.
According to one aspect of the present invention, there is provided a code file isolation packaging method, including:
pre-labeling code files related to different branches in one project file;
acquiring parameters transmitted in different branch packing processes;
according to the parameters, carrying out isolation processing on the code file to obtain the code file after the isolation processing;
and packaging the code files subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters.
Optionally, the code files include programming language files, extensible markup language files, and/or resource files;
the pre-labeling processing of the code files related to different branches further comprises the following steps:
performing pre-labeling processing on classes, methods, attribute parameters and/or internal classes related to different branches in a programming language file by using labels; wherein the tag is a note or annotation;
performing pre-labeling processing on logic processing codes related to different branches in a programming language file by using judgment branch statements;
and/or the presence of a gas in the gas,
pre-labeling the content related to different branches in the extensible markup language file by using annotations;
and/or the presence of a gas in the gas,
storing the resource files related to different branches in the resource files according to different directories;
and recording the path information of the resource files under different directories corresponding to different branches by using the configuration file.
Optionally, the isolating the code file according to the parameter, and obtaining the isolated code file further includes:
determining a corresponding isolation branch matching rule according to the parameters;
and according to the isolation branch matching rule, carrying out isolation processing on the code file to obtain the code file after the isolation processing.
Optionally, according to the isolation branch matching rule, performing isolation processing on the code file, and obtaining the code file after the isolation processing further includes:
acquiring resource file path information which conforms to the isolation branch matching rule in the configuration file;
setting a resource file path called by the package file according to the resource file path information;
and/or the presence of a gas in the gas,
acquiring an extensible markup language file;
matching the comments in the extensible markup language file with the isolation branch matching rule, replacing the contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating an extensible markup language file after isolation processing;
and/or
Acquiring a programming language file;
and matching the tags in the programming language file with the isolation branch matching rules, replacing the content corresponding to the tags which do not accord with the isolation branch matching rules with blank content, and generating the programming language file after isolation processing.
Optionally, matching the tag in the programming language file with the isolation branch matching rule, replacing the content corresponding to the tag that does not meet the isolation branch matching rule with blank content, and generating the isolated programming language file further includes:
parsing a syntax tree of the programming language file to obtain class information, method information, attribute parameter information and/or internal class information;
if the class information contains a label, and the label does not accord with the isolation branch matching rule, filtering out the programming language file;
if the method information contains a label, and the label does not accord with the isolation branch matching rule, replacing the method body code content corresponding to the method information with blank content;
if the attribute parameter information contains a label, and the label does not accord with the isolation branch matching rule, replacing the attribute parameter code content corresponding to the attribute parameter information with blank content;
if the internal class information contains the label and the label does not accord with the isolation branch matching rule, replacing the internal class code content corresponding to the internal class information with blank content;
matching the judgment branch statement with the isolation branch matching rule, and replacing code contents contained in the judgment branch statement which does not accord with the isolation branch matching rule with blank contents;
repeatedly executing the steps until the matching of all code contents of the programming language file and the isolation branch matching rule is completed;
removing unused reference relation in programming language file, and generating programming language file after isolation processing
Optionally, the step of packaging the code file after the isolation processing to obtain a package file of the engineering file corresponding to the parameter further includes:
compiling the programming language file after the isolation processing to obtain a corresponding compiled file;
deleting the programming language file after the isolation processing;
and packaging the resource files under the resource file path called by the compiled file, the isolated extensible markup language file and/or the package file to obtain a package file of the engineering file corresponding to the parameters.
According to another aspect of the present invention, there is provided a code file isolation packaging apparatus, including:
the pre-labeling module is suitable for pre-labeling the code files related to different branches in one project file;
the acquisition module is suitable for acquiring parameters transmitted in different branch packing processes;
the isolation module is suitable for carrying out isolation processing on the code file according to the parameters to obtain the code file after the isolation processing;
and the packaging module is suitable for packaging the code file subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters.
Optionally, the code files include programming language files, extensible markup language files, and/or resource files;
the pre-labeling module further comprises:
the first pre-labeling unit is suitable for performing pre-labeling processing on classes, methods, attribute parameters and/or internal classes related to different branches in the programming language file by using labels; wherein the tag is a note or annotation; performing pre-labeling processing on logic processing codes related to different branches in a programming language file by using judgment branch statements;
and/or the presence of a gas in the gas,
the second pre-labeling unit is suitable for performing pre-labeling processing on the content related to different branches in the extensible markup language file by using annotations;
and/or the presence of a gas in the gas,
the third pre-labeling unit is suitable for storing the resource files related to different branches in the resource files according to different directories; and recording the path information of the resource files under different directories corresponding to different branches by using the configuration file.
Optionally, the isolation module is further adapted to:
determining a corresponding isolation branch matching rule according to the parameters; and according to the isolation branch matching rule, carrying out isolation processing on the code file to obtain the code file after the isolation processing.
Optionally, the isolation module further comprises:
the first isolation unit is suitable for acquiring the resource file path information in the configuration file, which conforms to the isolation branch matching rule; setting a resource file path called by the package file according to the resource file path information;
and/or the presence of a gas in the gas,
the second isolation unit is suitable for acquiring the extensible markup language file; matching the comments in the extensible markup language file with the isolation branch matching rule, replacing the contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating an extensible markup language file after isolation processing;
and/or
The third isolation unit is suitable for acquiring a programming language file; and matching the tags in the programming language file with the isolation branch matching rules, replacing the content corresponding to the tags which do not accord with the isolation branch matching rules with blank content, and generating the programming language file after isolation processing.
Optionally, the third isolation unit is further adapted to:
parsing a syntax tree of the programming language file to obtain class information, method information, attribute parameter information and/or internal class information; if the class information contains a label, and the label does not accord with the isolation branch matching rule, filtering out the programming language file; if the method information contains a label, and the label does not accord with the isolation branch matching rule, replacing the method body code content corresponding to the method information with blank content; if the attribute parameter information contains a label, and the label does not accord with the isolation branch matching rule, replacing the attribute parameter code content corresponding to the attribute parameter information with blank content; if the internal class information contains the label and the label does not accord with the isolation branch matching rule, replacing the internal class code content corresponding to the internal class information with blank content; matching the judgment branch statement with the isolation branch matching rule, and replacing code contents contained in the judgment branch statement which does not accord with the isolation branch matching rule with blank contents; repeatedly executing the operation until the matching of all code contents of the programming language file and the isolation branch matching rule is completed; removing unused reference relation in programming language file, and generating programming language file after isolation processing
Optionally, the packaging module is further adapted to:
compiling the programming language file after the isolation processing to obtain a corresponding compiled file; deleting the programming language file after the isolation processing; and packaging the resource files under the resource file path called by the compiled file, the isolated extensible markup language file and/or the package file to obtain a package file of the engineering file corresponding to the parameters.
According to still another aspect of the present invention, there is provided an electronic apparatus including: the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the code file isolation packaging method.
According to still another aspect of the present invention, there is provided a computer storage medium having at least one executable instruction stored therein, where the executable instruction causes a processor to perform operations corresponding to the code file isolation packaging method.
According to the code file isolation packaging method and device provided by the invention, code files related to different branches in one project file are subjected to pre-labeling treatment; acquiring parameters transmitted in different branch packing processes; according to the parameters, carrying out isolation processing on the code file to obtain the code file after the isolation processing; and packaging the code files subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters. The invention uses the same project file, and carries out pre-labeling processing on the code file contained in the project file, so that one project file contains different branches. And correspondingly isolating the code file after the pre-labeling processing according to the actual parameters when different branches are packaged, and only packaging the code file after the isolation processing. Namely, according to the parameters transmitted by packaging, the parameters are correspondingly packaged into the package files corresponding to the parameters. The invention not only solves the problem of merging and maintaining different branch codes, but also solves the problems of incomplete isolation of processing logic in each packet of files after packaging, overlarge packet files and the like.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIGS. 1a and 1b show application schematics of the presentation of the same piece of code in different applications;
FIG. 2 illustrates a flow diagram of a method for isolated packaging of code files according to one embodiment of the invention;
FIG. 3 shows a flow diagram of a code file isolation packaging method according to another embodiment of the invention;
FIGS. 4a and 4b are schematic diagrams illustrating pre-labeling of a code file;
FIG. 5 is a schematic diagram illustrating isolation processing of a programming language file;
FIG. 6 shows a functional block diagram of a code file isolation packaging apparatus according to an embodiment of the present invention;
fig. 7 shows a schematic structural diagram of an electronic device according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
FIG. 2 shows a flowchart of a code file isolation packaging method according to an embodiment of the invention. As shown in fig. 2, the method for isolating and packaging the code file specifically includes the following steps:
step S201, code files related to different branches in one project file are pre-labeled.
The code files related to the functions required to be realized by different branches are all contained in one project file, that is, one project file can realize the requirements of different branches, and one project file contains all the code files of different branches. Code files including different branches in one project file need to be pre-labeled. The pre-labeling processing is mainly to label part of the content of the code file containing different branch processing logics so as to distinguish the processing logics of different branches.
Step S202, parameters transmitted in different branch packing are obtained.
And when packing, acquiring different parameters transmitted by different branches, wherein the different parameters are used for marking the different branches. The parameters are related to the pre-labeling process, and the parameters may be the same as or different from the labels used in the pre-labeling process, but when the parameters are different, the corresponding relationship between the parameters and the labels needs to be preset. Therefore, when packaging, corresponding isolation processing can be carried out according to the parameters.
And step S203, isolating the code file according to the parameters to obtain the code file after isolation.
When the code files are isolated, the position information of each code file in the project file needs to be acquired. And acquiring each code file according to the position information, and then carrying out isolation processing on the code files needing isolation processing according to the parameters. Specifically, the content related to the parameter in the code file is reserved, and the content not matched with the parameter is removed, so that the code file after the isolation processing is ensured to only contain the content related to the parameter, namely, only the content required by the branch corresponding to the parameter is obtained, and therefore, the contents such as code logic and the like irrelevant to the branch corresponding to the parameter are thoroughly isolated, and the content of the code file required to be contained in packaging is also reduced.
And step S204, packaging the code files subjected to the isolation processing to obtain package files of the engineering files corresponding to the parameters.
And packaging the code files subjected to the isolation processing, wherein the obtained package files only comprise the code files in the engineering files corresponding to the parameters, and the content of the code files not corresponding to the parameters is isolated, so that the size of the engineering files is greatly reduced, and the package files obtained by packaging can not cause the problems of overlarge files, excessive code logics, excessive judgment branches during execution, low execution speed and the like.
According to the code file isolation packaging method provided by the invention, code files related to different branches in one project file are pre-labeled; acquiring parameters transmitted in different branch packing processes; according to the parameters, carrying out isolation processing on the code file to obtain the code file after the isolation processing; and packaging the code files subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters. The invention uses the same project file, and carries out pre-labeling processing on the code file contained in the project file, so that one project file contains different branches. And correspondingly isolating the code file after the pre-labeling processing according to the actual parameters when different branches are packaged, and only packaging the code file after the isolation processing. Namely, according to the parameters transmitted by packaging, the parameters are correspondingly packaged into the package files corresponding to the parameters. The invention not only solves the problem of merging and maintaining different branch codes, but also solves the problems of incomplete isolation of processing logic in each packet of files after packaging, overlarge packet files and the like.
FIG. 3 shows a flowchart of a code file isolation packaging method according to another embodiment of the present invention. As shown in fig. 3, the method for isolating and packaging the code file specifically includes the following steps:
step S301, pre-labeling the code files related to different branches in one project file.
Code files include, for example, programming language files, extensible markup language files, resource files, and the like. The programming language is a programming language which does not include preprocessing before compiling, such as java language. However, the C/C + + language is preprocessed before being compiled, and thus, the C/C + + language is not suitable for the present invention. Programming language files such as java files, etc.; extensible markup language files such as xml files and the like; the resource files include resource files such as pictures, files and the like.
The pre-labeling processing of the code files related to different branches further comprises the following steps:
classes, methods, attribute parameters, internal classes, etc. in the programming language file that refer to different branches may be pre-labeled with labels. In particular, the tags may be notes or annotations, such as java files. As shown in fig. 4a, for an attribute parameter, a tag may be used for pre-labeling processing at the location where the attribute parameter is defined, such as an AliPayName, and the annotation @ O2OTarget may be used for pre-labeling above the private StringAliPayName where the code defines it, which belongs to Payment Bay (APP). Further, pre-annotation processing may also be performed at the position of the row where its definition is located using the annotation// attributes used only in the pay-Bao. For a method, a label may be used to perform a pre-labeling process at a location indicating an entirety of the method, such as an AliPaymethod, and the annotation @ O2OTarget may be used to perform a pre-labeling process on top of the private void AliPaymethod defined by the code, which belongs to the PayPal Branch. Further, the method may also be pre-annotated with annotations, which may be the same location as the annotation. For the whole class file, the whole position of one class file can be marked by using a label for pre-marking. As above public class Test, the Test class file is pre-annotated with the annotation @ O2OTarget or annotation (not shown). For the internal classes in the programming language file, labels can be used for pre-labeling at the whole position for marking one internal class, and the method pre-labeling processing can be referred to specifically. The above comments and pre-marked positions are all examples, and are set according to the implementation, and are not limited herein. Note and note may be used, and various types may be used, and the present invention is provided according to the implementation, and is only illustrative and not limited.
Except for carrying out the pre-labeling processing on the whole of classes, methods, attribute parameters, internal classes and the like related to different branches in the programming language file, the pre-labeling processing is carried out on logic processing codes related to different branches in the programming language file by using judgment branch statements. As shown in fig. 4a, in the method loginlock, logic processing of different branches is involved, and if is used to judge a branch statement, and the logic processing codes of different branches are pre-labeled, so that the subsequent isolation processing is facilitated. When the judgment condition in the if statement is O2OAdapterUtils. I.e. for the pay pal branch, the AliPayMethod method is called. Here, the oi2oadapterutits. alipay itself is a true conditional sentence, that is, its value is true, and the alipayMethod method is executed without making a judgment. Therefore, when the code is compiled, the compiling processing can remove the judgment condition of if (true), and can directly call the AliPayMethod method, thereby improving the processing speed. In addition to the if decision branch statement, a decision branch statement such as switch may be applied to the present embodiment, and is not limited herein.
And performing pre-labeling processing on the content related to different branches in the extensible markup language file by using the annotations. When performing the pre-labeling process, it should be noted that, for the contents of different branches in the xml file, comments need to be added at the beginning and the end of the contents to facilitate the subsequent isolation process. As in an xml file, the annotations <!are added before the beginning of a piece of content! -Alipay- - >, adding a comment <!after the end of the piece of content! -Alipay- >, facilitating <! -Alipay- >, it can be known which specific branch the content of the segment corresponds to in the xml file.
The resource files related to different branches in the resource files are stored according to different directories, as shown in fig. 4b, under the adapter directory, the resource files are divided into two different branches, i.e., alicay and kouberi, and the resource files required to be used by the branches are stored according to the respective directories. The resource file path information under different directories corresponding to different branches can be recorded by using the configuration file used in packaging. As indicated by the code in the configuration file below:
Figure BDA0001561669780000101
Figure BDA0001561669780000111
when packaging, according to different directories pointed by different branch names recorded in the configuration file, the path information of the resource file corresponding to each branch can be obtained, and then the corresponding resource file is obtained.
Step S302, parameters transmitted in different branch packing are obtained.
When packing, different branches know the specific branch to be packed through parameters. The parameters of the reference transmitted during the packing are acquired and correspond to different branches, and the number of the branches is not limited and can be two or more. If the parameter can be public praise and pay treasure; or the parameters are a test environment, an operating environment, a development environment, etc. The values of the parameters are related to the labels, the names corresponding to different branches in the configuration file, and the like, and the specific types and values of the parameters are set according to implementation conditions.
Step S303, determining a corresponding isolation branch matching rule according to the parameters.
And step S304, according to the isolation branch matching rule, isolating the code file to obtain the code file after isolation processing.
And determining corresponding isolation branch matching rules used for isolation for different code files according to the parameters.
For a resource file, the isolated branch matching rule is determined to be consistent with the AliPayRes according to a parameter such as AliPay. And further acquiring resource file path information which is in accordance with the isolation branch matching rule in the configuration file, namely acquiring resource file path information adapter/Alipay corresponding to AlipayRes. And setting a resource file path called by the package file according to the resource file path information, namely setting the resource file path to be called by the package file as adapter/Alipay.
For the extensible markup language file, according to parameters such as Alipay, the isolation branch matching rule is determined to be that Alipay is contained in the annotation. The method comprises the steps of firstly obtaining an extensible markup language file, matching comments in the extensible markup language file with an isolation branch matching rule, replacing contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating the extensible markup language file after isolation processing. For example, the annotation format is <! XXX- - >, matching the content of the retrieved XML file line by line, when no comments are included, or when comments <! When the value is-alipay-, the value is consistent with the matching rule of the isolation branch, and no processing is performed. When the annotation is not <! -Alipay >. And replacing the whole content with blank content according to the recorded content starting position and content ending position, and replacing the content of the line where the annotation is positioned with the blank content. In this embodiment, the content may also be deleted, but it is preferable to keep the row number of the content, and replace the specific content with blank content, so that when problems such as bug occur in the following, the corresponding row number may be found from the log file, and the corresponding row number of the xml file is modified. It should be noted that the generated isolated xml file is not directly modified from the obtained xml file, but is regenerated from the obtained xml file and stored in a location specified by the package.
For a programming language file, according to parameters such as Alipay, the isolation branch matching rule is determined to be that Alipay is contained in the label. The method comprises the steps of firstly obtaining a programming language file, matching tags in the programming language file with an isolation branch matching rule, replacing contents corresponding to the tags which do not accord with the isolation branch matching rule with blank contents, and generating the programming language file after isolation processing. Specifically, the syntax tree analysis is performed on the programming language file to obtain class information, method information, attribute parameter information, internal class information, and the like. And for class information, if the class information contains a label, and the label does not accord with the isolation branch matching rule, filtering out the programming language file. That is, the annotation or tag used by the class file does not contain Alipay, for example, the annotation is @ O2OTarget (APP. KOUBEI), the class file is directly filtered, that is, the class file is directly isolated, and the class file is not used as a code file required by the packaging. The annotation or the tag used by the class file contains Alipay, for example, the annotation is @ O2OTarget (APP. APLIPAY), the class file is a code file required by the packaging, the class file is directly obtained, and the isolation processing is not required to be performed on the class file. If the class information does not include a label, further matching of method information, attribute parameter information, internal class information, and the like included in the class file is necessary.
And for the method information, if the method information contains a label and the label does not accord with the isolation branch matching rule, replacing the method body code content corresponding to the method information with blank content. That is, the annotation or tag used by the method does not contain Alipay, for example, the annotation is @ O2OTarget (APP. KOUBEI), the start position and the end position of the method are recorded first, and the content of the whole method body code is completely replaced by blank content according to the start position and the end position of the recording. The annotation or tag used in the method contains Alipay, such as the annotation @ O2OTarget (APP. APLIPAY), and the method is not isolated. If the method information does not include the tag, attribute parameter information, a judgment branch, and the like in the method information need to be further matched.
And for the attribute parameter information, if the attribute parameter information contains a label and the label does not accord with the isolation branch matching rule, replacing the attribute parameter code content corresponding to the attribute parameter information with blank content. That is, the annotation or tag used by the attribute parameter does not contain Alipay, for example, the annotation is @ O2OTarget (APP. KOUBEI), the start position and the end position of the attribute parameter are recorded first, and the whole code content of the attribute parameter is completely replaced by blank content according to the recorded start position and end position. The annotation or tag used by the attribute parameter contains Alipay, for example, the annotation is @ O2OTarget (APP. APLIPAY), and the attribute parameter is not isolated. If the attribute parameter information does not contain the label, namely the attribute parameter is applicable to each branch, the attribute parameter is not isolated.
And for the inner class information, if the inner class information contains the label and the label does not accord with the isolation branch matching rule, replacing the inner class code content corresponding to the inner class information with blank content. The processing of the inner class information is the same as the processing of the method information, and is not described herein again with reference to the description of the processing of the method information.
In addition to the above isolation processing, the judgment branch statement in the code logic also needs to be processed. And matching the judgment branch statement with the isolation branch matching rule, and replacing the code content contained in the judgment branch statement which does not accord with the isolation branch matching rule with blank content. If the judgment condition of the if statement does not include Alipay, which is O2OAdapterUtils.KOUBEI, the start position and the end position of the code content included in the if statement are recorded first, and the code content included in the entire if statement is replaced with blank content according to the recorded start position and end position. The judgment condition of the if statement includes Alipay, which is O2OAdapterUtils. ALIPAY, and further needs to continue matching the code content included in the if statement to see whether the judgment branch statement is included. It should be noted that, here, only the preprocessed predicate branch statement is subjected to matching, isolation processing, and the like, and the predicate branch statement that is not preprocessed is normally retained.
And repeatedly executing the step of isolating the programming language file until the matching of all code contents in the programming language file and the isolation branch matching rule is completed. And then, processing the reference relation contained in the programming language file, and removing the unused reference relation in the programming language file, for example, a java file contains a plurality of import statements, and each import statement corresponds to one reference relation. After the isolation processing, many methods, attributes and the like may be removed from the code file, and the reference relations corresponding to some import statements are redundant in the code file, and the redundant import statements are replaced by blank contents to generate the programming language file after the isolation processing. Compared with fig. 4a, the generated programming language file after the isolation processing is shown in fig. 5, and all the code contents of the code file, in which the label contains the attribute parameter and the method of the koubii, and the judgment branch statement contains the koubii, are replaced with blank contents. It should be noted that the generated isolation-processed programming language file is not directly modified from the acquired programming language file, but is regenerated into a new programming language file according to the acquired programming language file and stored in a location specified by the package.
Step S305, compiling the programming language file after the isolation processing to obtain a corresponding compiled file.
Compiling is needed for the programming language file, and a corresponding compiled file such as a class file is obtained. The programming language file after the isolation processing is compiled, so that the complete isolation of code logic irrelevant to parameters is ensured during packaging.
And step S306, deleting the programming language file after the isolation processing.
The compiled file is mainly packaged during packaging, and optionally, the programming language file after the isolation processing is deleted after the compiled file is obtained, so that unnecessary space occupation is avoided.
Step S307, packaging the resource files under the resource file path called by the compiled file, the isolated extensible markup language file and/or the package file to obtain a package file of the engineering file corresponding to the parameters.
When packaging, the compiled file, the isolated extensible markup language file (which is not required to be compiled), and the resource file (which can only specify the resource file path) under the resource file path called by the package file are packaged to obtain the package file of the engineering file corresponding to the parameters. During packaging, the method can utilize a gradle project automation construction tool to package, create the isolation processing into a new task, and insert the new task into any position before the original compiling task of the gradle to execute.
According to the code file isolation packaging method provided by the invention, different pre-labeling processing is carried out according to different code files, and different branches are effectively distinguished in codes. According to the parameters transmitted by packaging, the corresponding isolation branch matching rules are determined, the code files are respectively isolated, logic processing in the codes is completely separated, different differentiated resources are also completely separated, the purpose that when one engineering file is fused with a plurality of branch codes, the packaged package file only contains the logic of each branch is achieved, and the problems of the size of the package file and the cost required by code maintenance are solved. Furthermore, during isolation processing, code contents which do not accord with the isolation branch matching rule, such as a programming language file, an extensible markup language file and the like, are replaced by blank contents, so that the modification and adjustment can be conveniently carried out according to the error line number reported in the package file during subsequent code maintenance, and the cost for code maintenance is reduced. Meanwhile, the pre-standard processing of the branch judgment statement in the programming language file uses the real condition statement as a branch label, so that the branch judgment can be removed during compiling, and the execution speed and efficiency of the package file are improved.
FIG. 6 shows a functional block diagram of a code file isolation packaging apparatus according to an embodiment of the present invention. As shown in fig. 6, the code file isolation packaging apparatus includes the following modules:
the pre-labeling module 610 is adapted to perform pre-labeling processing on code files related to different branches in one project file.
The code files related to the functions required to be realized by different branches are all contained in one project file, that is, one project file can realize the requirements of different branches, and one project file contains all the code files of different branches. The pre-labeling module 610 needs to perform pre-labeling processing on a code file including different branches in one project file. The pre-labeling processing is mainly to label part of the content of the code file containing different branch processing logics so as to distinguish the processing logics of different branches.
Code files include, for example, programming language files, extensible markup language files, resource files, and the like. The programming language is a programming language which does not include preprocessing before compiling, such as java language. However, the C/C + + language is preprocessed before being compiled, and thus, the C/C + + language is not suitable for the present invention. Programming language files such as java files, etc.; extensible markup language files such as xml files and the like; the resource files include resource files such as pictures, files and the like. The pre-labeling module 610 needs to perform pre-labeling processing on the code files. The pre-labeling module 610 includes a first pre-labeling unit 611, a second pre-labeling unit 612 and/or a third pre-labeling unit 613.
A first pre-labeling unit 611 adapted to perform pre-labeling processing using labels on classes, methods, attribute parameters and/or internal classes related to different branches in the programming language file; and performing pre-labeling processing on logic processing codes related to different branches in the programming language file by using judgment branch statements.
The first pre-labeling unit 611 may perform pre-labeling processing on classes, methods, attribute parameters, inner classes, etc. related to different branches in the programming language file using tags. In particular, the tags may be notes or annotations, such as java files. As shown in fig. 4a, the first pre-labeling unit 611 may perform pre-labeling processing on the attribute parameter at a defined attribute parameter position using a tag, such as an AliPayName, and the first pre-labeling unit 611 performs pre-labeling using the annotation @ O2OTarget above the private StringAliyName where the code defines, which belongs to Payment Bay (APP). Further, the first pre-labeling unit 611 may also perform pre-labeling processing using the comment// the attribute used only in the pay bank at the position of the row where its definition is located. The first pre-labeling unit 611 may perform pre-labeling processing on a method using a tag at a position indicating an entire method, such as an AliPaymethod, for the method, and the first pre-labeling unit 611 performs pre-labeling on the private void AliPaymethod defined by the code using the annotation @ O2OTarget, which belongs to the PayPay Branch. Further, the first pre-labeling unit 611 may pre-label the method with the annotation, and the position may be the same as the position of the annotation. For the whole class file, the whole position of one class file can be marked by using a label for pre-marking. As above public class Test, the first pre-labeling unit 611 performs pre-labeling processing (not shown in the figure) on the Test class file using the annotation @ O2OTarget or annotation. For the internal classes in the programming language file, the first pre-labeling unit 611 may perform pre-labeling by using a label at the position of designating an entire internal class, and specifically refer to the pre-labeling process of the method. The above comments and pre-marked positions are all examples, and are set according to the implementation, and are not limited herein. The first pre-labeling unit 611 may use any one of annotation and annotation, or may use multiple annotations, and is configured according to the implementation, and this is only an example, and is not limited herein.
The first pre-labeling unit 611 performs pre-labeling processing on logic processing codes related to different branches in the programming language file by using a branch judgment statement, in addition to performing pre-labeling processing on the whole of classes, methods, attribute parameters, internal classes, and the like related to different branches in the programming language file. As shown in fig. 4a, in the method loginlock, logic processing of different branches is involved, and the first pre-labeling unit 611 uses if to judge a branch statement, and performs pre-labeling processing on logic processing codes of different branches, so as to facilitate subsequent isolation processing. When the judgment condition in the if statement is O2OAdapterUtils. I.e. for the pay pal branch, the AliPayMethod method is called. Here, the oi2oadapterutits. alipay itself is a true conditional sentence, that is, its value is true, and the alipayMethod method is executed without making a judgment. Therefore, when the code is compiled, the compiling processing can remove the judgment condition of if (true), and can directly call the AliPayMethod method, thereby improving the processing speed. In addition to the if decision branch statement, a decision branch statement such as switch may be applied to the present embodiment, and is not limited herein.
The second pre-labeling unit 612 is adapted to perform pre-labeling processing on the content related to different branches in the xml file using annotations.
The second pre-labeling unit 612 performs pre-labeling processing on the content related to different branches in the extensible markup language file using annotations. When performing the pre-labeling process, it should be noted that, for the contents of different branches in the xml file, the second pre-labeling unit 612 needs to add annotations at both the beginning and ending parts of the contents to facilitate the subsequent isolation process. As in an xml file, the second pre-annotation unit 612 adds the annotation <!before the beginning of a piece of content! -Alipay- - >, adding a comment <!after the end of the piece of content! -Alipay- >, facilitating <! -Alipay- >, it can be known which specific branch the content of the segment corresponds to in the xml file.
A third pre-labeling unit 613, adapted to store resource files related to different branches in the resource files according to different directories; and recording the path information of the resource files under different directories corresponding to different branches by using the configuration file.
The third pre-labeling unit 613 stores the resource files related to different branches in the resource files according to different directories, as shown in fig. 4b, in the adapter directory, the third pre-labeling unit 613 divides the resource files into two different branches, i.e., alicay and koubii, and stores the resource files required to be used by each branch according to the respective directories. The third pre-labeling unit 613 may record resource file path information under different directories corresponding to different branches by using a configuration file used in packaging. As indicated by the code in the configuration file below:
Figure BDA0001561669780000171
when packaging, according to different directories pointed by different branch names recorded in the configuration file, the path information of the resource file corresponding to each branch can be obtained, and then the corresponding resource file is obtained.
The obtaining module 620 is adapted to obtain parameters transmitted during different branch packing.
During packing, the obtaining module 620 obtains different parameters transmitted by different branches, and the different parameters are used for marking different branches. The parameters are related to the pre-labeling process, and the parameters may be the same as or different from the labels used in the pre-labeling process, but when the parameters are different, the corresponding relationship between the parameters and the labels needs to be preset. Therefore, when packaging, corresponding isolation processing can be carried out according to the parameters.
When packing, different branches know the specific branch to be packed through parameters. The obtaining module 620 obtains the reference transmitted during the packing, and the parameters correspond to different branches, where the number of the branches may be two or more, and is not limited. If the parameter can be public praise and pay treasure; or the parameters are a test environment, an operating environment, a development environment, etc. The values of the parameters are related to the labels, the names corresponding to different branches in the configuration file, and the like, and the specific types and values of the parameters are set according to implementation conditions.
The isolation module 630 is adapted to perform isolation processing on the code file according to the parameter to obtain an isolated code file.
When the isolation module 630 performs isolation processing on the code files, it needs to acquire the location information of each code file in the project file. And acquiring each code file according to the position information, and then carrying out isolation processing on the code files needing isolation processing according to the parameters. Specifically, the isolation module 630 reserves the content related to the parameter in the code file, and removes the content that is not matched with the parameter, so as to ensure that the obtained code file after the isolation processing only contains the content related to the parameter, that is, only the content required by the branch corresponding to the parameter is obtained, thereby completely isolating the content of code logic and the like that are not related to the branch corresponding to the parameter, and reducing the content of the code file that needs to be contained during packaging.
The isolation module 630 determines the corresponding isolation branch matching rule used for isolation for different code files according to the parameters. The isolation module 630 includes a first isolation unit 631, a second isolation unit 632, and/or a third isolation unit 633.
The first isolation unit 631 is adapted to obtain resource file path information in the configuration file that conforms to the isolation branch matching rule; and setting a resource file path called by the package file according to the resource file path information.
For resource files, the isolation module 630 determines the isolation branch matching rule to be consistent with the AliPayRes according to a parameter such as AliPay. The first isolation unit 631 obtains the resource file path information in the configuration file that conforms to the isolation branch matching rule, that is, obtains the resource file path information adapter/Alipay corresponding to the AlipayRes. The first isolation unit 631 sets the resource file path called by the package file according to the resource file path information, that is, the first isolation unit 631 sets the resource file path to be called by the package file to adapter/alias.
A second isolation unit 632 adapted to obtain an extensible markup language file; and matching the comments in the extensible markup language file with the isolation branch matching rule, replacing the contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating the extensible markup language file after the isolation processing.
For extensible markup language files, the isolation module 630 determines the isolated branch matching rule as the annotation contains Alipay according to a parameter such as Alipay. The second isolation unit 632 first obtains the xml file, matches the comments in the xml file with the isolation branch matching rule, replaces the content included in the comments that do not meet the isolation branch matching rule with blank content, and generates the xml file after the isolation processing. For example, the annotation format is <! XXX- - >, the second isolation unit 632 matches the content of the retrieved XML file line by line, when no comments are included, or when the comments are <! When the distance is equal to the distance matching rule, the second isolation unit 632 does not process the distance. When the annotation is not <! The second isolation unit 632 records the position of the annotation inconsistent with the isolation branch matching rule, i.e. the content start position, continues matching, finds the annotation at the end of the content, and records the content end position. The second isolation unit 632 replaces the whole content with blank content according to the recorded content start position and content end position, and the second isolation unit 632 also replaces the content of the line where the annotation is located with blank content. In this embodiment, the second isolating unit 632 may also delete the segment of content, but preferably still keeps the row number of the segment of content, and replaces the specific content with blank content, so that when a bug or other problem occurs in the future, the corresponding row number may be found from the log file, and the corresponding row number of the xml file is modified. It should be noted that the isolated xml file generated by the second isolation unit 632 is not directly modified from the obtained xml file, but is regenerated into a new xml file according to the obtained xml file and stored in a location specified by the package.
A third isolation unit 633 adapted to acquire a programming language file; and matching the tags in the programming language file with the isolation branch matching rules, replacing the content corresponding to the tags which do not accord with the isolation branch matching rules with blank content, and generating the programming language file after isolation processing.
For a programming language file, the quarantine module 630 determines that the quarantine branch matching rule is that Alipay is included in the tag according to a parameter such as Alipay. The third isolation unit 633 first obtains the programming language file, matches the tags in the programming language file with the isolation branch matching rules, replaces the content corresponding to the tags that do not meet the isolation branch matching rules with blank content, and generates the isolated programming language file. Specifically, the third isolation unit 633 performs syntax tree parsing on the programming language file to obtain class information, method information, attribute parameter information, internal class information, and the like. For class information, if the class information includes a tag and the tag does not comply with the isolation branch matching rule, the third isolation unit 633 filters out the programming language file. That is, the annotation or the tag used by the class file does not contain Alipay, for example, the annotation is @ O2OTarget (APP. KOUBEI), the third isolation unit 633 directly filters the class file, that is, the third isolation unit 633 directly isolates the class file, and does not use the class file as the code file required by the packaging. The annotation or the tag used by the class file contains Alipay, for example, the annotation is @ O2OTarget (APP. APLIPAY), the class file is a code file required by the packaging at this time, and the third isolation unit 633 directly acquires the class file without performing isolation processing on the class file. If the class information does not include a label, the third quarantine unit 633 needs to further match the method information, the attribute parameter information, the internal class information, and the like included in the class file.
For the method information, if the method information includes a tag and the tag does not meet the isolation branch matching rule, the third isolation unit 633 replaces the method body code content corresponding to the method information with blank content. That is, the annotation or tag used by the method does not contain Alipay, such as the annotation @ O2OTarget (APP. KOUBEI), the third isolation unit 633 records the start position and the end position of the method first, and replaces the content of the whole method body code with blank content completely according to the recorded start position and end position. The annotation or tag used in the method includes Alipay, such as @ O2OTarget (APP. APLIPAY), and the third isolation unit 633 does not perform isolation processing on the method. If the method information does not include a tag, the third isolation unit 633 needs to further match the attribute parameter information, the judgment branch, and the like in the method information.
For the attribute parameter information, if the attribute parameter information includes a tag and the tag does not conform to the isolation branch matching rule, the third isolation unit 633 replaces the attribute parameter code content corresponding to the attribute parameter information with blank content. That is, the annotation or tag used by the attribute parameter does not contain Alipay, such as the annotation is @ O2OTarget (APP. KOUBEI), the third isolation unit 633 records the start position and the end position of the attribute parameter first, and replaces the whole attribute parameter code content with blank content according to the recorded start position and end position. The annotation or tag used by the attribute parameter includes Alipay, for example, the annotation is @ O2OTarget (APP. APLIPAY), and the third isolation unit 633 does not perform isolation processing on the attribute parameter. If the attribute parameter information does not include a tag, that is, the attribute parameter is applicable to each branch, the third isolation unit 633 does not perform isolation processing on the attribute parameter.
For the inner class information, if the inner class information includes a label and the label does not conform to the isolation branch matching rule, the third isolation unit 633 replaces the inner class code content corresponding to the inner class information with blank content. The processing of the inner class information is the same as the processing of the method information, and is not described herein again with reference to the description of the processing of the method information.
In addition to the above isolation processing, the third isolation unit 633 also needs to process a judgment branch statement in the code logic. The third isolation unit 633 matches the judgment branch statement with the isolation branch matching rule, and replaces the code content contained in the judgment branch statement that does not meet the isolation branch matching rule with blank content. Koubei, the third isolation unit 633 records the start position and the end position of the code content included in the if statement, and replaces all the code content included in the entire if statement with blank content according to the recorded start position and end position. The third isolation unit 633 needs to further match the code content included in the if statement, and check whether the if statement further includes a branch judgment statement. It should be noted that, here, only the preprocessed predicate branch statement is subjected to matching, isolation processing, and the like, and the predicate branch statement that is not preprocessed is normally retained.
The third isolation unit 633 repeatedly executes the above-mentioned steps of performing isolation processing on the programming language file until the matching of all code contents in the programming language file with the isolation branch matching rule is completed. Then, the third isolating unit 633 processes the reference relationship contained in the programming language file, and removes the reference relationship that is not used in the programming language file, for example, a java file contains multiple import statements, and each import statement corresponds to one reference relationship. After the isolation processing, many methods, attributes, and the like may be removed from the code file, and some reference relations corresponding to import statements are already redundant in the code file, and the third isolation unit 633 replaces the redundant import statements with blank contents to generate the programming language file after the isolation processing. The third isolation unit 633 generates the isolated programming language file as shown in fig. 5, and compared with fig. 4a, the third isolation unit 633 replaces all the attribute parameters and methods of the label containing koubii in the code file and the code content of the branch statement containing koubii with blank content.
It should be noted that the isolated processed programming language file generated by the third isolating unit 633 is not directly modified from the acquired programming language file, but is newly generated from the acquired programming language file and saved at a position specified by packaging.
And the packing module 640 is adapted to pack the code file after the isolation processing to obtain a package file of the project file corresponding to the parameter.
The packaging module 640 packages the code files subjected to the isolation processing, and the obtained package files only include the code files in the engineering files corresponding to the parameters, but isolate the content of the code files not corresponding to the parameters, so that the size of the engineering files is greatly reduced, and the package files obtained by packaging cannot cause the problems of overlarge files, excessive code logics, excessive judgment branches during execution, low execution speed and the like.
Further, the programming language file packaging module 640 needs to compile to obtain a corresponding compiled file such as a class file. The programming language file after the isolation processing is compiled, so that the complete isolation of code logic irrelevant to parameters is ensured during packaging. Because the compiled file is mainly packaged during packaging, optionally, after the compiled file is obtained, the packaging module 640 deletes the programming language file after the isolation processing, thereby avoiding unnecessary space occupation. When packaging, the packaging module 640 packages the compiled file, the isolated xml file (which is not required to be compiled), and the resource file (which may only specify the resource file path) in the resource file path called by the package file, to obtain the package file of the engineering file corresponding to the parameters. The packaging module 640 can utilize the automatic building tool of the gradle project to package when packaging, and create the isolation process contained in the isolation module 630 as a new task, which can be inserted into any position before the original compilation task of the gradle to be executed.
According to the code file isolation packaging device provided by the invention, code files related to different branches in one project file are pre-labeled; acquiring parameters transmitted in different branch packing processes; according to the parameters, carrying out isolation processing on the code file to obtain the code file after the isolation processing; and packaging the code files subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters. The invention uses the same project file, and carries out pre-labeling processing on the code file contained in the project file, so that one project file contains different branches. And different pre-labeling processing is carried out according to different code files, so that different branches can be effectively distinguished in the codes. And correspondingly isolating the code file after the pre-labeling processing according to the actual parameters when different branches are packaged, and only packaging the code file after the isolation processing. Namely, according to the parameters transmitted by packaging, the parameters are correspondingly packaged into the package files corresponding to the parameters. The invention not only solves the problem of merging and maintaining different branch codes, but also solves the problems of incomplete isolation of processing logic in each packet of files after packaging, overlarge packet files and the like. Furthermore, during isolation processing, code contents which do not accord with the isolation branch matching rule, such as a programming language file, an extensible markup language file and the like, are replaced by blank contents, so that the modification and adjustment can be conveniently carried out according to the error line number reported in the package file during subsequent code maintenance, and the cost for code maintenance is reduced. Meanwhile, the pre-standard processing of the branch judgment statement in the programming language file uses the real condition statement as a branch label, so that the branch judgment can be removed during compiling, and the execution speed and efficiency of the package file are improved.
The application also provides a nonvolatile computer storage medium, wherein the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the code file isolation packaging method in any method embodiment.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and the specific embodiment of the present invention does not limit the specific implementation of the electronic device.
As shown in fig. 7, the electronic device may include: a processor (processor)702, a Communications Interface 704, a memory 706, and a communication bus 708.
Wherein:
the processor 702, communication interface 704, and memory 706 communicate with each other via a communication bus 708.
A communication interface 704 for communicating with network elements of other devices, such as clients or other servers.
The processor 702 is configured to execute the program 710, and may specifically perform relevant steps in the above-described code file isolation packaging method embodiment.
In particular, the program 710 may include program code that includes computer operating instructions.
The processor 702 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement an embodiment of the present invention. The electronic device comprises one or more processors, which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
The memory 706 stores a program 710. The memory 706 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 710 may be specifically configured to cause the processor 702 to execute the code file isolation packaging method in any of the above-described method embodiments. For specific implementation of each step in the program 710, reference may be made to corresponding steps and corresponding descriptions in units in the foregoing code file isolation and packaging embodiment, which are not described herein again. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, and are not described herein again.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a code file isolation packaging system according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (14)

1. A code file isolation packaging method comprises the following steps:
pre-labeling code files related to different branches in one project file;
acquiring parameters transmitted in different branch packing processes;
according to the parameters, carrying out isolation processing on the code file to obtain an isolated code file;
packaging the code files subjected to the isolation processing to obtain package files of the engineering files corresponding to the parameters;
the code file comprises a programming language file; the pre-labeling the code file related to the different branches further comprises:
performing pre-labeling processing on classes, methods, attribute parameters and/or internal classes related to different branches in a programming language file by using labels; wherein the tag is an annotation or annotation;
and/or, performing pre-labeling processing on logic processing codes related to different branches in the programming language file by using judgment branch statements;
the isolating the code file according to the parameters to obtain the code file after the isolating process further comprises:
acquiring a programming language file;
and matching the tags in the programming language file with the isolation branch matching rules, replacing the contents corresponding to the tags which do not accord with the isolation branch matching rules, and generating the programming language file after the isolation processing.
2. The method of claim 1, wherein the code files further comprise extensible markup language files and/or resource files;
the pre-labeling the code file related to the different branches further comprises:
pre-labeling the content related to different branches in the extensible markup language file by using annotations;
and/or the presence of a gas in the gas,
storing the resource files related to different branches in the resource files according to different directories;
and recording the path information of the resource files under different directories corresponding to different branches by using the configuration file.
3. The method according to claim 1 or 2, wherein the isolating the code file according to the parameter to obtain the isolated code file further comprises:
determining a corresponding isolation branch matching rule according to the parameters;
and according to the isolation branch matching rule, carrying out isolation processing on the code file to obtain the code file after the isolation processing.
4. The method of claim 3, wherein the isolating the code file according to the isolation branch matching rule to obtain the isolated code file further comprises:
acquiring resource file path information in a configuration file, wherein the resource file path information conforms to the isolation branch matching rule;
setting a resource file path called by a package file according to the resource file path information;
and/or the presence of a gas in the gas,
acquiring an extensible markup language file;
matching the comments in the extensible markup language file with the isolation branch matching rule, replacing the contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating an extensible markup language file after isolation processing;
and/or
Acquiring a programming language file;
and matching the tags in the programming language file with the isolation branch matching rule, replacing the content corresponding to the tags which do not accord with the isolation branch matching rule with blank content, and generating the programming language file after isolation processing.
5. The method according to claim 4, wherein the matching of the tag in the programming language file with the isolation branch matching rule, and replacing the content corresponding to the tag that does not meet the isolation branch matching rule with blank content, and the generating of the isolated programming language file further comprises:
parsing the syntax tree of the programming language file to obtain class information, method information, attribute parameter information and/or internal class information;
if the class information contains a label, and the label does not accord with the isolation branch matching rule, filtering the programming language file;
if the method information comprises a label, and the label does not accord with the isolation branch matching rule, replacing the method body code content corresponding to the method information with blank content;
if the attribute parameter information contains a label, and the label does not accord with the isolation branch matching rule, replacing the attribute parameter code content corresponding to the attribute parameter information with blank content;
if the inner class information contains a label and the label does not accord with the isolation branch matching rule, replacing the inner class code content corresponding to the inner class information with blank content;
matching the judgment branch statement with the isolation branch matching rule, and replacing code content contained in the judgment branch statement which does not accord with the isolation branch matching rule with blank content;
repeatedly executing the steps until the matching of all code contents of the programming language file and the isolation branch matching rule is completed;
and removing unused reference relations in the programming language file to generate the programming language file after the isolation processing.
6. The method according to any one of claims 1 to 5, wherein the packaging the code file after the isolation processing to obtain a package file of the engineering file corresponding to the parameter further comprises:
compiling the programming language file after the isolation processing to obtain a corresponding compiled file;
deleting the programming language file after the isolation processing;
and packaging the resource files under the resource file path called by the compiled file, the isolated extensible markup language file and/or the package file to obtain a package file of the engineering file corresponding to the parameter.
7. A code file isolation packaging apparatus, comprising:
the pre-labeling module is suitable for pre-labeling the code files related to different branches in one project file;
the acquisition module is suitable for acquiring parameters transmitted in different branch packing processes;
the isolation module is suitable for carrying out isolation processing on the code file according to the parameters to obtain the code file after the isolation processing;
the packaging module is suitable for packaging the code file subjected to the isolation processing to obtain a package file of the engineering file corresponding to the parameters;
the code file comprises a programming language file; the pre-labeling module further comprises:
the first pre-labeling unit is suitable for performing pre-labeling processing on classes, methods, attribute parameters and/or internal classes related to different branches in the programming language file by using labels; wherein the tag is an annotation or annotation; and/or, performing pre-labeling processing on logic processing codes related to different branches in the programming language file by using judgment branch statements;
the isolation module further comprises:
the third isolation unit is suitable for acquiring a programming language file; and matching the tags in the programming language file with the isolation branch matching rules, replacing the contents corresponding to the tags which do not accord with the isolation branch matching rules, and generating the programming language file after the isolation processing.
8. The apparatus of claim 7, wherein the code files further comprise an extensible markup language file and/or a resource file;
the pre-labeling module further comprises:
the second pre-labeling unit is suitable for performing pre-labeling processing on the content related to different branches in the extensible markup language file by using annotations;
and/or the presence of a gas in the gas,
the third pre-labeling unit is suitable for storing the resource files related to different branches in the resource files according to different directories; and recording the path information of the resource files under different directories corresponding to different branches by using the configuration file.
9. The apparatus of claim 7 or 8, wherein the isolation module is further adapted to:
determining a corresponding isolation branch matching rule according to the parameters; and according to the isolation branch matching rule, carrying out isolation processing on the code file to obtain the code file after the isolation processing.
10. The apparatus of claim 9, wherein the isolation module further comprises:
the first isolation unit is suitable for acquiring resource file path information in a configuration file, wherein the resource file path information conforms to the isolation branch matching rule; setting a resource file path called by a package file according to the resource file path information;
and/or the presence of a gas in the gas,
the second isolation unit is suitable for acquiring the extensible markup language file; matching the comments in the extensible markup language file with the isolation branch matching rule, replacing the contents contained in the comments which do not accord with the isolation branch matching rule with blank contents, and generating an extensible markup language file after isolation processing;
the third isolation unit is further adapted to: acquiring a programming language file; and matching the tags in the programming language file with the isolation branch matching rule, replacing the content corresponding to the tags which do not accord with the isolation branch matching rule with blank content, and generating the programming language file after isolation processing.
11. The apparatus of claim 10, wherein the third isolation unit is further adapted to:
parsing the syntax tree of the programming language file to obtain class information, method information, attribute parameter information and/or internal class information; if the class information contains a label, and the label does not accord with the isolation branch matching rule, filtering the programming language file; if the method information comprises a label, and the label does not accord with the isolation branch matching rule, replacing the method body code content corresponding to the method information with blank content; if the attribute parameter information contains a label, and the label does not accord with the isolation branch matching rule, replacing the attribute parameter code content corresponding to the attribute parameter information with blank content; if the inner class information contains a label and the label does not accord with the isolation branch matching rule, replacing the inner class code content corresponding to the inner class information with blank content; matching the judgment branch statement with the isolation branch matching rule, and replacing code content contained in the judgment branch statement which does not accord with the isolation branch matching rule with blank content; repeatedly executing the operation until the matching of all code contents of the programming language file and the isolation branch matching rule is completed; and removing unused reference relations in the programming language file to generate the programming language file after the isolation processing.
12. The apparatus of any of claims 7-11, wherein the packaging module is further adapted to:
compiling the programming language file after the isolation processing to obtain a corresponding compiled file; deleting the programming language file after the isolation processing; and packaging the resource files under the resource file path called by the compiled file, the isolated extensible markup language file and/or the package file to obtain a package file of the engineering file corresponding to the parameter.
13. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction which causes the processor to execute the operation corresponding to the code file isolation packaging method of any one of claims 1-6.
14. A computer storage medium having stored therein at least one executable instruction that causes a processor to perform operations corresponding to the code file isolation packaging method of any one of claims 1-6.
CN201810083363.4A 2018-01-29 2018-01-29 Code file isolation packaging method and device Active CN108304175B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810083363.4A CN108304175B (en) 2018-01-29 2018-01-29 Code file isolation packaging method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810083363.4A CN108304175B (en) 2018-01-29 2018-01-29 Code file isolation packaging method and device

Publications (2)

Publication Number Publication Date
CN108304175A CN108304175A (en) 2018-07-20
CN108304175B true CN108304175B (en) 2021-06-08

Family

ID=62867006

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810083363.4A Active CN108304175B (en) 2018-01-29 2018-01-29 Code file isolation packaging method and device

Country Status (1)

Country Link
CN (1) CN108304175B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110968340A (en) * 2018-09-29 2020-04-07 京东数字科技控股有限公司 Method and device for realizing multi-version dependence isolation
CN111273944B (en) * 2018-12-05 2024-01-30 三六零科技集团有限公司 Method and device for generating program file and uploading program file to code warehouse
CN111382131B (en) * 2018-12-27 2023-05-09 浙江大学 Data processing method, device and storage medium
CN109739524B (en) * 2019-01-09 2022-04-15 北京字节跳动网络技术有限公司 Software installation package generation method and device, electronic equipment and storage medium
CN109783133B (en) * 2019-01-17 2022-03-22 北京城市网邻信息技术有限公司 Code packaging method and device, computer equipment and storage medium
CN111078278B (en) * 2019-12-21 2020-09-08 众能联合数字技术有限公司 Automatic packaging method supporting Flutter and iOS mixed editing project
CN111628938B (en) * 2020-05-26 2023-06-20 抖音视界有限公司 Branch merging method, device, electronic equipment and computer storage medium
CN112882720B (en) * 2021-03-15 2024-03-22 抖音视界有限公司 Compiling method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528165A (en) * 2016-11-11 2017-03-22 深圳中兴网信科技有限公司 Code generation method and code generation system
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9507594B2 (en) * 2013-07-02 2016-11-29 Intel Corporation Method and system of compiling program code into predicated instructions for execution on a processor without a program counter

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528165A (en) * 2016-11-11 2017-03-22 深圳中兴网信科技有限公司 Code generation method and code generation system
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Android项目如何将同一套代码应用于多个项目;-大锅饭-;《https://blog.csdn.net/Tomasyb/article/details/78871456》;20171222;第1-3页 *

Also Published As

Publication number Publication date
CN108304175A (en) 2018-07-20

Similar Documents

Publication Publication Date Title
CN108304175B (en) Code file isolation packaging method and device
CN110968325B (en) Applet conversion method and device
CN112394942B (en) Distributed software development compiling method and software development platform based on cloud computing
CN111813380B (en) Coloring data processing method and device based on game engine and electronic equipment
CN110990001A (en) IVR (Interactive Voice response) process execution method and device
CN112835587B (en) Compiling integration method and device
CN111475150B (en) Cross-language binding method, device, equipment and storage medium
US10338891B2 (en) Migration between model elements of different types in a modeling environment
CN108920179A (en) Java reflects implementation method, device and system
CN106293862B (en) A kind of analysis method and device of expandable mark language XML data
CN113190235B (en) Code analysis method and device, electronic terminal and storage medium
WO2020073200A1 (en) Program debugging method and system
CN111198708A (en) Method and device for solving conflict of jar packets
EP2535813B1 (en) Method and device for generating an alert during an analysis of performance of a computer application
CN111273940B (en) Method and device for uploading program file to code warehouse
CN115562686A (en) Lightweight packaging method, system, terminal and storage medium for Springboot project
CN112463596B (en) Test case data processing method, device and equipment and processing equipment
CN103577170A (en) Construction method and construction device for web application
CN111273944B (en) Method and device for generating program file and uploading program file to code warehouse
CN113760291A (en) Log output method and device
CN112000386A (en) Application implementation method and device
CN111444057A (en) Page performance data acquisition method and device and computing equipment
CN114091111B (en) Method and device for storing intelligent contracts of block chains
JP6945434B2 (en) Software development equipment, software development methods and software development programs
CN114527997A (en) Project construction method, device, equipment and storage medium

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