CN111897570B - Multi-dependency item file extraction method and device based on Maven plug-in - Google Patents
Multi-dependency item file extraction method and device based on Maven plug-in Download PDFInfo
- Publication number
- CN111897570B CN111897570B CN202010680433.1A CN202010680433A CN111897570B CN 111897570 B CN111897570 B CN 111897570B CN 202010680433 A CN202010680433 A CN 202010680433A CN 111897570 B CN111897570 B CN 111897570B
- Authority
- CN
- China
- Prior art keywords
- file
- item
- maven
- configuration file
- dependency
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000605 extraction Methods 0.000 title claims abstract description 47
- 230000001419 dependent effect Effects 0.000 claims abstract description 77
- 238000000034 method Methods 0.000 claims abstract description 77
- 230000008569 process Effects 0.000 claims abstract description 26
- 238000011161 development Methods 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 9
- 230000008520 organization Effects 0.000 claims description 5
- 238000004422 calculation algorithm Methods 0.000 claims description 4
- 238000013515 script Methods 0.000 abstract description 22
- 238000012423 maintenance Methods 0.000 abstract description 6
- 230000000694 effects Effects 0.000 abstract description 2
- 238000004806 packaging method and process Methods 0.000 description 9
- 238000013508 migration Methods 0.000 description 5
- 230000005012 migration Effects 0.000 description 5
- 230000010354 integration Effects 0.000 description 4
- 239000000243 solution Substances 0.000 description 4
- 238000010276 construction Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 230000006837 decompression Effects 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- PCHJSUWPFVWCPO-UHFFFAOYSA-N gold Chemical compound [Au] PCHJSUWPFVWCPO-UHFFFAOYSA-N 0.000 description 1
- 239000010931 gold Substances 0.000 description 1
- 229910052737 gold Inorganic materials 0.000 description 1
- 238000002347 injection Methods 0.000 description 1
- 239000007924 injection Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- ZLIBICFPKPWGIZ-UHFFFAOYSA-N pyrimethanil Chemical compound CC1=CC(C)=NC(NC=2C=CC=CC=2)=N1 ZLIBICFPKPWGIZ-UHFFFAOYSA-N 0.000 description 1
- 239000010979 ruby Substances 0.000 description 1
- 229910001750 ruby Inorganic materials 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
- G06F8/433—Dependency analysis; Data or control flow analysis
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
The method is realized based on the Maven plugin, the source position and the target position of the dependent item are set through a custom configuration file, and the function of extracting the dependent item file to the target position in batches from a specified Jar package is provided. A third party server or a folder and the like are not required to be introduced, so that the complexity of the system is reduced; only needs to be configured when the project is created, and other processes do not need additional configuration, so that maintenance workload is reduced; the extraction process is completed based on the Maven plugin, and because Maven only depends on the JDK, which is a cross-platform running environment, the method is platform-independent and version-independent, and no additional script or system is needed for supporting. In addition, the application provides a multi-dependency item file extraction device, equipment and a readable storage medium based on a Maven plugin, and the technical effects of the device and the equipment correspond to those of the method.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for extracting a multi-dependency file based on a Maven plugin.
Background
For a typical large project, how to efficiently, gracefully, flexibly and automatically manage various files with multiple dependencies, so that the files can be effectively integrated with a main project, and meanwhile, the files and file lists which are led in or shielded by each dependency can be managed in a fine granularity according to different scenes, so that the problem is necessarily solved.
Solutions to these problems vary from architecture to architecture, from programming/language model to programming/language model. For a typical Spring project, the package name convention and class loading mechanism provided by Java can ensure that Java classes in all plug-ins are loaded into the system as required. The problem is that after the project is run, not only class files, but generally at least environment configuration, package configuration, ORM files and database migration scripts are needed. For maven items with multiple dependencies, the framework only provides management for directly supported properties files, yaml files and the like, and special configuration files, especially the migration script, cannot be provided for relying on the internal custom package script of the Jar package.
The weakness is in two aspects, firstly, in the development process, complex local configuration is needed to carry out local development, if complex conversion operation is involved, the time is longer, and the complexity is greatly improved by considering the parallel development of a plurality of branches; secondly, in actual operation, in order to perform continuous integration, corresponding scripts need to be written for the environment of the packaging server, if the packaging environment is updated or changed, the scripts may be damaged, and additional cost is increased.
The current mainstream mode involves the scene of dynamically extracting files from dependent items (such as Jar packages) to the project main catalog. One is to separate the files from dependencies, build a set of system management files (such as another Git repository) separately, upload the files to the management system by manual configuration/automated scripting during the development of the dependent items, and then pull the files manually during use. On one hand, the method needs to maintain the same files at a plurality of positions, is a test on the synchronization and verification of the files, introduces a third party management system, greatly increases the complexity of the system, and increases certain learning cost for newly added members, thus being not a scientific solution.
Another solution is that after introducing the dependency, the dependency compression package is decompressed through a local automation script and then processed, and the processing mode has two problems, namely, the script is bound with the environment, for Java development, linux is used in a service packaging environment, windows is used in a development process, and the Linux script is not universal with the Windows script, so that two sets of scripts need to be additionally maintained for the requirement, and the requirement is inexpensible; the second problem is that the tools used for decompression are not only system-bound, but also version-bound, and if the packaging server is updated, the corresponding system tools are not compatible, the scripts may be disabled, and at this time, additional time is required for maintenance, and even multiple versions of the scripts may be maintained at the same time.
Therefore, how to provide a scheme for extracting files from the Jar package to the project main directory, which avoids the defects of increasing the complexity of the system, bringing larger maintenance workload, failing to be used by different operating systems for scripts and failing to be used by the scripts due to project upgrading, is a problem to be solved by those skilled in the art.
Disclosure of Invention
The purpose of the application is to provide a method, a device, equipment and a readable storage medium for extracting a multi-dependency item file based on a Maven plug-in, which are used for solving the problems that the current scheme for extracting the file from a Jar package often has the defects of increased system complexity, large maintenance workload and incapability of being used for different operating systems and item upgrading to cause script invalidation. The specific scheme is as follows:
in a first aspect, the present application provides a method for extracting a multi-dependency file based on a Maven plugin, including:
acquiring a configuration file of a Maven plug-in, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and the configuration file is updated along with the update of the dependent item;
acquiring a state cache file generated in the project compiling process, wherein the state cache file is used for describing the extracted dependent items in the Jar package;
cross-comparing the configuration file and the state cache file, and judging whether a changed dependent item exists or not;
if so, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
recompilation of the item and updating of the state cache file.
Preferably, the obtaining a configuration file of the Maven plugin, where the configuration file is used to describe an initial position and a target position of a dependent item, includes:
and acquiring a configuration file of the Maven plugin, wherein the configuration file is used for describing the initial position and the target position of the dependent item, and the initial position comprises the full-limit name of the Jar package and the path description information of the file/folder.
Preferably, the full-defined name includes the following three elements: an ID of the development organization, an item ID, an item version number.
Preferably, the description information of the file/folder includes a first wildcard representing any plurality of characters but not including subfolders, a second wildcard representing any plurality of characters and including subfolders, and a third wildcard representing a single character.
Preferably, the configuration file further includes path reservation configuration information, and the path reservation information includes reserved path features and unreserved path features.
Preferably, the cross comparison between the configuration file and the state cache file is performed to determine whether there is a changed dependency, including:
and cross-comparing the configuration file and the state cache file through an MD5 algorithm, and judging whether a changed dependent item exists or not.
Preferably, the obtaining the configuration file of the Maven plugin includes:
and when the triggering condition is met, acquiring a configuration file of the Maven plug-in, wherein the triggering condition is that a compiling instruction is received.
In a second aspect, the present application provides a Maven plugin-based multi-dependency file extraction apparatus, including:
configuration file acquisition module: the method comprises the steps that a configuration file of a Maven plug-in is obtained, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and is updated along with the update of the dependent item;
a state cache file acquisition module: the method comprises the steps of obtaining a state cache file generated in a project compiling process, wherein the state cache file is used for describing extracted dependent items in a Jar package;
and a cross comparison module: the method comprises the steps of carrying out cross comparison on the configuration file and the state cache file, and judging whether a changed dependent item exists or not;
and an extraction module: if so, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
and a compiling module: for recompiling the item and updating the state cache file.
In a third aspect, the present application provides a Maven plugin-based multi-dependency file extraction device, including:
a memory: for storing a computer program;
a processor: for executing the computer program to implement the steps of the Maven plugin-based multi-dependency file extraction method as described above.
In a fourth aspect, the present application provides a readable storage medium having stored thereon a computer program for implementing the steps of the Maven plugin-based multi-dependency file extraction method described above when executed by a processor.
The method for extracting the multi-dependency item file based on the Maven plugin comprises the following steps: acquiring a configuration file of a Maven plug-in, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and is updated along with the update of the dependent item; acquiring a state cache file generated in the project compiling process, wherein the state cache file is used for describing the extracted dependent items in the Jar package; cross-comparing the configuration file and the state cache file, and judging whether a changed dependent item exists or not; if the dependency item exists, reading the changed dependency item from the corresponding initial position according to the configuration file, and writing the changed dependency item into the corresponding target position; recompilation of the project and updating of the state cache file.
Therefore, the method is realized based on the Maven plug-in, the source position and the target position of the dependent item are set through the custom configuration file, the function of extracting the dependent item file to the target position in batches from one or more than one designated Jar package is provided, and the method can be widely used for various different scenes such as database script migration and decoupling, SPI definition file integration and the like. The method has at least the following three advantages:
the method has the advantages that firstly, aiming at the problem that a third party system is required to be introduced in the current multi-dependent file extraction scheme, the method directly extracts the dependent items from the Jar package, does not need to introduce a third party server or a folder and the like, and reduces the complexity of the system.
The method has the advantages that the method only needs to be configured when a project is created, the configuration can be automatically updated when the dependency is changed, and other packaging and deployment processes do not need additional configuration, so that maintenance workload is remarkably reduced.
The method is based on a Maven plugin to complete the extraction process, and because Maven only depends on the JDK, which is a cross-platform runtime environment, the method is platform-independent and version-independent, and does not need additional scripts or systems for supporting.
In addition, the application provides a Maven plugin-based multi-dependency item file extraction device, equipment and a readable storage medium, and the technical effects of the device and the equipment correspond to those of the method, and are not repeated herein.
Drawings
For a clearer description of embodiments of the present application or of the prior art, the drawings that are used in the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description that follow are only some embodiments of the present application, and that other drawings may be obtained from these drawings by a person of ordinary skill in the art without inventive effort.
FIG. 1 is a flowchart of an implementation of a first embodiment of a method for extracting a multi-dependency file based on a Maven plug-in;
FIG. 2 is a schematic diagram of a configuration file structure in a second embodiment of a method for extracting a multi-dependency file based on a Maven plug-in;
FIG. 3 is a flowchart of the overall operation of a Maven plug-in a second embodiment of a method for extracting a multi-dependency file based on a Maven plug-in provided by the present application;
FIG. 4 is a functional block diagram of an embodiment of a Maven plug-in based multi-dependency file extraction apparatus provided herein.
Detailed Description
The core of the application is to provide a method, a device, equipment and a readable storage medium for extracting multi-dependency files based on a Maven plug-in, and provide a function of extracting files to target positions in batches from one or more designated Jar packages by providing multi-dimensional custom configuration, so that the method, the device and the equipment can be widely used for various different scenes such as migration and decoupling of database scripts, integration of SPI definition files and the like.
In order to provide a better understanding of the present application, those skilled in the art will now make further details of the present application with reference to the drawings and detailed description. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
An embodiment one of a Maven plugin-based multi-dependency file extraction method provided in the present application is described below, with reference to fig. 1, where the embodiment one includes:
s101, acquiring a configuration file of a Maven plug-in, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and is updated along with the update of the dependent item;
s102, acquiring a state cache file generated in a project compiling process, wherein the state cache file is used for describing the extracted dependent items in the Jar package;
s103, cross-comparing the configuration file and the state cache file, and judging whether a changed dependent item exists or not; if the changed dependent item exists, the S104 is entered, otherwise, the processing is not performed;
s104, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
s105, recompiling the project and updating the state cache file.
Apache Maven is an open source project of pure Java development under Apache. Based on the Project Object Model (POM) concept, the processes of compiling, constructing, packaging and the like are automatically completed by analyzing the information in the POM. Compared with the traditional ant construction process, maven establishes a design thought that the contract is better than the configuration at the beginning of the design, so that on the premise of following the contracted configuration, the Maven can greatly improve the construction efficiency of the project, and meanwhile, due to excellent modeling of POM, the pon.xml file of the Maven project theoretically contains all the dependency and construction information of the current project.
Maven may also be used to construct and manage various items, such as items written in c#, ruby, scala, and other languages. Maven does not in itself provide any immediate dependency or build tool, maven itself provides just one plug-in (gold) running framework, and in actual running, the responding plug-in is located by parsing pon.xml (and all dependencies in its specified dependency tree), and then loading the plug-in from a remote repository or local repository according to configuration, and then running the plug-in. Meanwhile, maven greatly enhances the universality of the plug-in by flexible configuration and configuration injection.
Maven has been a virtually universal standard for current JavaWeb development, and has become a built-in dependency management, building and packaging framework for all projects due to its superior properties. Therefore, when discussing the problems related to these three steps, maven and its built-in lifecycle and definition can be regarded as the built-in information of the item by default, instead of the additionally introduced third party system.
The Maven plug-in is already a JavaWeb project dependence management tool, and is well expressed in a definition form, so that the user can be familiar without extra learning cost, meanwhile, as almost all mainstream IDEs and packaging tools are internally provided with support for the JavaWeb project dependence management tool, when a development environment is built, no extra configuration is needed, files can be attached to a default compiling process to be automatically configured, and in addition, the Maven is only dependent on a cross-platform runtime environment of JDK, so that the solution is platform-independent and version-independent, and no extra script or system is needed for supporting.
The embodiment allows a user to manage the extraction of the file of the dependent item through different configurations by opening flexible configuration items through a plug-in developed by the user and attaching the plug-in to the compiling process of Maven.
In this embodiment, the configuration file is initially created when the item is created, and in the subsequent process, if the dependent item changes, the configuration file needs to be updated synchronously. The state buffer file is generated in the project compiling process, and after each compiling, the state buffer file is synchronously updated.
Specifically, the configuration file is used for describing an initial position and a target position of the dependent item, wherein the initial position comprises a full-limit name of the Jar package and path description information of the file/folder, and the full-limit name further comprises the following three elements: an ID of the development organization, an item ID, an item version number. From these three elements, one Jar package can be uniquely determined.
For path description information of files/folders, considering both accuracy and flexibility, a set of easy-to-understand file matching logic can be selected, and several wildcards are defined to read the file aspect: the first wildcard represents any number of characters but does not include subfolders, the second wildcard represents any number of characters and includes subfolders, and the third wildcard represents a single character.
For the target location, there will typically be a corresponding extraction location for a class of files, but in view of the universality of the plug-in, it is preferable that one file/folder path corresponds to one target location. In practical applications, the target location may be set to a specific location in a configuration file. In addition, path reservation information of the dependent item can be set in the configuration file and used for indicating whether path characteristics of the dependent item are reserved or not, and the path reservation information comprises reserved path characteristics and unreserved path characteristics.
Generally, dependencies are created as part of a system that is rarely changed after creation, and extraction from multiple dependent files should be completed at the first compilation, and in the subsequent compilation, even if a plug-in is triggered, it should be automatically determined whether the currently configured dependent item is changed and then re-extracted. Therefore, a set of cache system needs to be built at the outer layer of the compiled target directory, and the cache is used to define the dependency and related file states of the current compiled state, and a typical cache file should contain all the states already processed in the current extraction process.
The multi-dependency item file extraction method based on the Maven plugin is realized based on the Maven plugin, the source position and the target position of the dependency item are set through the custom configuration file, the function of extracting the dependency item file to the target position in batches from one or more designated Jar packages is provided, and the method can be widely used for various different scenes such as database script migration and decoupling, SPI definition file integration and the like. The method has at least the following three advantages:
the method has the advantages that firstly, the dependent items are directly extracted from the Jar package, a third-party server or a folder and the like are not required to be introduced, and the complexity of the system is reduced.
The method has the advantages that configuration is only needed when the project is created, configuration can be automatically updated when dependency is changed, additional configuration is not needed in other packaging deployment processes, and maintenance workload is remarkably reduced.
The method has the advantages that the extraction process is finished based on the Maven plugin, and because the Maven only depends on the cross-platform runtime environment of the JDK, the method is platform-independent and version-independent, and no additional script or system is needed for supporting.
The second embodiment of the multi-dependency file extraction method based on the Maven plugin provided by the application is implemented based on the first embodiment, and is expanded to a certain extent based on the first embodiment.
As described above, the present application is implemented based on a Maven plug-in, and in practical application, the triggering condition of the Maven plug-in may be set, so as to improve efficiency. For example, the configuration file can be monitored, and the update process of the configuration file is used as a trigger condition of the Maven plugin; the current project can be monitored, and the compiling instruction of the current project is used as a trigger condition of the Maven plugin. Specific trigger conditions can be set according to actual requirements, and the application is not limited to the specific trigger conditions. In the second embodiment, the triggering condition of the plug-in is set to be that a compiling instruction is received.
Embodiment II specifically comprises the following steps:
s201, when a trigger condition is met, acquiring a configuration file of a Maven plug-in, wherein the trigger condition is that a compiling instruction is received, the configuration file is used for describing an initial position and a target position of a dependent item, and the configuration file is updated along with the update of the dependent item;
in this embodiment, the configuration file is shown in fig. 2.
S202, acquiring a state cache file generated in a project compiling process, wherein the state cache file is used for describing the extracted dependent items in the Jar package;
s203, cross-comparing the configuration file and the state cache file through an MD5 algorithm, and judging whether a changed dependent item exists or not;
s204, if the dependency item exists, reading the changed dependency item from the corresponding initial position according to the configuration file, and writing the changed dependency item into the corresponding target position;
s205, recompiling the item and updating the state cache file.
The implementation of this embodiment involves mainly two parts. One part is the extraction logic inside the plug-in and the other part is the configuration of the caller. The former is general logic, which should be placed in a common space accessible to all items, such as OSS or Nexus warehouse, after completion, and the latter is custom configuration when each item is used, which should be placed in a pon configuration file inside the item. These two parts are described below:
for Maven plug-in, the version of the plug-in is not too severely required, and the formally released version can be obtained. For extracting the jar package file, the initial position and the target position of the dependent item need to be defined in the configuration file, and in order to achieve both the semantic readability and the universal applicability, a set of corresponding description systems is specified in the embodiment.
Source file location aspect, contains two pieces of information: the full-limit name of the source Jar package and the path description information of the file/folder can uniquely determine a dependent item through the two information. For clarity of description and not confusion, for Jar packages, the present embodiment describes Jar packages using three definition elements of Maven's own, through which one Jar package can be uniquely determined in the dependency:
element 1: groupId, dependent on the ID of the development organization;
element 2: artifactId: a dependent item ID;
element 3: version: the project version is optional in view of the fact that for the use environment, multi-version dependent mix should not occur.
For path description information and matching rules of files/folders, the present embodiment defines several wild cards to describe the path of the dependent item: representing path separator representing any number of characters but not including subfolders, representing any number of characters and including subfolders? Representing a single character. And further describes matching rules according to the wildcards, and the wildcards are flexibly combined to locate a required source file when actually configured. For example, if all the sql files under src/resources need to be matched, the sql file may be written as src/resources/sql, and if all the files in the directory need to be matched, the sql file may be written as src/resources/sql.
And for the target position, the target position can be self-specified in the configuration process, for example, set as a compiling catalog of the items.
In addition, path reservation configuration information of the dependent item can be set in the configuration file, wherein the path reservation information comprises reserved path characteristics and unreserved path characteristics.
In summary, as shown in fig. 2, the configuration file structure uniquely determines a Jar package by relying on three elements, i.e., the ID of the development organization, the ID of the project, and the version of the project. Each file under the Jar package is described by path description information (matching rule), target path, and path feature reservation configuration.
In this embodiment, the state cache file at least includes the following attributes:
attribute 1, full-qualified name of the dependency that has been processed;
attribute 2, a list of matching paths of dependencies that have been processed;
attribute 3, the dependent path reservation configuration that has been processed.
The above attributes are arranged into a list, and the file with the extracted state can be used as a buffer memory by separating.
For the caller, after the plugin itself is introduced into the pon, a plurality of steps of configuration are needed to be automatically packaged by the life cycle system of Maven, and considering the development and production environments, the plugin is preferably packaged in the compiling process, and the copying process of the file is completed in the compiling process and the duplication is automatically removed. The method specifically comprises the following steps: introducing an insert; configuring all dependency items and file modes to be extracted; configuring plug-in trigger nodes generally recommends Maven's compilation process.
In a second embodiment, the operation flow chart of the Maven plugin is shown in fig. 3, and includes:
step 1, reading configuration: reading and checking the configuration file of the caller, wherein for each configuration item, a dependent item needs to be uniquely determined, but the file matching mode does not need to be checked;
step 2, reading cache: reading a state cache file and analyzing the state cache file into a list;
step 3, cross-comparing the cache and the configuration items, judging whether the change exists, and directly ending if the change does not exist;
step 4, picking out the configuration items with changes, and considering the performance problems of decompression and IO, only needing to process the configuration items with changes;
step 5, extraction operation: for each changed configuration item, analyzing out a relative path, extracting a matched file, and copying the matched file to a target path;
step 6, updating cache: and updating the configuration item of the time into a cache.
Therefore, in the multi-dependency file extraction method based on the Maven plugin provided by the embodiment, the Maven plugin is used for completing the extraction process, the dependency extraction is directly performed, and a third-party server/folder and the like are not introduced; defining the extracted source and target locations using a custom configuration; the state cache file is used to avoid repeated extraction and unnecessary extraction work; matching a plurality of files in a unified pattern using wild cards; allowing customization of whether a reservation of path features is required.
The following describes a Maven plug-in-based multi-dependency item file extraction device provided in the embodiments of the present application, where the Maven plug-in-based multi-dependency item file extraction device described below and the Maven plug-in-based multi-dependency item file extraction method described above may be referred to correspondingly.
As shown in fig. 4, the Maven plugin-based multi-dependency file extraction device includes:
configuration file acquisition module 401: the method comprises the steps that a configuration file of a Maven plug-in is obtained, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and is updated along with the update of the dependent item;
status cache file acquisition module 402: the method comprises the steps of obtaining a state cache file generated in a project compiling process, wherein the state cache file is used for describing extracted dependent items in a Jar package;
cross contrast module 403: the method comprises the steps of carrying out cross comparison on the configuration file and the state cache file, and judging whether a changed dependent item exists or not;
extraction module 404: if so, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
compiling module 405: for recompiling the item and updating the state cache file.
The Maven plugin-based multi-dependency file extraction apparatus of this embodiment is used to implement the foregoing Maven plugin-based multi-dependency file extraction method, so that the specific implementation in this apparatus may be found in the foregoing example portions of the Maven plugin-based multi-dependency file extraction method, for example, the configuration file obtaining module 401, the state cache file obtaining module 402, the cross comparison module 403, the extracting module 404, and the compiling module 405, which are respectively used to implement steps S101, S102, S103, S104, and S105 in the foregoing Maven plugin-based multi-dependency file extraction method. Therefore, the detailed description will be omitted herein with reference to the accompanying drawings, which illustrate examples of the respective parts.
In addition, since the Maven plugin-based multi-dependency item file extraction device of the present embodiment is used to implement the foregoing Maven plugin-based multi-dependency item file extraction method, the roles of the device correspond to those of the foregoing method, and the description thereof is omitted herein.
In addition, the application also provides a multi-dependency item file extraction device based on the Maven plugin, which comprises the following steps:
a memory: for storing a computer program;
a processor: for executing the computer program to implement the steps of the Maven plugin-based multi-dependency file extraction method as described above.
Finally, the present application provides a readable storage medium having stored thereon a computer program for implementing the steps of the Maven plugin-based multi-dependency file extraction method as described above when executed by a processor.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The foregoing has outlined rather broadly the more detailed description of the present application and the principles and embodiments of the present application have been presented in terms of specific examples, which are provided herein to assist in the understanding of the method and core concepts of the present application; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.
Claims (10)
1. A method for extracting a multi-dependency item file based on a Maven plugin is characterized by comprising the following steps:
acquiring a configuration file of a Maven plug-in, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and the configuration file is updated along with the update of the dependent item;
acquiring a state cache file generated in the project compiling process, wherein the state cache file is used for describing the extracted dependent items in the Jar package;
cross-comparing the configuration file and the state cache file, and judging whether a changed dependent item exists or not;
if so, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
recompilation of the item and updating of the state cache file.
2. The method of claim 1, wherein the obtaining a configuration file of a Maven plug-in, the configuration file describing an initial location and a target location of a dependent item, comprises:
and acquiring a configuration file of the Maven plugin, wherein the configuration file is used for describing the initial position and the target position of the dependent item, and the initial position comprises the full-limit name of the Jar package and the path description information of the file/folder.
3. The method of claim 2, wherein the full-qualified name comprises three elements: an ID of the development organization, an item ID, an item version number.
4. The method of claim 3, wherein the path description information of the file/folder includes a first wildcard representing any plurality of characters but not including subfolders, a second wildcard representing any plurality of characters and including subfolders, and a third wildcard representing a single character.
5. The method of claim 2, wherein the configuration file further comprises path reservation configuration information including reserved path features and unreserved path features.
6. The method of claim 1, wherein the cross-comparing the configuration file and the state cache file to determine whether a changed dependency exists comprises:
and cross-comparing the configuration file and the state cache file through an MD5 algorithm, and judging whether a changed dependent item exists or not.
7. The method of any one of claims 1-6, wherein the obtaining a configuration file of a Maven plug-in includes:
and when the triggering condition is met, acquiring a configuration file of the Maven plug-in, wherein the triggering condition is that a compiling instruction is received.
8. A Maven plugin-based multi-dependency item file extraction apparatus, comprising:
configuration file acquisition module: the method comprises the steps that a configuration file of a Maven plug-in is obtained, wherein the configuration file is used for describing the initial position and the target position of a dependent item, and is updated along with the update of the dependent item;
a state cache file acquisition module: the method comprises the steps of obtaining a state cache file generated in a project compiling process, wherein the state cache file is used for describing extracted dependent items in a Jar package;
and a cross comparison module: the method comprises the steps of carrying out cross comparison on the configuration file and the state cache file, and judging whether a changed dependent item exists or not;
and an extraction module: if so, reading the changed dependent item from the corresponding initial position according to the configuration file, and writing the changed dependent item into the corresponding target position;
and a compiling module: for recompiling the item and updating the state cache file.
9. A Maven plugin-based multi-dependency file extraction apparatus, comprising:
a memory: for storing a computer program;
a processor: steps for executing the computer program to implement a Maven plugin-based multi-dependency file extraction method according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program for implementing the steps of the Maven plugin based multi-dependency file extraction method according to any one of claims 1 to 7 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010680433.1A CN111897570B (en) | 2020-07-15 | 2020-07-15 | Multi-dependency item file extraction method and device based on Maven plug-in |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010680433.1A CN111897570B (en) | 2020-07-15 | 2020-07-15 | Multi-dependency item file extraction method and device based on Maven plug-in |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111897570A CN111897570A (en) | 2020-11-06 |
CN111897570B true CN111897570B (en) | 2024-04-12 |
Family
ID=73191214
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010680433.1A Active CN111897570B (en) | 2020-07-15 | 2020-07-15 | Multi-dependency item file extraction method and device based on Maven plug-in |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111897570B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112433719B (en) * | 2020-11-23 | 2023-09-01 | 广州虎牙科技有限公司 | Compiling method and device of application program, electronic equipment and storage medium |
CN112486470A (en) * | 2020-12-15 | 2021-03-12 | 恩亿科(北京)数据科技有限公司 | Method and system for automatically adjusting file window sequence based on file dependency relationship |
CN112596779A (en) * | 2020-12-16 | 2021-04-02 | 中国建设银行股份有限公司 | Dual-version-compatible dependency package generation method, device, equipment and storage medium |
CN112817598B (en) * | 2021-01-13 | 2024-06-25 | 浙江华云信息科技有限公司 | Code injection method for compiling period |
CN112799955B (en) * | 2021-02-08 | 2023-09-26 | 腾讯科技(深圳)有限公司 | Method and device for detecting model change, storage medium and electronic equipment |
CN113360140A (en) * | 2021-05-31 | 2021-09-07 | 武汉虹旭信息技术有限责任公司 | Configuration method and device based on Spring frame scaffold |
US12099834B2 (en) | 2021-07-23 | 2024-09-24 | Red Hat, Inc. | Patching software dependencies using external metadata |
CN115061741B (en) * | 2022-05-31 | 2024-06-14 | 北京奇艺世纪科技有限公司 | Target plug-in operation method and device, electronic equipment and storage medium |
CN114706918B (en) * | 2022-06-01 | 2022-09-16 | 杭州安恒信息技术股份有限公司 | Multi-type database compatibility method, device, equipment and storage medium |
CN117075956A (en) * | 2023-09-04 | 2023-11-17 | 上海易立德信息技术股份有限公司 | Configuration plug method and system applied to modularized project |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106155724A (en) * | 2015-04-14 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of upgrade method and device |
CN110109701A (en) * | 2019-05-14 | 2019-08-09 | 重庆商勤科技有限公司 | File configuration method, device and application dissemination method, device when using deployment |
CN110688137A (en) * | 2019-09-27 | 2020-01-14 | 支付宝(杭州)信息技术有限公司 | Application delivery method and device and storage medium |
CN111142903A (en) * | 2019-12-23 | 2020-05-12 | 杭州安恒信息技术股份有限公司 | Configuration file interactive updating method and device based on file comparison |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8813031B2 (en) * | 2012-03-02 | 2014-08-19 | Oracle International Corporation | System and method for automatically resolving dependencies of Java Archive files for use with Maven |
-
2020
- 2020-07-15 CN CN202010680433.1A patent/CN111897570B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106155724A (en) * | 2015-04-14 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of upgrade method and device |
CN110109701A (en) * | 2019-05-14 | 2019-08-09 | 重庆商勤科技有限公司 | File configuration method, device and application dissemination method, device when using deployment |
CN110688137A (en) * | 2019-09-27 | 2020-01-14 | 支付宝(杭州)信息技术有限公司 | Application delivery method and device and storage medium |
CN111142903A (en) * | 2019-12-23 | 2020-05-12 | 杭州安恒信息技术股份有限公司 | Configuration file interactive updating method and device based on file comparison |
Non-Patent Citations (2)
Title |
---|
基于Maven的J2ME项目管理插件的开发;胡永凯;左保河;;电脑与电信;20090310(03);全文 * |
用Maven简化你的项目管理;张俊;;程序员;20060901(09);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN111897570A (en) | 2020-11-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111897570B (en) | Multi-dependency item file extraction method and device based on Maven plug-in | |
CN107704382B (en) | Python-oriented function call path generation method and system | |
CN112394942B (en) | Distributed software development compiling method and software development platform based on cloud computing | |
Fouquet et al. | An eclipse modelling framework alternative to meet the models@ runtime requirements | |
US10514898B2 (en) | Method and system to develop, deploy, test, and manage platform-independent software | |
US11288062B2 (en) | Automatic source code refactoring | |
US11693635B1 (en) | Automatic code reconfiguration based on function and subfunction analysis | |
CN111158743B (en) | Big data operation and maintenance management platform | |
CN114356964A (en) | Data blood margin construction method and device, storage medium and electronic equipment | |
CN114138748A (en) | Database mapping file generation method, device, equipment and storage medium | |
CN103186463A (en) | Method and system for determining testing range of software | |
CN112395199B (en) | Distributed software instance testing method based on cloud computing and software development platform | |
US20240231811A9 (en) | Shrinking delta files based on function analysis | |
US20240231810A9 (en) | Symbol-matching between software versions | |
US20240231781A9 (en) | Shrinking files based on function analysis | |
CN111435312A (en) | Application program management method and device and electronic equipment | |
CN111522623B (en) | Modularized software multi-process running system | |
KR100834676B1 (en) | Method for building software project | |
CN111259042A (en) | Dynamic query method and system | |
CN115951916A (en) | Component processing method and device, electronic equipment and storage medium | |
CN118331588B (en) | Code library packaging method, program packaging method and device | |
US11941380B1 (en) | Automatic code reconfiguration based on function and subfunction analysis | |
CN117591136A (en) | Storage image generation method, device, computer equipment and storage medium | |
CN118708189A (en) | Code compiling method, device, computer equipment, storage medium and program product | |
CN115857962A (en) | Software project processing method and device, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |