Disclosure of Invention
The invention mainly aims to provide a packaging method, a packaging terminal and a computer readable storage medium of an application program package, and aims to solve the problem that an outsourcing file available in a project cannot be packaged into the application program package.
In order to achieve the above object, the present invention provides a method for packaging an application package, the method for packaging an application package comprising the steps of:
Acquiring an outsourcing and an inner package, wherein the files in the inner package are files of the project, and the files in the outsourcing are not files of the project;
when the fact that the outer package comprises a first file is detected, adding the directory information of the first file into a package directory in a package script to obtain a target directory, wherein the package directory is determined according to the directory information of each second file in the inner package, and the first file is a file required by the inner package;
and controlling the packaging script to compile the first file and the second file based on the target directory to obtain an application program package.
In an embodiment, after the step of obtaining the outsourcing and the endocyst, the method further includes:
and when the fact that the first file is not included in the outer package is detected, the packaging script is controlled to compile the second file based on the packaging catalogue, and an application program package is obtained.
In an embodiment, before the step of obtaining the outsourcing and the endocyst, the method further includes:
acquiring a packaging instruction;
and executing the step of obtaining the outsourcing and the inner package when the packaging instruction comprises preset parameters.
In one embodiment, after the step of receiving the package instruction, the method further includes:
and when the packaging instruction does not comprise preset parameters, controlling the packaging script to compile the second file based on the packaging catalog to obtain an application program package.
In an embodiment, the step of controlling the package script to compile the first file and the second file based on the target directory to obtain an application package includes:
acquiring a first file according to directory information of the first file, and adding the first file into the inner package, wherein the directory information at least comprises a path and a file name;
and controlling the packaging script to compile the files in the inner package added with the first file based on the target directory to obtain an application program package.
In an embodiment, after the step of controlling the package script to compile the file in the inner package to which the first file is added based on the target directory to obtain an application package, the method further includes:
and deleting the first file in the inner package.
In an embodiment, after the step of controlling the package script to compile the first file and the second file based on the target directory to obtain an application package, the method further includes:
And deleting the directory information of the first file in the target directory to restore and obtain the package directory of the package program.
In an embodiment, after the step of obtaining the outsourcing and the endocyst, the method further includes:
determining a service scene corresponding to the inner packet;
determining whether the outsourcing comprises files required by the service scene or not;
and when the outsourcing comprises the files required by the service scene, executing the step of adding the directory information of the first file into a package directory in a package script, wherein the outsourcing comprises the files required by the service scene, and judging that the outsourcing comprises the first file.
In order to achieve the above object, the present invention also provides a packaging terminal including a memory, a processor, and a packaging program stored in the memory and executable on the processor, the packaging program implementing the steps of the packaging method of application packages as described above when executed by the processor.
To achieve the above object, the present invention also provides a computer-readable storage medium including a packaging program which, when executed by a processor, implements the steps of the packaging method of an application package as described above.
According to the packaging method, the packaging terminal and the computer readable storage medium of the application program package, the packaging terminal obtains the outsourcing outside the project and the inner package inside the project, when the fact that the outsourcing contains the first file required by the project is detected, the directory information of the file is added into the packaging directory of the packaging script to obtain the target directory, and finally the packaging script is controlled to compile the first file and the second file in the inner package based on the target directory to obtain the application program package. The packing terminal adds the catalog information of the outsourcing files required by the project into the packing catalog of the packing script, so that the purpose of packing the files available in the outsourcing into the application program package is achieved through the packing script.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The main solutions of the embodiments of the present invention are: acquiring an outsourcing and an inner package, wherein the files in the inner package are files of the project, and the files in the outsourcing are not files of the project; when the fact that the outer package comprises a first file is detected, adding the directory information of the first file into a package directory in a package script to obtain a target directory, wherein the package directory is determined according to the directory information of each second file in the inner package, and the first file is a file required by the inner package; and controlling the packaging script to compile the first file and the second file based on the target directory to obtain an application program package.
The packing terminal adds the catalog information of the outsourcing files required by the project into the packing catalog of the packing script, so that the purpose of packing the files available in the outsourcing into the application program package is achieved through the packing script.
As shown in fig. 1, fig. 1 is a schematic hardware structure of a packaging terminal according to an embodiment of the present invention.
As shown in fig. 1, the embodiment of the present invention relates to a packaging terminal, which may include: a processor 101, such as a CPU, a communication bus 102, and a memory 103. Wherein the communication bus 102 is used to enable connected communication between these components. The memory 103 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 103 may alternatively be a storage device separate from the aforementioned processor 101. It will be appreciated by those skilled in the art that the structure shown in fig. 1 is not limiting and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
As shown in fig. 1, a packaging program may be included in the memory 103 as one type of computer storage medium.
In the apparatus shown in fig. 1, the processor 101 may be configured to call a wrapper stored in the memory 103 and perform the following operations:
Acquiring an outsourcing and an inner package, wherein the files in the inner package are files of the project, and the files in the outsourcing are not files of the project;
when the fact that the outer package comprises a first file is detected, adding the directory information of the first file into a package directory in a package script to obtain a target directory, wherein the package directory is determined according to the directory information of each second file in the inner package, and the first file is a file required by the inner package;
and controlling the packaging script to compile the first file and the second file based on the target directory to obtain an application program package.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
and when the fact that the first file is not included in the outer package is detected, the packaging script is controlled to compile the second file based on the packaging catalogue, and an application program package is obtained.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
acquiring a packaging instruction;
and executing the step of obtaining the outsourcing and the inner package when the packaging instruction comprises preset parameters.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
and when the packaging instruction does not comprise preset parameters, controlling the packaging script to compile the second file based on the packaging catalog to obtain an application program package.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
acquiring a first file according to directory information of the first file, and adding the first file into the inner package, wherein the directory information at least comprises a path and a file name;
and controlling the packaging script to compile the files in the inner package added with the first file based on the target directory to obtain an application program package.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
and deleting the first file in the inner package.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
And deleting the directory information of the first file in the target directory to restore and obtain the package directory of the package program.
In one embodiment, the processor 101 may call a wrapper stored in the memory 103, and further perform the following:
determining a service scene corresponding to the inner packet;
determining whether the outsourcing comprises files required by the service scene or not;
and when the outsourcing comprises the files required by the service scene, executing the step of adding the directory information of the first file into a package directory in a package script, wherein the outsourcing comprises the files required by the service scene, and judging that the outsourcing comprises the first file.
According to the scheme, the packaging terminal obtains the outsourcing outside the project and the inner package inside the project, when detecting that the outsourcing contains the first file required by the project, adds the directory information of the file into the packaging directory of the packaging script to obtain the target directory, and finally controls the packaging script to compile the first file and the second file in the inner package based on the target directory to obtain the application program package. The packing terminal adds the catalog information of the outsourcing files required by the project into the packing catalog of the packing script, so that the purpose of packing the files available in the outsourcing into the application program package is achieved through the packing script.
Based on the hardware architecture of the packaging terminal, the embodiment of the packaging method of the application program package is provided.
Referring to fig. 2, fig. 2 is a first embodiment of a method for packaging an application package according to the present invention, where the method for packaging an application package includes the following steps:
step S10, obtaining an outsourcing and an inner package, wherein the files in the inner package are files of the project, and the files in the outsourcing are not files of the project;
In this embodiment, the execution body is a package terminal. And the packaging terminal is provided with a plug-in, and the packaging terminal packages the application program package through the plug-in. The application package may be APK (Android application package ), i.e. the application package is an installation package of an application of the Android system. The plug-in may be a Gradle plug-in. Gradle is an item automation build open source tool based on APACHE ANT and APACHE MAVEN concepts. The script built by Gradle uses a special domain language based on Groovy to declare item settings, discarding various cumbersome configurations based on XML (Extensible Markup Language ). The script constructed by the Gradle plug-in is a packaging script. I.e. the packing terminal is provided with a packing script. The package script may be Grovvy script. The application package may be an installation package of an application on a wearable device, and the wearable device may be a smart watch, a smart bracelet, or the like.
When the project is developed, each file within the project forms an inner package, and each file outside the project forms an outer package. It will be appreciated that the files in the inner package are files of items, while the files in the outer package are not files of items. The inner package and the outer package are stored in a storage area corresponding to the project, and when the packing terminal needs to pack, the inner package and the outer package are acquired from the storage area.
It should be noted that the package script includes a package directory. After the inner package is built, the catalog information of all files in the inner package is input into the packaging catalog. The directory information includes at least a file name and a path of the file. It can be understood that the files entered in the package directory are files in the inner package, and the files outside the package directory are files in the outer package.
Step S20, when the fact that the outer package comprises a first file is detected, directory information of the first file is added into a package directory in a package script to obtain a target directory, wherein the package directory is determined according to directory information of each second file in the inner package, and the first file is a file required by the inner package;
The outsourcing is provided with a corresponding catalogue which is determined according to the catalogue information of each file in the outsourcing. And packaging the terminal. The packing terminal packing script traverses the directory to determine whether the first file is included in the outsource. The first file is the file required by the inner package. Specifically, the packaging script detects whether there is a first file available for the inner package in the outer package based on the lifecycle function projectsEvaluated of the item. When the first file is included in the outsourcing, the packaging terminal acquires the directory information of the first file from the directory, wherein the directory information of the first file at least comprises a path and a file name of the first file, and the path is a storage path of the first file. The packing terminal adds the directory information of the first files to a packing directory to obtain a target directory, the packing directory is determined by the directory information of each second file in the inner package, and the target directory is determined by the directory information of the first files and the directory information of the second files.
And step S30, controlling the packaging script to compile the first file and the second file based on the target directory to obtain an application program package.
After the target directory is obtained, the packing terminal controls the packing script to compile the first file and the second file based on the target directory to obtain the application program package.
Specifically, the packaging terminal extracts the first file from the outsourcing based on the directory information of the first file in the target directory, and then adds the first file to the inner package. And compiling the files in the inner package added with the first file through the target directory by the packaging script to obtain the application program package. The package script needs to compare the files in the inner package through the target directory, that is, the package script compiles all the files corresponding to the target directory.
In addition, the packaging terminal can directly acquire the first file through the directory information of the first file, and then the first file is added into the inner package, so that the packaging script compiles the file in the inner package added with the first file based on the target directory to obtain the application program package.
In the technical scheme provided by the embodiment, the packaging terminal obtains the outsourcing outside the project and the inner package inside the project, when detecting that the outsourcing contains the first file required by the project, adds the directory information of the file into the packaging directory of the packaging script to obtain the target directory, and finally controls the packaging script to compile the first file and the second file in the inner package based on the target directory to obtain the application program package. The packing terminal adds the catalog information of the outsourcing files required by the project into the packing catalog of the packing script, so that the purpose of packing the files available in the outsourcing into the application program package is achieved through the packing script.
Referring to fig. 3, fig. 3 is a second embodiment of the method for packaging an application package according to the present invention, based on the first embodiment, after the step S10, further includes:
And step S40, when the fact that the first file is not included in the outer package is detected, the packaging script is controlled to compile the second file based on the packaging catalogue, and an application program package is obtained.
In this embodiment, the packing terminal traverses the directory corresponding to the outsourcing based on the packing script to find out whether the outsourcing includes the file required by the inner package. The files required for the inner package are understood as files required for the application corresponding to the application package.
If the outsourcing does not contain the files needed by the inner package, the packaging terminal does not need to package the files in the outsourcing into the application program package. At this time, the packing terminal controls the packing script to compile each second file in the inner package based on the packing catalog, thereby obtaining the application program package.
And after the packaging terminal obtains the application program package, the packaging terminal deletes the first file added into the inner package through the packaging script. That is, after the packing terminal finishes packing, the files in the package can be restored, so that the default packing flow is not influenced. The packaging terminal can judge whether a preset parameter exists in the life cycle function, if so, the packaging terminal can determine that the first file exists in the inner package in the packaging process, and the packaging terminal deletes the first file in the inner package.
Further, after the application program is obtained, the packing terminal deletes the directory information of the first file in the target directory, so that the packing directory of the packing program is restored, and the default packing flow is prevented from being influenced.
In the technical scheme provided by the embodiment, when the package terminal obtains the inner package and the outer package, if the fact that the outer package does not contain files needed by the inner package is detected, the package script is controlled to compile each file in the inner package based on the package catalog to obtain the application program package, namely, when no available file is in the outer package, no influence is caused on the default package flow.
Referring to fig. 4, fig. 4 is a third embodiment of the method for packaging an application package according to the present invention, and before step S10, further includes:
s50, acquiring a packaging instruction;
And step S60, executing the steps of obtaining the outsourcing and the inner package when the packaging instruction comprises preset parameters, wherein the files in the inner package are files of the project, and the files in the outsourcing are not files of the project.
In this embodiment, the developer of the project may send a packing instruction to the packing terminal, and of course, the opener may operate at the packing terminal, thereby triggering the packing instruction. If the files in the outsourcing are required to be packaged into the application program package, a developer is required to input parameters in the packaging terminal, the packaging terminal generates a packaging instruction based on the parameters, and the parameters are defined as preset parameters. The preset parameter may be gradlew aDebug-PBUILD _type.
After the packing terminal obtains the packing instruction, if the packing instruction contains preset parameters, the developer can determine that the developer has a requirement of driving the file in the package into the application program package, and at the moment, the packing terminal obtains the package and the package, namely, the step S10-step S30 is executed.
If the packaging instruction does not comprise preset parameters, the packaging script is controlled to compile the second files based on the packaging catalogue to obtain an application program package, namely, a developer does not need to package the files in the outsourcing to the application program package, and the packaging terminal only needs to compile each second file in the inner package.
In the technical scheme provided by the embodiment, the packaging terminal obtains a packaging instruction, wherein the packaging instruction comprises preset parameters, and the packaging terminal packages available files in the outsourcing into the inner package.
Referring to fig. 5, fig. 5 is a fourth embodiment of a method for packaging an application package according to the present invention, and after the step S10, further includes:
step S70, determining a service scene corresponding to the inner package;
step S80, determining whether the outsourcing comprises files required by the service scene or not;
And step S90, when the outsourcing comprises the files required by the service scene, executing the step of adding the directory information of the first file into a package directory in a package script, wherein the outsourcing comprises the files required by the service scene, and judging that the outsourcing comprises the first file.
In this embodiment, the package corresponds to one application program, and the application program may include a plurality of service scenarios. For example, the application is a game application, and the service scenario includes a recharge scenario, etc. It is understood that the inner package corresponds to a plurality of traffic scenarios. The packing terminal determines whether to include a file required for the service scene in the outsourcing. For example, if the service scenario is a recharging scenario, it needs to be determined whether the outsourcing includes recharging-related files, for example, a recharging-verified file may be used as the service scenario as the first file. It can be understood that the files in the outsourcing are associated with service scenes, and if the service scene managed by the files in the outsourcing is the service scene corresponding to the inner package, the first file can be determined to be included in the outer package. By placing the business scenario into the outsourcing, maintenance costs of the inner package may be reduced.
The packaging terminal determines whether the outsourcing comprises files required by the service scene or not based on the service scene. If the outsourcing includes the file required by the service scene, the first file is determined to be included in the outsourcing, and the packaging terminal executes step S20 and step S30.
In the technical scheme provided by the embodiment, the packaging terminal determines a service scene corresponding to the inner package, determines whether the outer package includes a file required by the service scene, and packages the file into the application program package if the outer package includes the file required by the service scene.
Based on the above embodiments, the method for packaging application packages provided by the present invention will be briefly described, with specific reference to the following steps:
step 1, putting resource files except for the project into a created outsourcing;
Step 2, acquiring a packing instruction, if the packing instruction comprises parameters= gradlew aDebug-PBUILD _TYPE, starting to construct a project, and performing a process of outsourcing and filling into an inner package;
step 3, in the life cycle function projectsEvaluated of the project, detecting whether available files exist in the outsourcing, specifically detecting whether available files exist in the directory of the outsourcing through Grovvy script, if so, performing step 4, and if not, performing step 5;
Step 4, traversing the outsourcing catalogue by using Grovvy scripts, adding available files into the outsourcing and the inside packaging, and adding paths and file names of the available files into the packaging catalogue of the Grovvy scripts;
Step 5, compiling the files in the package catalog by adopting a development tool of Grovvy scripts to obtain an application program package;
And 6, judging whether preset parameters exist in a life cycle function buildFinished of the project after the application program is obtained, if so, deleting the files copied by the outsourcing in the inner package by using a Grovvy script.
The invention has the beneficial effects that:
1. The problem that the development tool cannot drive the outsourced content into the APK is solved;
2. optimizing the APK volume;
3. when outsourcing is not involved, no influence is caused to a default packaging flow;
4. the special service scene is put into the outer package, so that the maintenance cost is reduced, and the control and the use of service functions are facilitated;
5. when the method is used for outsourcing, the files of the inner package are restored after the packing operation is completed, and the default packing flow is not influenced.
6. The outsourcing and the inner-wrapping files are separated, and the function of multiple channels can be realized.
The invention also provides a packaging terminal which comprises a memory, a processor and a packaging program stored in the memory and capable of running on the processor, wherein the packaging program realizes the steps of the packaging method of the application program package in the embodiment when being executed by the processor.
The present invention also provides a computer-readable storage medium including a packaging program which, when executed by a processor, implements the steps of the packaging method of packaging a package as described in the above embodiment.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.