CN117369822A - Offline compiling method and device, electronic equipment and readable storage medium - Google Patents

Offline compiling method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN117369822A
CN117369822A CN202311292189.1A CN202311292189A CN117369822A CN 117369822 A CN117369822 A CN 117369822A CN 202311292189 A CN202311292189 A CN 202311292189A CN 117369822 A CN117369822 A CN 117369822A
Authority
CN
China
Prior art keywords
maven
file
path
compiling
warehouse
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.)
Pending
Application number
CN202311292189.1A
Other languages
Chinese (zh)
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.)
Tianyi Digital Life Technology Co Ltd
Original Assignee
Tianyi Digital Life 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 Tianyi Digital Life Technology Co Ltd filed Critical Tianyi Digital Life Technology Co Ltd
Priority to CN202311292189.1A priority Critical patent/CN117369822A/en
Publication of CN117369822A publication Critical patent/CN117369822A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The invention discloses a method, a device, electronic equipment and a readable storage medium for offline compiling, wherein the method comprises the following steps: creating a path list and a hyperlink list; copying the hyperlink list to a path list to construct a local private Maven warehouse; compiling the local private Maven warehouse offline through a script file of the project construction tool to obtain a compiled local private Maven warehouse; and deploying the compiled local private Maven warehouse to terminal equipment for offline compiling. According to the method, the local private Maven warehouse is constructed by creating the path list and is configured based on the script file of the project construction tool, so that project offline compiling can be realized without the network segment appointed by private service, and the time cost and the labor cost are reduced. The method, the device, the electronic equipment and the readable storage medium for offline compiling can be widely applied to the technical field of computers.

Description

Offline compiling method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for offline compiling, an electronic device, and a readable storage medium.
Background
With the iteration of android projects, project-dependent third-party libraries are gradually increased, hundreds or even thousands of large project-dependent third-party libraries can exist, but a part of libraries provided by Google authorities can be downloaded slowly in China, although the downloading can be configured to be accelerated by a domestic mirror website, the downloading still occupies a part of compiling time, in addition, when the projects are compiled for the first time, most of time is spent on downloading the project-dependent third-party libraries, and the problem of compiling failure caused by mistakes in downloading is layered endlessly. In addition, some self-developed libraries are placed in Maven private clothes with limited access to network segments, project compiling is not failed due to the fact that the libraries in the private clothes cannot be downloaded when the network segments appointed by the private clothes are compiled, the existing offline compiling scheme mostly downloads aar/jar packages in online third-party libraries to the local, online dependence is changed to be realized by depending on the local aar/jar packages, and the scheme has the following two problems;
firstly, each online library has a corresponding pore file, and the file records other online libraries on which the online library needs to depend, so that offline compiling cannot be realized by only downloading aar/jar packages of the online library, one download of other libraries on which the online library depends is required, one large project may need to download hundreds or even thousands of aar/jar packages, and all online dependencies are required to be changed into local dependencies in a build.gradle configuration file, so that the problems of high time cost and labor cost exist;
Secondly, when the dependent library version numbers stored in the Maven private service are modified, aar/jar packages corresponding to the version numbers must be downloaded again in a network segment appointed by the Maven private service, and offline compiling cannot be performed under the condition that the Maven private service cannot be accessed for a short time, so that the software development difficulty is increased.
Disclosure of Invention
In order to solve the technical problems, the invention aims to provide a method, a device, electronic equipment and a readable storage medium for offline compiling, which are capable of realizing offline compiling of projects without a network segment appointed by private service and reducing time cost and labor cost by creating a path list to construct a local private Maven warehouse and configuring the path list based on script files of project construction tools.
The first technical scheme adopted by the invention is as follows: a method of offline compiling, comprising the steps of:
creating a path list and a hyperlink list;
copying the hyperlink list to the path list to construct a local private Maven warehouse;
compiling the local private Maven warehouse offline through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
and deploying the compiled local private Maven warehouse to terminal equipment for offline compiling.
Further, the step of creating a path list specifically includes:
obtaining a path format of a target file of a Gradle third party library and a Maven warehouse, wherein the target file comprises a aar file, a jar file and a pom file, and the path format of the Maven warehouse comprises a domain name, an organization name, an artifactId, a version number or an actual file name;
acquiring a corresponding file path according to the target file and preprocessing the file path to obtain a preprocessed target file path format;
splicing the preprocessed target file path format with the path format of the Maven warehouse to obtain a spliced path format;
and storing the spliced path formats, and creating a path list.
Further, the step of obtaining a corresponding file path according to the target file and preprocessing to obtain a preprocessed target file path format specifically includes:
acquiring a corresponding file path according to the target file and determining a path format of the target file according to the file path;
dividing the path format of the target file through a first character string to obtain a divided path format of the target file, wherein the divided path format of the target file comprises groupId, artifactId, a version number, an md5 value of the file and an actual file name;
Dividing the groupId through a second character string to obtain divided groupId, wherein the divided groupId comprises a domain name and an organization name;
and integrating the domain name, the organization name, the artifactId and the version number to obtain a preprocessed target file path format.
Further, the groupId is a unique identifier identifying an organization of the Maven warehouse for uniquely identifying an item from the Maven warehouse; the artifactId is a unique identifier of a Maven repository for uniquely identifying the name of an item from the Maven repository.
Further, the step of creating a hyperlink list specifically includes:
extracting hyperlink information of a Maven private service through a python crawler, wherein the Maven private service represents a central storage library and is used for managing and caching a Maven warehouse;
acquiring a target URL address corresponding to the hyperlink information of the Maven private service;
selecting aar files, jar files and pore files in the hyperlink information of the Maven private service according to the target URL address;
intercepting a domain name, an organization name, an artifactId and a version number corresponding to a aar file and a domain name, an organization name, an artifactId and a version number corresponding to a jar file in hyperlink information of the Maven private service;
Splicing the domain name, organization name, artifactId and version number corresponding to the aar file and the domain name, organization name, artifactId and version number corresponding to the jar file through the first character string, and constructing a downloading path;
and downloading the hyperlink information of the Maven private service to the download path to create a hyperlink list.
Further, the path format of the hyperlink list is consistent with the path format of the Maven warehouse.
Further, the step of compiling the local private Maven warehouse offline through the script file of the project construction tool to obtain a compiled local private Maven warehouse specifically includes:
configuring the local private Maven warehouse to be of a first priority through a script file of an item construction tool;
configuring an installation address of the local private Maven warehouse;
and compiling the local private Maven warehouse offline according to the first priority and the installation address to obtain a compiled local private Maven warehouse.
The second technical scheme adopted by the invention is as follows: an apparatus for offline compiling, comprising:
The creation module is used for creating a path list and a hyperlink list;
the copying module is used for copying the hyperlink list to the path list to construct a local private Maven warehouse;
the compiling module is used for performing offline compiling on the local private Maven warehouse through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
the deployment module is used for deploying the compiled local private Maven warehouse to the terminal equipment and performing offline compiling.
The third technical scheme adopted by the invention is as follows: an electronic device is provided, the electronic device comprising at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the offline compiling method.
The fourth technical scheme adopted by the invention is as follows: there is provided a computer readable medium having stored thereon computer instructions for enabling a computer to perform the above-described offline compiling method.
The method, the device, the electronic equipment and the readable medium have the beneficial effects that: the method and the system further copy the hyperlink list to the path list to construct the local private Maven warehouse through creating the path list and creating the hyperlink list, and perform offline compiling on the local private Maven warehouse through the script file of the project construction tool, so that the path of the cache file in the gradle can be converted into the path of the Maven warehouse for storing the dependency library, the offline compiling can be completed by configuring the local Maven warehouse in the project, the complicated steps of downloading and modifying the local dependency are omitted, the time cost and the labor cost are further saved, the required dependency library can be preferentially searched in the local Maven warehouse when the project is compiled after configuration, and as all the dependency libraries are copied into the local Maven warehouse through the script, the remote warehouse searching is not performed during compiling, namely, the offline compiling of the project is realized, the development difficulty of software is further reduced, and all the dependency libraries of various versions in the Maven can be completely downloaded without performing offline compiling on the project in a network section appointed by the private service.
Drawings
FIG. 1 is a flowchart illustrating steps of a method for offline compiling according to an embodiment of the present invention;
FIG. 2 is a block diagram of an apparatus for offline compiling in accordance with an embodiment of the present invention;
FIG. 3 is a flowchart of steps of an android project offline compiling method of a local Maven warehouse according to an embodiment of the invention;
FIG. 4 is a flowchart illustrating steps for processing a locally cached file according to an embodiment of the present invention;
FIG. 5 is a flowchart of the steps for processing a file in a Maven private service in accordance with an embodiment of the present invention;
FIG. 6 is a flowchart illustrating the steps for creating a path list in accordance with an embodiment of the present invention;
FIG. 7 is a flowchart illustrating steps for script preprocessing of a target file path format in accordance with an embodiment of the present invention;
FIG. 8 is a flowchart illustrating the steps for creating a hyperlink list in accordance with an embodiment of the present invention;
FIG. 9 is a flowchart illustrating steps for offline compiling in accordance with an embodiment of the present invention;
fig. 10 is a block diagram of an electronic device employing a program compiling method according to an embodiment of the invention.
Detailed Description
The invention will now be described in further detail with reference to the drawings and to specific examples. The step numbers in the following embodiments are set for convenience of illustration only, and the order between the steps is not limited in any way, and the execution order of the steps in the embodiments may be adaptively adjusted according to the understanding of those skilled in the art.
Explanation of technical terms of the present invention:
maven warehouse: the Maven warehouse is a storage library used by a Maven construction tool and used for storing library files such as relevant dependencies, plug-ins and the like required by Java programming language construction projects, and consists of a local warehouse and a remote warehouse, wherein the local warehouse is positioned on a local computer of a developer and used for storing the local dependency library downloaded during the construction of the Maven projects so as to facilitate construction in an off-network environment. The Maven local repository is located in the m2 folder under the user's directory, and the dependencies of each item will be saved under the folder of the same name.
Gradle: gradle is a build automation tool used to build, test and deploy items of software. It can perform various construction tasks and provides great flexibility and extensibility, gradle uses the Groovy programming language as a construction scripting language, but also supports scripting using the Kotlen language.
Maven private: maven privacy garment (Maven Repository Manager) is a tool or service for managing and storing Maven repositories that allows organizations or teams to build a private Maven repository internally for storing and sharing internally developed dependency libraries, plug-ins, and other build resources.
Offline compiling refers to a process of compiling code when there is no network connection. Typically, compiling code requires downloading dependent items and build tools, all of which require network connections. However, sometimes, code compilation is required in the absence of a network environment. In this time, all the dependency items and the construction tools can be downloaded in a network environment by using an offline compiling mode, and then code compiling is carried out in a network-free environment; aiming at the problem that the version numbers of the dependent libraries stored in the Maven private service need to be downloaded again when being modified, the invention utilizes the python crawler technology to download all the dependent libraries of various versions in the Maven private service at one time, and can carry out offline compiling no matter which version number is used.
Referring to fig. 1, the present invention provides a method of offline compiling, the method comprising the steps of:
S1, creating a path list and a hyperlink list;
s11, referring to FIG. 6, creating a path list;
s111, acquiring a path format of a target file of a Gradle third party library and a Maven warehouse;
specifically, android projects are generally packaged by using a Gradle automatic construction tool, third party libraries on which the projects depend are configured in a build. Gradle file, the third party libraries can be stored in a Maven central warehouse or a Maven private service built by an enterprise or a person, the Gradle downloads the third party libraries according to the build. Gradle file when constructing the projects, the downloaded third party libraries are placed under a C \Users\username\Gradle\modules-2\files-2.1 folder by default, the file directory is traversed, all file names under the directory are obtained, a path list is created, whether the suffix of the file name is aar, jar or pom is judged, and if the suffix meets the condition, the path of the file is stored in the path list;
in this embodiment, gradle is an automated build tool based on the Groovy language, with the goal of providing a flexible and efficient build system for building and testing various types of projects.
The Maven repository is a place to store and manage Java item dependencies. The system is designed for a Maven construction tool, can help developers to introduce and manage required third-party libraries and components in projects, and is divided into two types: a local warehouse and a remote warehouse;
The local repository is a repository located on the developer's local computer for storing Maven dependencies downloaded by the developer. When a new dependency needs to be introduced in the project, maven will download the dependency from the remote repository, which the present invention stores in the local repository. Thus, in a later build, maven will directly obtain the required dependencies from the local repository without having to download again from the remote repository.
A remote repository is a repository located on the internet for storing a large number of third party libraries and components. The developer can download the required dependencies from the remote repository through the Maven build tool and use them in the project. Maven defaults to using the central repository as the primary remote repository, but other remote repositories may also be specified in the project's profile. The Maven of the invention automatically stores the downloaded dependencies in a local repository to increase the build speed and availability.
It should be noted that Maven's repository is simple and intuitive to add the required dependencies to the project, and Maven will automatically store the downloaded dependencies in the local repository to increase build speed and availability, which allows for the existence of shared dependencies, which is a centralized repository, allowing developers to share dependencies among multiple projects.
S112, acquiring a corresponding file path according to the target file and preprocessing the file path to obtain a preprocessed target file path format;
specifically, as shown in fig. 7, a corresponding file path is obtained according to the target file, and the path format of the target file is determined according to the file path; dividing the path format of the target file through the first character string to obtain a divided path format of the target file, wherein the divided path format of the target file comprises groupId, artifactId, a version number, an md5 value of the file and an actual file name; dividing the groupId through a second character string to obtain divided groupId, wherein the divided groupId comprises a domain name and an organization name; integrating the domain name, the organization name, the artifactId and the version number to obtain the preprocessed target file path format.
In this embodiment, groupId is a unique identifier that identifies the organization or company of the Maven project or Maven project module. It often conforms to the naming rules of Java packages. groupId can help Maven uniquely identify an item from the warehouse, avoiding confusion with other organizations' items. For example, the group pid of the Apache Commons item is org.apache.common, the group pid of the Juit item is Junit, the group pid of the Spring frame work item is org.spring frame work, etc., one group pid typically corresponds to one or more items, each item having its own artifactId and version. The combined use of groupId and artifactId can help Maven uniquely identify an item or an item module. For example, the org.spring-Boot-starter-web is the groupId, and the Spring-Boot-starter-web is the artifactId, which in combination identify the dependency of the web component in the Spring Boot framework.
The artifactId is the unique identifier of the Maven project or project module. It represents a unit in an item that itself can be compiled independently. In combination with groupId, artifactId can help Maven uniquely identify an item or a block of items. For example, the artifactId of the Spring frame project may be Spring-core, spring-web, spring-Boot-starter, etc., so that the artifactId should also clearly indicate its function, so that other developers can understand and use the project, e.g., the Spring-Boot-starter-web may clearly indicate that the dependency term is a starter for the web in the Spring Boot frame, and the artifactId is a unique identifier of the Maven project or project module, representing a unit in the project that can be compiled independently.
S113, splicing the preprocessed target file path format with the path format of the Maven warehouse to obtain a spliced path format;
specifically, taking an example of a google official library of the version of android.activity: 1.2.0, three files of activity-1.2.0-sources, activity-1.2.0.Aar and activity-1.2.0.Pom can be found through the traversal of step S111. Each library name is composed of groupId, artifactId and version number, groupId is generally multi-segment, composed of domain name and organization name, and for an android x.activity: 1.2.0 library, groupId is android.activity, domain name is android, organization name is activity, artifactId is activity, version number is 1.2.0. The storage path format after the Gradle construction tool downloads the three-party library is as follows: the md5 value/actual file name of/groupId/artifactId/version number/file, and the storage path format of Maven repository to the three-party repository is: directly copying the library file downloaded by Gradle into the Maven warehouse can lead to the Maven warehouse not identifying the corresponding three-party library, and the method comprises the following specific steps of: traversing the path list obtained in S111, dividing each path character string according to "/" to obtain a groupId, an artifactId, a version number, an md5 value of a file and an actual file name, dividing the groupId character string according to "/" to obtain a domain name, organizing a name, splicing the domain name, the organization name, the artifactId and the version number to obtain a path format in a Maven warehouse, and finally copying the file into the path.
In this embodiment, in Java development, jar files and aar files are two common file formats, while the pon file is one file format used by Maven building tools; jar files are a file format for archiving and distributing Java class libraries, resource files and executable files; aar is a file format of an Android application package; the pon file is an XML file format used by Maven construction tools to describe the dependencies, construction process and version information of Maven items, etc. They are widely used in Java development and Android development for conveniently distributing and using Java class libraries and Maven projects.
jar files (Java Archive) are a file format used to Archive and distribute Java class libraries, resource files, and executable files, similar to ZIP files. It typically contains Java class files, resource file metadata information, and can be used as a Java class library by other Java applications. jar files are widely used in Java development for convenient distribution and deployment of Java programs.
aar file (Android) is a file format of an Android application package, and is used for packaging and distributing Android libraries. The aar file contains all the resources of the Android library, including layout, images, text, etc., as well as the source code of the Android library and the compiled bytecode file. aar files are widely used in Android development for convenient distribution and use of Android libraries.
The pon file (Project Object Model) is an XML file format used by Maven build tools to describe the dependencies, build process and version information of Maven items, etc. It typically contains metadata information such as groupId, artifactId, version of Maven items, and dependencies of Maven items, plug-in configuration, etc. pom files are widely used in Maven build processes to describe build processes and dependencies.
S114, storing the spliced path formats, and creating a path list.
Specifically, as shown in fig. 4, android projects are generally packaged by using a Gradle automatic construction tool, third party libraries on which the projects depend are configured in a build. Gradle file, the third party libraries may be stored in a Maven central warehouse, or may be stored in a Maven private suit built by an enterprise or a person, the Gradle downloads the third party libraries according to the build. Gradle file when constructing the projects, the downloaded third party libraries are placed under a C_sers\user\gradle\caches\modules-2.1 folder by default, the file directory is traversed, all file names under the directory are acquired, a path list is created, whether the suffix of the file name is aar, jar or pom is determined, and if the suffix meets the condition, the path of the file is stored in the path list.
In this embodiment, caches are used to store all the downloaded dependent item files and metadata files, modules-2 is used to store all the downloaded dependent item files, and files-2.1 is used to store the dependent item files associated with the local file system;
s12, referring to FIG. 8, creating a hyperlink list;
in this embodiment, it should be noted that offline compiling is a process of converting software or a document from source code into an executable file or a document. In this process, a large number of files may be generated that have a cross-referencing relationship with each other, such as one source file may reference a function or variable in another source file; in order to facilitate users to review and use the files, offline compiling generally generates a hyperlink list, and the list lists the cross-reference relations among all the files, including links to source files, header files, library files and the like, so that users can conveniently browse, find and locate the positions of the files, and meanwhile, the hyperlink list can also improve the usability and usability of the documents, so that the users can more easily understand the structure of the documents and better grasp the content of the documents. Thus, creating a list of hyperlinks in offline compilation is a very important step that can improve the quality and user experience of the software or text.
S121, extracting hyperlink information of a Maven private service through a python crawler, wherein the Maven private service represents a central storage library and is used for managing and caching a Maven warehouse;
specifically, firstly, a request is sent to a Maven private service by using a request library to acquire an HTML source code of a Maven private service page, secondly, all hyperlink information is extracted from the HTML source code by using a regular expression or a Beautifuge library, finally, the extracted hyperlink information is traversed, unnecessary hyperlink information (such as JavaScript script and the like) is filtered, and effective hyperlink information is stored in a list or dictionary and returned to the list or dictionary storing the effective hyperlink information.
Firstly, a request is sent to a Maven private service by using a request library, and an HTML source code of the Maven private service page is obtained. Then, the HTML code is parsed using the Beau full Soup library to obtain all the hyperlink information. For each hyperlink it is further checked whether it is a valid hyperlink (i.e. not beginning with # and javascript: and if so it is added to the links list and finally a list storing valid hyperlink information is returned.
In this embodiment, maven's private service is a piece of software for managing and caching Maven's dependency libraries. It can be used to host local and third party libraries and provide and manage various configurations for managing these dependencies in a project. In general, the Maven private service aims at providing a central storage library, and can share and manage a dependency item library in an enterprise internal network. Dependency version control can be forced through private settings to ensure the stability of dependent items, to enable support for internal dependencies, and to be compatible with open source components. The private suit simulates the process of uploading components, so that the components can be conveniently distributed to other developers or are centrally managed by using the private suit, and the productivity is increased. Privacy services allow developers to share code and simplify the build process. Sharing a dependency library among multiple items makes it easier to copy dependencies to the current warehouse;
The Maven private service can be used for managing and caching a centralized repository of Maven dependent items in an enterprise environment to improve the construction efficiency. The trouble of construction time delay due to network problems can be reduced and better ability to control dependent item versions can be provided.
S122, obtaining a target URL address corresponding to the hyperlink information of the Maven private service;
in this embodiment, it is determined that the suffix of the hyperlink needs to view the target URL address of the link, the suffix of the hyperlink is a file extension in the target URL address, and the suffix of the hyperlink is determined by viewing the target URL address, firstly, a page is opened in a browser, when a mouse hovers over the hyperlink, the browser will display the target URL address at the bottom, and can determine the suffix of the hyperlink therefrom, secondly, a page is opened in the browser, a right click is performed on the mouse in the page, a "view source code" is selected, a code of the hyperlink is found in the source code, the target URL address can be viewed therefrom and the suffix of the hyperlink can be determined, or a developer tool is used, and the target URL address and the suffix of the hyperlink can be more conveniently viewed. In the Chrome browser, the developer tool can be opened by right clicking on the hyperlink, selecting the "check element" and then looking at the target URL address in the Elements panel, determining the suffix of the hyperlink.
It is understood that URL (Uniform Resource Locator) address refers to the only address that identifies and locates resources in a computer network such as the internet or a local area network. It is typically made up of several parts including protocols (e.g., http, https, etc.), domain names or IP addresses, port numbers, and paths, etc.
S123, selecting aar files, jar files and pore files in hyperlink information of the Maven private service according to the target URL address;
in this embodiment, the HTML source code of the aven private page is obtained according to the request sent by the target URL address. Extracting all hyperlink information from the HTML source code by using a regular expression or a mode of analyzing the HTML; processing each hyperlink to judge whether the hyperlink is a corresponding aar file, jar file or pom file; if the hyperlink is a aar file, jar file or pom file, adding it to the corresponding collection; returning the selected aar file, jar file and pom file set;
that is, the HTML source code of the Maven private page is first obtained using the requests library, and then all the hyperlink information is extracted using the regular expression. For each hyperlink we determine if it is a aar file, jar file or pom file and if so add it to the corresponding collection. Finally, we return the collection of aar files, jar files and pon files selected.
S124, intercepting a domain name, an organization name, an artifactId and a version number corresponding to a aar file, a jar file and a pore file in hyperlink information of a Maven private service;
in this embodiment, the Maven privacy garment is opened, the "Elements" tab on the toolbar is determined by the developer tool, then the corresponding link is selected, and the "Elements" option is selected, in which the mouse is hovered over the selected HTML element, then its HTML code is viewed.
S125, splicing the aar file, the jar file, the domain name corresponding to the pore file, the organization name, the artifactId and the version number through the first character string to construct a downloading path;
in this embodiment, firstly, the domain name, organization name, artifactId and version number of the file are obtained, and the download format is further constructed as follows: domain name/restore/organization name/path/groupId/artifactId/convertififid-version.
And finally, inserting the obtained domain name, organization name, artifactId and version number into the corresponding positions of the download path, and generating a complete download path to construct the download path of the invention. For example: https:// domain name/repository/organization name/path/groupId/artifactId/version/artifactId-version.
S126, the hyperlink information of the Maven private service is downloaded to the download path, and a hyperlink list is created.
Specifically, as shown in fig. 5, using a python crawler to extract all hyperlink information in a Maven private service, creating a hyperlink list, judging whether the suffix of the hyperlink is aar, jar or pom, if the suffix meets the condition, storing the hyperlink in the hyperlink list, intercepting a domain name, an organization name, an artifactId and a version number in the hyperlink list, splicing the version number into a download path, and downloading all files in the hyperlink list into the download path.
S2, copying the hyperlink list to a path list, and constructing a local private Maven warehouse;
specifically, because the paths in the Maven private service and the paths in the local Maven warehouse are consistent, no script is needed to process, and the downloaded file is directly copied to the { local Maven warehouse } \m2\restore\path.
S3, as shown in FIG. 9, performing offline compiling on the local private Maven warehouse through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
s31, configuring a local private Maven warehouse to be a first priority through a script file of an item construction tool;
In this embodiment, a Maven's configuration file settings.xml is first opened, which is typically located in the conf directory under Maven's installation directory. Secondly, in the file, a mirrors tag is found and a new mirrors tag is added. The mirror tag is used for specifying a mirror warehouse of Maven, and three subelements of id, url and mirrorOf are further added into the mirror tag. Wherein id is used to identify the private service, url is used to specify the location of the private service, mirrorOf is used to specify the remote repository that needs to be proxied. In the mirrorOf element, use "×" to represent that all remote warehouses are proxied, and finally set the mirrorOf of the private service to "×", that is, use this one local private service for all remote warehouses;
specifically, a mirroro tag is added to the mirroro tag, and mirrorOf is set to be "#" to represent that local private clothes are used for all remote warehouses, and a profile tag is added to the profiles tag, wherein a response and a plugin response of the local private clothes are specified. Finally, the use of local this profile is specified in the activeProfiles.
S32, configuring an installation address of a local private Maven warehouse;
Specifically, first, open Maven's profile settings. The file is typically located in the conf directory under Maven's installation directory, further in which a localrestore tag is found and the installation path of the local private repository is specified in the url element therein. If the localrepositisource tag does not exist, the tag needs to be manually added;
in this embodiment, a localrepositisource tag is added to the settings tag, and an installation path of the local private repository is specified therein, so that the installation path of the local private Maven repository can be successfully configured, so that Maven can install and find dependency items correctly.
And S33, performing off-line compiling according to the first priority and the installation address to obtain a compiled local private Maven warehouse.
Specifically, before the project is compiled offline, the official api of Gradle needs to be called in the build. Gradle file of the project level to configure the local Maven warehouse as a first priority, the installation address of the local Maven warehouse is set in the development tool, the required dependency library is preferentially searched in the local Maven warehouse when the project is compiled after configuration, and as all the dependency libraries are copied into the local Maven warehouse through scripts, remote warehouse searching is not needed during compiling, so that the project is compiled offline.
In this embodiment, the build. Gradle file is a script file used by the Android project construction tool Gradle, and is used to define the construction configuration of the Android application program. It contains all configuration information and tasks required for project construction, such as compiling source code, packaging applications, and can write construction scripts using the Groovy language;
the build. Gradle file typically contains the following parts:
(1) Project configuration information;
at the top of the build. Gradle, configuration information for some items, such as compiled SDK version, application package name, etc., will be defined. These configuration information will be used to specify parameters of the build process.
(2) Dependency configuration information;
the dependency configuration information will be used to add dependency libraries and third party libraries to the project. By adding dependency information in the build. Gradle file, the le will download the required dependency items and add to the items.
(3) Task configuration information;
the task configuration information defines some build tasks, such as "compiled code", "packaged application", and the like. Each task contains some configuration such as input files, output files, execute commands, etc., and then Gradle will execute the task according to these configurations.
(4) Plug-in information;
the plug-in configuration information allows for the use of various Gradle plug-ins, such as Android plug-ins, to perform some specific build tasks. By specifying the configuration for the Android plug-in the build. Gradle file, the Gradle can identify the various components of the project, thereby compiling and packaging the application correctly.
The build. Gradle file is a script file defining Android application program construction processes and dependent items. It contains configuration information for items, dependencies, and task configuration information, and allows the use of various Gradle plug-ins to perform specific build tasks. By writing the build. Gradle file, the construction process of the Android application program can be rapidly and conveniently configured and executed, so that the development efficiency and the deployment speed are greatly improved.
And S4, deploying the compiled local private Maven warehouse to terminal equipment, and performing offline compiling.
Specifically, the scheme is that off-line compiling is realized on a computer which has undergone project compiling (all libraries are in a Gradle cache file), for a computer A which performs project compiling for the first time, only a local Maven warehouse is needed to be installed, files in the Maven warehouse which are subjected to project compiling and S1, S2 and S3 steps are completed are copied to the A computer, then the S3 configuration of the local Maven warehouse is completed, the downloading time of a remote warehouse can be greatly shortened, and the more dependent third party libraries are, the more the compiling speed is increased, so that the off-line compiling can be realized by only running two scripts and configuring the local warehouse, and the complicated steps of downloading all dependent files according to a pore file and modifying all on-line dependencies into local dependencies are omitted; when the version number of the dependent library in the Maven private service is modified, the downloading is not needed again; for the first time the project is compiled, the compilation time can also be greatly reduced.
The path of Gradle buffer file is located in the Gradle directory under the user's home directory (C: \Users < username >. Gradle on Windows, and/home/. Gradle on Linux and Mac). In the gradle directory, the cache files are stored in the following subdirectories:
caches: for storing all downloaded dependent item files and metadata files.
build-cache: the method is used for storing construction caches, wherein the construction caches comprise compiler output, construction intermediate files and other output results.
daemon: daemons related files for storing Gradle's background processes.
native: for storing files related to the native platform, such as native libraries and native executives.
Further, the caches directory contains the following subdirectories:
modes-2: for storing all downloaded dependent item files (i.e., the local Maven repository).
Transform-2: for storing all the conversion files affected by the download, such as decompressing and processing the downloaded dependent item files.
metadata-2.0: for storing metadata files for all downloaded dependent items.
-resolution: for storing metadata and parsing associated with the Gradle plug-in.
The Gradle cache file directory comprises a plurality of subdirectories, wherein the subdirectories comprise various types of files in the construction process. The existence of the cache files can improve the construction efficiency, reduce the consumption of network transmission and help to accelerate the construction process.
In summary, referring to fig. 3, the embodiment of the present invention is as follows:
for a computer with project compiling, firstly, carrying out offline compiling by utilizing a Gradle cache file, wherein the path of the Gradle cache file is C \Users\usernames\caches\modules-2\files-2.1\groupid\artifactId\actual file names of the version number\files, and before copying the cache file into a Maven warehouse, all files need to be traversed, and the groupId, artifactId, version number of each file, the md5 value of the file, the actual file name and the file folder with the path of/domain name/organization name/artifactId/version number are created in the Maven warehouse;
in this embodiment, file-2.1 is a subdirectory in the Gradle cache directory, typically storing dependent item files associated with the local file system. It contains the following two subdirectories:
fileHashes: for storing hash values for all files to help Gradle identify if a file has changed. Gradle uses the file hash value to compare whether the file has been changed, and if the hash values are different, the file is considered changed.
filefonapshonts: for storing a snapshot of all files on the local file system. Gradle creates a snapshot of the file in this directory to compare whether the file has changed during construction.
In the Gradle cache, files-2.1 subdirectories are typically used to optimize the efficiency of construction of dependent items associated with the local file system. If Gradle's build cache is enabled, it will use the file hash value and snapshot in this directory to accelerate the build. During construction, gradle will examine the file hash value and snapshot in this directory to determine if the dependent item has changed, thereby avoiding unnecessary reconstruction.
file-2.1 is a subdirectory in the Gradle cache directory for storing hash values and snapshots of dependent item files associated with the local file system. The method is an important part in Gradle cache management, and is helpful for improving the construction efficiency and avoiding unnecessary reconstruction.
Secondly, extracting all hyperlink information in the Maven private service by using a python crawler, judging whether the suffix of the hyperlink is aar, jar or pom, intercepting a domain name, an organization name, an artifactId and a version number in the hyperlink if the suffix meets the condition, splicing the domain name, the organization name, the artifactId and the version number into a download path by using "/", downloading all files in a hyperlink list into the download path, and copying the downloaded files into a local Maven warehouse;
Finally, configuring a local Maven warehouse in a build. Gradle file of the project to realize offline compiling;
for a computer which does not carry out project compiling, files in a local Maven warehouse of other computers can be directly copied to realize offline compiling, and the downloading speed of an online compiling and downloading third party warehouse is limited by a Maven central warehouse and a Maven private server, so that the downloading time is long, and the scheme can effectively shorten the time spent in downloading by relying on the local Maven warehouse, so that the compiling time is reduced.
Referring to fig. 2, an apparatus for offline compiling, comprising:
the creation module is used for creating a path list and a hyperlink list;
the copying module is used for copying the hyperlink list to the path list to construct a local private Maven warehouse;
the compiling module is used for performing offline compiling on the local private Maven warehouse through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
the deployment module is used for deploying the compiled local private Maven warehouse to the terminal equipment and performing offline compiling.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
FIG. 10 illustrates a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 10, the electronic device includes a computing unit that can perform various appropriate actions and processes according to a computer program stored in a read-only memory ROM or a computer program loaded from a storage unit into a random access memory RAM. In the RAM, various programs and data required for the operation of the device may also be stored. The computing unit, ROM and RAM are connected to each other by a bus. An input/output I/0 interface is also connected to the bus.
A plurality of components in an electronic device are connected to an I/0 interface, comprising: an input unit such as a keyboard, a mouse, etc.; an output unit such as various types of displays, speakers, and the like; a storage unit such as a magnetic disk, an optical disk, or the like; and communication units such as network cards, modems, wireless communication transceivers, and the like. The communication unit allows the device to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The computing unit may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing units include, but are not limited to, central processing units CPUs, graphics processing units GPUs, various specialized artificial intelligence AI computing chips, various computing units running machine learning model algorithms, digital signal processors DSPs, and any suitable processors, controllers, microcontrollers, and the like. The computing unit performs the various methods and processes described above, such as the application offline compilation method. For example, in some embodiments, the application offline compiling method may be implemented as a computer software program, which is tangibly embodied on a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device via the ROM and/or the communication unit. When the computer program is loaded into RAM and executed by the computing unit, one or more steps of the application offline compiling method described above may be performed. Alternatively, in other embodiments, the computing unit may be configured to perform the application offline compilation method by any other suitable means, e.g. by means of firmware.
Various implementations of the systems and techniques described here above can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays FPGAs, application specific integrated circuits ASICs, application specific standard product ASSPs, system-on-chip SOCs, load programmable logic devices CPLDs, computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include a one or more wire-based air-laid connection, a portable computer diskette, a hard disk, a random access memory RAM, a read-only memory ROM, an erasable programmable read-only memory EPROM or flash memory, an optical fiber, a portable compact disc read-only memory CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The content in the method embodiment is applicable to the system embodiment, the functions specifically realized by the system embodiment are the same as those of the method embodiment, and the achieved beneficial effects are the same as those of the method embodiment.
While the preferred embodiment of the present invention has been described in detail, the invention is not limited to the embodiment, and various equivalent modifications and substitutions can be made by those skilled in the art without departing from the spirit of the invention, and these modifications and substitutions are intended to be included in the scope of the present invention as defined in the appended claims.

Claims (10)

1. A method of offline compiling comprising the steps of:
creating a path list and a hyperlink list;
copying the hyperlink list to the path list to construct a local private Maven warehouse;
Compiling the local private Maven warehouse offline through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
and deploying the compiled local private Maven warehouse to terminal equipment for offline compiling.
2. The method according to claim 1, wherein the step of creating a path list comprises:
obtaining a path format of a target file of a Gradle third party library and a Maven warehouse, wherein the target file comprises a aar file, a jar file and a pom file, and the path format of the Maven warehouse comprises a domain name, an organization name, an artifactId, a version number or an actual file name;
acquiring a corresponding file path according to the target file and preprocessing the file path to obtain a preprocessed target file path format;
splicing the preprocessed target file path format with the path format of the Maven warehouse to obtain a spliced path format;
and storing the spliced path formats, and creating a path list.
3. The method according to claim 2, wherein the step of obtaining the corresponding file path according to the target file and preprocessing to obtain the preprocessed target file path format specifically comprises:
Acquiring a corresponding file path according to the target file and determining a path format of the target file according to the file path;
dividing the path format of the target file through a first character string to obtain a divided path format of the target file, wherein the divided path format of the target file comprises groupId, artifactId, a version number, an md5 value of the file and an actual file name;
dividing the groupId through a second character string to obtain divided groupId, wherein the divided groupId comprises a domain name and an organization name;
and integrating the domain name, the organization name, the artifactId and the version number to obtain a preprocessed target file path format.
4. A method of offline compiling according to claim 3, characterized in that said groupId is a unique identifier identifying the organization of the Maven repository for uniquely identifying an item from the Maven repository; the artifactId is a unique identifier of a Maven repository for uniquely identifying the name of an item from the Maven repository.
5. The method according to claim 2, wherein the step of creating the hyperlink list comprises:
Extracting hyperlink information of a Maven private service through a python crawler, wherein the Maven private service represents a central storage library and is used for managing and caching a Maven warehouse;
acquiring a target URL address corresponding to the hyperlink information of the Maven private service;
selecting aar files, jar files and pore files in the hyperlink information of the Maven private service according to the target URL address;
intercepting a domain name, an organization name, an artifactId and a version number corresponding to a aar file and a domain name, an organization name, an artifactId and a version number corresponding to a jar file in hyperlink information of the Maven private service;
splicing the domain name, organization name, artifactId and version number corresponding to the aar file and the domain name, organization name, artifactId and version number corresponding to the jar file through the first character string, and constructing a downloading path;
and downloading the hyperlink information of the Maven private service to the download path to create a hyperlink list.
6. The method of claim 5, wherein the path format of the hyperlink list is consistent with the path format of the Maven repository.
7. The method according to claim 1, wherein the step of compiling the local private Maven repository offline through the script file of the project construction tool to obtain the compiled local private Maven repository specifically comprises:
configuring the local private Maven warehouse to be of a first priority through a script file of an item construction tool;
configuring an installation address of the local private Maven warehouse;
and compiling the local private Maven warehouse offline according to the first priority and the installation address to obtain a compiled local private Maven warehouse.
8. An apparatus for offline compiling, comprising the following modules:
the creation module is used for creating a path list and a hyperlink list;
the copying module is used for copying the hyperlink list to the path list to construct a local private Maven warehouse;
the compiling module is used for performing offline compiling on the local private Maven warehouse through a script file of the project construction tool to obtain a compiled local private Maven warehouse;
the deployment module is used for deploying the compiled local private Maven warehouse to the terminal equipment and performing offline compiling.
9. An offline compiled electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
10. An off-line compiled readable storage medium, wherein the computer instructions are for causing the computer to perform the method of any one of claims 1-7.
CN202311292189.1A 2023-10-07 2023-10-07 Offline compiling method and device, electronic equipment and readable storage medium Pending CN117369822A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311292189.1A CN117369822A (en) 2023-10-07 2023-10-07 Offline compiling method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311292189.1A CN117369822A (en) 2023-10-07 2023-10-07 Offline compiling method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN117369822A true CN117369822A (en) 2024-01-09

Family

ID=89395618

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311292189.1A Pending CN117369822A (en) 2023-10-07 2023-10-07 Offline compiling method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117369822A (en)

Similar Documents

Publication Publication Date Title
US11178207B2 (en) Software version control without affecting a deployed container
US20210182170A1 (en) Overlapping-in-time execution of load tests on applications in a centralized system
US10095489B1 (en) GUI-based application template for containerized application software development
EP3769223B1 (en) Unified test automation system
US11429365B2 (en) Systems and methods for automated retrofitting of customized code objects
US9703554B2 (en) Custom code migration suggestion system based on actual change references
US9811325B2 (en) Systems and methods for dynamically replacing code objects for code pushdown
US20170262266A1 (en) Orchestrating the lifecycle of multiple-target applications
US9652220B2 (en) Zero down-time deployment of new application versions
KR20180063240A (en) Systems and methods for building, optimizing, and implementing an infrastructure in a cloud-based computing environment
CN113434158B (en) Custom management method, device, equipment and medium for big data component
US9256509B1 (en) Computing environment analyzer
US11741002B2 (en) Test automation systems and methods using logical identifiers
US11836072B2 (en) Risk-based root cause identification methods and related autobuild systems
US8677339B2 (en) Component relinking in migrations
WO2015027844A1 (en) Method to generate dynamic customized context-sensitive help
Vivian et al. Rapid and efficient analysis of 20,000 RNA-seq samples with Toil
US10606730B2 (en) Networked digital data processor log file viewer
US20200097260A1 (en) Software application developer tools platform
US9116713B1 (en) System and method for expression evaluation in a distributed networking environment
US10698666B2 (en) Automatically building software projects
CN116244186A (en) Operating system test management method and device and computing equipment
CN117369822A (en) Offline compiling method and device, electronic equipment and readable storage medium
US11030087B2 (en) Systems and methods for automated invocation of accessibility validations in accessibility scripts
US8387040B2 (en) Dynamic creation of client-side environment for problem analysis

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