[go: up one dir, main page]

CN106155724B - Upgrading method and device - Google Patents

Upgrading method and device Download PDF

Info

Publication number
CN106155724B
CN106155724B CN201510175039.1A CN201510175039A CN106155724B CN 106155724 B CN106155724 B CN 106155724B CN 201510175039 A CN201510175039 A CN 201510175039A CN 106155724 B CN106155724 B CN 106155724B
Authority
CN
China
Prior art keywords
link
dependent link
packet
pom
changed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510175039.1A
Other languages
Chinese (zh)
Other versions
CN106155724A (en
Inventor
蒋海忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510175039.1A priority Critical patent/CN106155724B/en
Publication of CN106155724A publication Critical patent/CN106155724A/en
Application granted granted Critical
Publication of CN106155724B publication Critical patent/CN106155724B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请提供了一种升级方法及装置,该方法包括:获取当前项目构建管理Maven工程的第一依赖链路,该第一依赖链路中包括待变更包;获取待变更包转换为升级包的映射规则;根据该映射规则修改该第一依赖链路,得到第二依赖链路。本申请通过预设映射规则,对第一依赖链路的待变更包进行修改得到第二依赖链路,实现了对初始依赖链路的自动升级,解决了在Maven工程中不能自动升级依赖链路的问题。

Figure 201510175039

The present application provides an upgrade method and device. The method includes: obtaining a first dependency link of a current project construction management Maven project, where the first dependency link includes a to-be-changed package; A mapping rule; modify the first dependent link according to the mapping rule to obtain a second dependent link. The present application modifies the to-be-changed package of the first dependency link to obtain the second dependency link through the preset mapping rules, realizes the automatic upgrade of the initial dependency link, and solves the problem that the dependency link cannot be automatically upgraded in the Maven project The problem.

Figure 201510175039

Description

一种升级方法及装置An upgrade method and device

技术领域technical field

本申请涉及计算机软件技术领域,尤其涉及一种升级方法及装置。The present application relates to the technical field of computer software, and in particular, to an upgrade method and device.

背景技术Background technique

Maven(项目构建管理)是基于POM(项目对象模型),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。Maven包括SNAPSHOT快照仓库和release发布仓库。SNAPSHOT快照仓库用于保存开发过程中的不稳定版本,release正式仓库则是用来保存稳定的发行版本。SNAPSHOT是个快照并有随时被更新覆盖的情况存在,导致容易发生线上故障,但有些Maven工程中会直接或者间接依赖SNAPSHOT包,这就需要对依赖链路进行去SNAPSHOT包的工作,即将依赖SNAPSHOT包的链路升级为依赖release包的链路。Maven (Project Build Management) is a software project management tool based on POM (Project Object Model) that can manage project builds, reports and documentation through a small piece of descriptive information. Maven includes SNAPSHOT snapshot repository and release release repository. The SNAPSHOT snapshot repository is used to store unstable versions during development, and the official release repository is used to store stable releases. SNAPSHOT is a snapshot and can be overwritten by updates at any time, which leads to online failures. However, some Maven projects will directly or indirectly depend on the SNAPSHOT package, which requires the work of removing the SNAPSHOT package for the dependency link, which will soon depend on SNAPSHOT. The link of the package is upgraded to the link that depends on the release package.

目前,如果要推动一个Maven工程进行去SNAPSHOT包的工作,开发方需要针对每个jar包一层层的推动上层业务去做变更,比如以下的链路A->B->C-SNAPSHOT->D->E-SNAPSHOT,对当前推动方A来说,他需要推动B不能依赖任何SNAPSHOT版本,也就意味着B需要推动业务方C去发布C’版本,同理C需要推动D,D需要推动E,及一层层推动业务方去升级release包,中间任何一个环节都缺一不可,直到整条链路变更SNAPSHOT包,得到一条升级链路。At present, if you want to promote a Maven project to remove the SNAPSHOT package, the developer needs to make changes to the upper-layer business for each jar package layer by layer, such as the following link A->B->C-SNAPSHOT-> D->E-SNAPSHOT, for the current promoter A, he needs to push B and cannot rely on any SNAPSHOT version, which means that B needs to push business party C to release C' version. Similarly, C needs to push D, and D needs to To promote E, and to push the business side to upgrade the release package layer by layer, any link in the middle is indispensable, until the entire link changes the SNAPSHOT package, and an upgrade link is obtained.

但由于Maven整条链路上会很长,可能有10甚至更多的节点存在,当前没有一个自动的方案可以解决去SNAPSHOT包过程,全部都是人工的变更,在升级依赖链路的时候,需要一层层的推动业务方去升级release包,沟通成本很大,解决问题也很复杂。However, since the entire Maven link will be very long and there may be 10 or more nodes, there is currently no automatic solution that can solve the process of removing the SNAPSHOT package, all of which are manual changes. When upgrading the dependent link, It is necessary to promote the business side to upgrade the release package layer by layer, the communication cost is high, and the problem solving is also very complicated.

发明内容SUMMARY OF THE INVENTION

本申请实施例提出了一种升级方法及装置,以解决现有技术中在Maven工程中不能自动升级依赖链路的技术问题。The embodiments of the present application propose an upgrade method and device to solve the technical problem in the prior art that the dependency link cannot be automatically upgraded in the Maven project.

本申请实施例提供了一种升级方法,包括:The embodiment of the present application provides an upgrade method, including:

获取当前项目构建管理Maven工程的第一依赖链路,该第一依赖链路中包括待变更包;Obtain the first dependency link of the current project construction management Maven project, where the first dependency link includes the package to be changed;

获取所述待变更的包转换为升级包的映射规则;obtaining a mapping rule for converting the package to be changed into an upgrade package;

根据该映射规则修改该第一依赖链路,得到第二依赖链路。Modify the first dependent link according to the mapping rule to obtain a second dependent link.

本申请实施例提供了一种升级装置,包括:The embodiment of the present application provides an upgrade device, including:

依赖链路获取模块,用于获取当前项目构建管理Maven工程的第一依赖链路,该第一依赖链路中包括待变更包;a dependency link obtaining module, used to obtain the first dependency link of the current project construction management Maven project, where the first dependency link includes the package to be changed;

依赖链路解析模块,用于获取所述待变更包转换为升级包的映射规则;A dependency link parsing module for obtaining the mapping rule for converting the to-be-changed package into an upgrade package;

依赖链路转换模块,用于根据所述映射规则,修改第一依赖链路,得到第二依赖链路。The dependent link conversion module is configured to modify the first dependent link according to the mapping rule to obtain the second dependent link.

有益效果如下:The beneficial effects are as follows:

由于本申请实施例所提供的技术方案通过解析当前Maven工程的依赖链路及待变更包的映射规则,根据映射规则对初始的依赖链路进行修改,从而得到稳定的依赖链路,实现了对初始依赖链路的升级,解决了在Maven工程中不能自动升级依赖链路的问题。Because the technical solution provided by the embodiments of the present application parses the dependency link of the current Maven project and the mapping rule of the package to be changed, and modifies the initial dependency link according to the mapping rule, thereby obtaining a stable dependency link and realizing the The upgrade of the initial dependency link solves the problem that the dependency link cannot be automatically upgraded in the Maven project.

附图说明Description of drawings

下面将参照附图描述本申请的具体实施例,其中:Specific embodiments of the present application will be described below with reference to the accompanying drawings, wherein:

图1示出了本申请实施例中一种升级方法实施的流程示意图;FIG. 1 shows a schematic flowchart of implementing an upgrade method in an embodiment of the present application;

图2示出了本申请实施例中又一种升级方法实施的流程示意图;FIG. 2 shows a schematic flowchart of implementing another upgrade method in an embodiment of the present application;

图3示出了本申请实施例中又一种升级方法实施的流程示意图;FIG. 3 shows a schematic flowchart of implementing another upgrade method in an embodiment of the present application;

图4示出了本申请实施例中一种升级装置的结构示意图;FIG. 4 shows a schematic structural diagram of an upgrading apparatus in an embodiment of the present application;

图5示出了本申请实施例中又一种升级装置的结构示意图。FIG. 5 shows a schematic structural diagram of another upgrading apparatus in an embodiment of the present application.

具体实施方式Detailed ways

为了使本申请的技术方案及优点更加清楚明白,以下结合附图对本申请的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本申请的一部分实施例,而不是所有实施例的穷举。并且在不冲突的情况下,本说明中的实施例及实施例中的特征可以互相结合。In order to make the technical solutions and advantages of the present application clearer, the exemplary embodiments of the present application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of them. Exhaustive list of examples. Also, the embodiments in this specification and the features of the embodiments may be combined with each other without conflict.

发明人在发明过程中注意到:在现有的Maven工程中,SNAPSHOT有随时被更新覆盖的情况存在,导致容易发生线上故障,而有些Maven工程中会直接或者间接依赖SNAPSHOT包,这就需要对依赖链路进行去SNAPSHOT包的工作,以升级现有的依赖链路。本实施例中提到的当前Maven工程是指系统当前正在执行的Maven工程。In the process of invention, the inventor noticed that in the existing Maven project, SNAPSHOT may be updated and covered at any time, which leads to online failures, and some Maven projects will directly or indirectly depend on the SNAPSHOT package, which requires Do SNAPSHOT package work on dependent links to upgrade existing dependent links. The current Maven project mentioned in this embodiment refers to the Maven project currently being executed by the system.

基于此,本申请实施例提出了一种升级方法及装置,下面进行说明。Based on this, the embodiments of the present application propose an upgrade method and device, which will be described below.

图1示出了本申请实施例提供的一种升级方法,如图1所示,包括:FIG. 1 shows an upgrade method provided by an embodiment of the present application, as shown in FIG. 1 , including:

步骤101、获取当前项目构建管理Maven工程的第一依赖链路,该第一依赖链路中包括待变更包;Step 101: Obtain the first dependency link of the current project construction management Maven project, where the first dependency link includes the package to be changed;

步骤102、获取待变更包转换为升级包的映射规则;Step 102, obtaining a mapping rule for converting the package to be changed into an upgrade package;

步骤103、根据该映射规则修改该第一依赖链路,得到第二依赖链路。Step 103: Modify the first dependent link according to the mapping rule to obtain a second dependent link.

本实施例中待变更包包括但不限于SNAPSHOT包,对此本实施例中不做具体限定。The package to be changed in this embodiment includes but is not limited to the SNAPSHOT package, which is not specifically limited in this embodiment.

在另一种可能的实施方式中,获取当前Maven工程的第一依赖链路关系,包括:In another possible implementation manner, the first dependency link relationship of the current Maven project is obtained, including:

通过Maven插件获取当前Maven工程的pom(项目对象模型)文件;Obtain the pom (project object model) file of the current Maven project through the Maven plugin;

解析所述pom文件,依次获取所述当前Maven工程的各个链路节点,得到所述当前Maven工程的第一依赖链路。Parse the pom file, sequentially acquire each link node of the current Maven project, and obtain the first dependency link of the current Maven project.

在另一种可能的实施方式中,所述获取将所述待变更包转换为升级包的映射规则,包括:In another possible implementation manner, the acquiring a mapping rule for converting the to-be-changed package into an upgrade package includes:

解析出所述第一依赖链路中的待变更包;Parse out the to-be-changed packet in the first dependency link;

获取所述待变更包的映射规则,所述映射规则包括:如果所述待变更包中包括预设后缀名,则将所述待变更的包的版本号的后缀名对应修改为升级包的后缀名,如果所述待变更包中不包括所述预设后缀名,则在所述待变更包后添加所述升级包的后缀名;Obtain the mapping rule of the package to be changed, where the mapping rule includes: if the package to be changed includes a preset suffix name, then correspondingly modify the suffix name of the version number of the package to be changed to the suffix of the upgrade package name, if the preset suffix name is not included in the to-be-changed package, then add the suffix name of the upgrade package after the to-be-changed package;

根据所述待变更包的映射规则,确认与所述待变更包对应的升级包的后缀名。Confirm the suffix name of the upgrade package corresponding to the to-be-changed package according to the mapping rule of the to-be-changed package.

在另一种可能的实施方式中,根据所述映射规则修改所述第一依赖链路,得到第二依赖链路,包括:In another possible implementation manner, modifying the first dependent link according to the mapping rule to obtain a second dependent link, including:

获取所述第一依赖链路关联的jar(归档文件)对应的pom文件;Obtain the pom file corresponding to the jar (archive file) associated with the first dependency link;

解析出所述jar对应的pom文件的属性列表,并将所述当前Maven工程的内置变量添加到所述属性列表中,所述当前Maven工程的内置变量包括:组织标识、项目标识和版本号;Parse out the property list of the pom file corresponding to the jar, and add the built-in variables of the current Maven project to the property list, where the built-in variables of the current Maven project include: organization ID, project ID, and version number;

根据所述映射规则修改所述jar对应的pom文件属性列表中的版本号,得到第二依赖链路。Modify the version number in the attribute list of the pom file corresponding to the jar according to the mapping rule to obtain a second dependency link.

在另一种可能的实施方式中,根据所述映射规则修改所述jar对应的pom文件属性列表中的版本号,得到第二依赖链路之前,还包括:In another possible implementation manner, before the second dependency link is obtained by modifying the version number in the attribute list of the pom file corresponding to the jar according to the mapping rule, the method further includes:

获取所述第一依赖链路关联的jar对应的pom文件的所有父pom列表;Obtain all parent pom lists of the pom file corresponding to the jar associated with the first dependency link;

判断是否有需要修改的父pom列表,如果是,则根据所述映射规则修改所述需要修改的父pom列表下每个pom文件属性列表中的版本号。Determine whether there is a parent pom list that needs to be modified, and if so, modify the version number in the attribute list of each pom file under the parent pom list that needs to be modified according to the mapping rule.

在另一种可能的实施方式中,所述方法还包括:In another possible implementation, the method further includes:

验证所述第二依赖链路的MD5(Message Digest Algorithm,消息摘要算法第五版)值与所述第一链路的MD5值是否相同,如果是,则将所述第二依赖链路存储到Maven仓库中。Verify whether the MD5 (Message Digest Algorithm, Message Digest Algorithm Version 5) value of the second dependent link is the same as the MD5 value of the first link, and if so, store the second dependent link in the in the Maven repository.

在另一种可能的实施方式中,验证所述第二依赖链路的MD5值与所述第一链路的MD5值是否相同,包括:In another possible implementation manner, verifying whether the MD5 value of the second dependent link is the same as the MD5 value of the first link includes:

获取所述第一依赖链路中需要修改的jar,计算所述第一链路中需要修改的jar的第一MD5值;Obtain the jar that needs to be modified in the first dependency link, and calculate the first MD5 value of the jar that needs to be modified in the first link;

获取所述第二依赖链路中对应所述第一依赖链路中修改的jar,计算所述第二链路中对应所述第一依赖链路中修改后的jar的第二MD5值;Obtain the jar in the second dependency link corresponding to the modification in the first dependency link, and calculate the second MD5 value of the second link corresponding to the modified jar in the first dependency link;

判断所述第一MD5值与所述第二MD5值是否相同,如果是,则确认所述第二依赖链路的MD5值与所述第一链路的MD5值相同。Determine whether the first MD5 value is the same as the second MD5 value, and if so, confirm that the MD5 value of the second dependent link is the same as the MD5 value of the first link.

有益效果:本申请实施例所提供的技术方案通过解析当前Maven工程的依赖链路及待变更包的映射规则,根据映射规则对初始的依赖链路进行修改,从而得到稳定的依赖链路,实现了对初始依赖链路的升级,解决了在Maven工程中不能自动升级依赖链路的问题。Beneficial effect: The technical solution provided by the embodiment of the present application analyzes the dependency link of the current Maven project and the mapping rule of the package to be changed, and modifies the initial dependency link according to the mapping rule, thereby obtaining a stable dependency link and realizing It upgrades the initial dependency link and solves the problem that the dependency link cannot be automatically upgraded in the Maven project.

参见图2,本申请的又一实施例中提供了一种升级方法,该实施例在上述实施例的基础上给出了一个具体的实施方式,在执行当前Maven工程时,可以自动执行如下步骤,无需人工参与。如图2所示,该方法包括:Referring to FIG. 2, another embodiment of the present application provides an upgrade method. This embodiment provides a specific implementation based on the above-mentioned embodiment. When executing the current Maven project, the following steps can be automatically executed , without human involvement. As shown in Figure 2, the method includes:

步骤201、获取当前Maven工程的第一依赖链路。Step 201: Obtain the first dependency link of the current Maven project.

本实施例中,设置Maven插件,在执行Maven工程时,调用该插件,通过该插件解析出当前Maven工程的pom文件(即pom.xml文件),然后依次获取当前Maven工程的各个链路节点,得到当前Maven工程的第一依赖链路。具体方法包括:In this embodiment, a Maven plug-in is set, and when the Maven project is executed, the plug-in is called, and the pom file (that is, the pom.xml file) of the current Maven project is parsed through the plug-in, and then each link node of the current Maven project is obtained in turn, Get the first dependency link of the current Maven project. Specific methods include:

步骤1)通过Maven插件获取当前Maven工程的pom文件;Step 1) Obtain the pom file of the current Maven project through the Maven plugin;

步骤2)解析该pom文件,获取当前Maven工程依赖的第1节点;Step 2) Parse the pom file to obtain the first node that the current Maven project depends on;

步骤3)通过Maven插件对该第1节点进行解析,获得所述第1节点的解析结果;Step 3) parsing the first node through the Maven plug-in to obtain the parsing result of the first node;

步骤4)判断该解析结果中是否有第1节点的依赖节点,如果没有,则将该第1节点做为当前Maven工程的最后一个依赖节点,如果有,则将该第1节点的依赖节点作为第1节点,重复执行步骤3)-4),直到找到当前Maven工程的最后一个依赖节点,得到当前Maven工程的第一依赖链路。Step 4) Determine whether there is a dependent node of the first node in the analysis result. If not, then the first node is used as the last dependent node of the current Maven project. If there is, then the first node is used as the dependent node. For the first node, repeat steps 3)-4) until the last dependency node of the current Maven project is found, and the first dependency link of the current Maven project is obtained.

其中,pom文件是Maven项目中的文件。在一个Maven工程中,不仅仅是一堆包含代码的文件,还包含pom文件,该文件用于管理:源代码、配置文件、开发者的信息和角色、问题追踪系统、组织标识、项目授权、项目的依赖关系等等,此处与现有技术中对pom文件的描述一致,在此本实施例中不再赘述。where the pom file is the file in the Maven project. In a Maven project, not just a bunch of files containing code, but also pom files, which are used to manage: source code, configuration files, developer information and roles, issue tracking system, organization identification, project authorization, The dependencies of the project, etc., are consistent with the description of the pom file in the prior art, and are not repeated in this embodiment.

由于pom文件中存储有项目的依赖关系,所以通过对Maven工程中pom文件的解析,就能够得出该工程的依赖关系,一个jar(归档文件)一条数据链路,每个节点的数据形式以GroupId(组织标识):artifactId(项目标识):Version(版本号)组合,比如链路:Since the dependencies of the project are stored in the pom file, the dependencies of the project can be obtained by parsing the pom file in the Maven project, one jar (archive file) and one data link. The data of each node is in the form of GroupId (organization ID): artifactId (project ID): Version (version number) combination, such as link:

com.tmall:sak-app:war:1.0-SNAPSHOT->com.tmall:sak-biz-common:jar:1.0-SNAPSHOT->com.taobao.carts:carts-client:jar:1.0.13->com.taobao.trade:tradebase:jar:1.0.37->com.taobao.trade.platform:tp-client:jar:1.4.32->com.taobao.misccenter:misccenter-client:jar:1.5.3.2_ladder-SNAPSHOT->com.taobao.tradesecurity:ts-client:jar:1.0.1-SNAPSHOT->com.taobao.sharereport:share-report-common:jar:1.5.1-SNAPSHOT。com.tmall:sak-app:war:1.0-SNAPSHOT->com.tmall:sak-biz-common:jar:1.0-SNAPSHOT->com.taobao.carts:carts-client:jar:1.0.13->com .taobao.trade:tradebase:jar:1.0.37->com.taobao.trade.platform:tp-client:jar:1.4.32->com.taobao.misccenter:misccenter-client:jar:1.5.3.2_ladder- SNAPSHOT->com.taobao.tradesecurity:ts-client:jar:1.0.1-SNAPSHOT->com.taobao.sharereport:share-report-common:jar:1.5.1-SNAPSHOT.

其中,com.tmall:sak-app:war:1.0-SNAPSHOT、com.tmall:sak-biz-common:jar:1.O-SNAPSHOT、com.taobao.trade:tradebase:jar:1.0.37等为依赖链路中的节点,其中包含SNAPSHOT的包是待变更包。在具体解析的过程中,通过Maven插件获取当前工程的pom文件,从该文件中解析出第1个节点com.tmall:sak-app:war:1.0-SNAPSHOT,然后对该节点进行解析,对解析结果进行分析,确认是否有该节点的依赖节点,如解析出该节点的依赖节点为com.tmall:sak-biz-common:jar:1.0-SNAPSHOT,则继续对该节点进行解析,直到解析到com.taobao.sharereport:share-report-common:jar:1.5.1-SNAPSHOT节点,发现其没有后续依赖节点,则完成依赖链路的解析,得到如上的依赖节点。Among them, com.tmall: sak-app: war: 1.0-SNAPSHOT, com.tmall: sak-biz-common: jar: 1.O-SNAPSHOT, com.taobao.trade: tradebase: jar: 1.0.37, etc. are dependencies The node in the link, the packet containing SNAPSHOT is the packet to be changed. In the specific parsing process, the pom file of the current project is obtained through the Maven plug-in, the first node com.tmall:sak-app:war:1.0-SNAPSHOT is parsed from the file, and then the node is parsed to parse the Analyze the result to confirm whether there is a dependent node of the node. If the dependent node of the node is com.tmall:sak-biz-common:jar:1.0-SNAPSHOT, continue to parse the node until it resolves to com .taobao.sharereport: share-report-common: jar: 1.5.1-SNAPSHOT node, if it is found that there is no subsequent dependent node, the analysis of the dependency link is completed, and the above dependent node is obtained.

另外,值得注意的是,本实施例中一个jar对应一条依赖链路,如果当前Maven工程只包含一个jar,则第一依赖链路包括一条,但是如果当前Maven工程包括多个jar,则第一依赖链路指代多条,每条链路均执行如下步骤,对此本实施例中不再赘述。In addition, it is worth noting that in this embodiment, one jar corresponds to one dependency link. If the current Maven project contains only one jar, the first dependency link includes one, but if the current Maven project includes multiple jars, the first dependency link is Dependent links refer to multiple links, and each link performs the following steps, which are not repeated in this embodiment.

步骤202、获取待变更包转换为升级包的映射规则。Step 202: Obtain a mapping rule for converting the package to be changed into an upgrade package.

具体应用中,会对于不同的待变更包可以预先设定多个映射规则,包括:如果所述待变更包中包括预设后缀名,则将所述待变更的包的版本号的后缀名对应修改为升级包的后缀名,如果所述待变更包中不包括所述预设后缀名,则在所述待变更包后添加所述升级包的后缀名。例如,每个工程的SNAPSHOT包转release包都统一有如下规则,version以-SNSPSHOT结尾的,将-SNAPSHOT改为-mysuffix,如果version以.SNAPSHOT结尾的,那统一将.SNAPSHOT改为-mysuffix,其他的统一追加-mysuffix,比如version为2.0.0,那么改后的版本为2.0.0-mysuffix。对于其他类型的待变更包也可以设置其他对应的映射规则,其中映射规则可以存储在Maven仓库中,也可以单独创建文件家存储,对此本实施例中不做具体限定。In a specific application, multiple mapping rules may be preset for different packages to be changed, including: if the package to be changed includes a preset suffix name, corresponding to the suffix name of the version number of the package to be changed The suffix name of the upgrade package is modified. If the preset suffix name is not included in the to-be-changed package, the suffix name of the upgrade package is added after the to-be-changed package. For example, each project's SNAPSHOT package has the following rules to be converted into a release package. If the version ends with -SNSPSHOT, change -SNAPSHOT to -mysuffix. If the version ends with .SNAPSHOT, then change .SNAPSHOT to -mysuffix. For other uniforms, add -mysuffix. For example, if the version is 2.0.0, then the changed version is 2.0.0-mysuffix. For other types of packages to be changed, other corresponding mapping rules may also be set, wherein the mapping rules may be stored in a Maven repository, or a file home storage may be created separately, which is not specifically limited in this embodiment.

本步骤中,在获取到第一链路后,解析出第一链路中的待变更包,在多个映射规则中找到与该待变更包对应的映射规则,根据其对应的映射规则,确认与其对应的升级包的后缀名,如与SNAPSHOT包对应的升级包为release包,解析出升级包的后缀名,对应存储待变更包与其对应的升级包的映射规则。In this step, after the first link is acquired, the packet to be changed in the first link is parsed, the mapping rule corresponding to the to-be-changed packet is found in a plurality of mapping rules, and the confirmation is confirmed according to the corresponding mapping rule. The suffix name of the corresponding upgrade package. For example, the upgrade package corresponding to the SNAPSHOT package is a release package. The suffix name of the upgrade package is parsed, and the mapping rule for storing the to-be-changed package and its corresponding upgrade package is stored.

本实施例中通过修改后缀名,将待变更不稳定包转换为稳定包,这样即使有新的不稳定包时,修改过后缀名的包也不会被覆盖,从而保证了链路的稳定性。In this embodiment, the unstable packet to be changed is converted into a stable packet by modifying the suffix name, so that even if there is a new unstable packet, the packet whose suffix name has been modified will not be overwritten, thus ensuring the stability of the link .

值得注意的是,在本步骤中,只是获取对应修改的映射规则,不具体执行包的修改。且本实施例中以去SNAPSHOT包,将其转换为release包为例,但在不同的应用场景下,并不局限于此一种实施方式,在其它实施方式中对应的映射规则也可不同,本实施例对此不做具体限定。It is worth noting that in this step, only the mapping rule corresponding to the modification is obtained, and the modification of the package is not specifically performed. And in this embodiment, the SNAPSHOT package is removed and converted into a release package as an example, but in different application scenarios, it is not limited to this implementation, and the corresponding mapping rules in other implementations may also be different, This embodiment does not specifically limit this.

步骤203、获取第一依赖链路关联的jar对应的pom的所有父pom列表,判断是否有需要修改的父pom列表,如果是,则执行步骤204,否则执行步骤205。Step 203: Obtain all parent pom lists of the poms corresponding to the jars associated with the first dependency link, and determine whether there is a parent pom list that needs to be modified. If yes, go to step 204, otherwise go to step 205.

本实施例中,如果存在多条依赖链路,则遍历依赖链路中的每个jar的pom文件,获取当前jar对应的pom的所有父pom列表,其中父pom列表的形式为GroupId:artifactId:version。确认父pom列表中是否有待变更包,如SNAPSHOT包,如果有,则确认该父pom列表需要修改,如果没有待变更包,则不需要修改。In this embodiment, if there are multiple dependency links, the pom file of each jar in the dependency link is traversed to obtain all parent pom lists of the pom corresponding to the current jar, where the parent pom list is in the form of GroupId:artifactId: version. Check whether there are packages to be changed in the parent pom list, such as the SNAPSHOT package. If so, confirm that the parent pom list needs to be modified. If there are no packages to be changed, no modification is required.

步骤204、根据映射规则修改需要修改的父pom列表下每个pom文件属性列表中的版本号。Step 204: Modify the version number in the attribute list of each pom file under the parent pom list to be modified according to the mapping rule.

本步骤中,获取需要修改的父pom列表下的所有pom文件,解析出每个pom文件的属性列表,并将当前Maven工程的内置变量添加到该属性列表中。具体的,对于需要修改的父pom列表,从顶层pom依次往下遍历,获取每个pom的properties(属性列表),元素为//project/prperties,并将Maven工程自带的内置变量追加到该属性列表中,比如${project.groupId},${project.artifactid},${project.version}等。In this step, obtain all pom files under the parent pom list to be modified, parse out the property list of each pom file, and add the built-in variables of the current Maven project to the property list. Specifically, for the list of parent poms that need to be modified, traverse down from the top-level pom to obtain the properties (property list) of each pom, the element is //project/properties, and append the built-in variables that come with the Maven project to the In the property list, such as ${project.groupId}, ${project.artifactid}, ${project.version}, etc.

值得注意的是,在添加变量值之后,需要将该变量依次解析为常量值,具体的解析过程与现有技术中一样,本实施例中不再赘述。It is worth noting that after adding a variable value, the variable needs to be parsed into constant values in sequence, and the specific parsing process is the same as that in the prior art, which is not repeated in this embodiment.

依据解析出来属性列表,变更当前pom文件中的version,其中version的变更按照步骤202中获取的映射规则进行替换,即将version以-SNSPSHOT结尾的,将-SNAPSHOT改为-mysuffix,如果version以.SNAPSHOT结尾的,那统一将.SNAPSHOT改为-mysuffix,其他的统一追加-mysuffix。According to the parsed attribute list, change the version in the current pom file, where the version change is replaced according to the mapping rule obtained in step 202, that is, if the version ends with -SNSPSHOT, change -SNAPSHOT to -mysuffix, if the version ends with .SNAPSHOT At the end, change .SNAPSHOT to -mysuffix, and add -mysuffix to others.

在一种可能的实施例中,GroupId可以从父pom里继承过来,也就是说,如果一个当前pom它有一个父pom,那么这个当前pom是不需要定义GroupId的,因为GroupId会从父pom继承过来。那么在修改当前pom的时候,如果发现GroupId是空的,为了使流程更清晰,可选地,在当前pom中添加其对应的父pom的GroupId。因此在对当前pom文件进行变更时,如遇到上述情况,可依次变更pom文件中的如下三个元素<groupId>,<artifacfId>,<version>。其中,<artifactId>是不需要修改的,直接保留,可能修改的为<groupId>,必须修改的为<version>。In a possible embodiment, GroupId can be inherited from parent pom, that is, if a current pom has a parent pom, then this current pom does not need to define GroupId, because GroupId will be inherited from parent pom come over. Then when modifying the current pom, if the GroupId is found to be empty, in order to make the process clearer, optionally, add the GroupId of the corresponding parent pom to the current pom. Therefore, when changing the current pom file, if the above situation is encountered, the following three elements <groupId>, <artifacfId>, <version> in the pom file can be changed in sequence. Among them, <artifactId> does not need to be modified, and is directly reserved. The one that may be modified is <groupId>, and the one that must be modified is <version>.

值得注意的是,本实施例中步骤203-204是可选地,在实际执行过程中可以不对父pom列表进行修改,而直接执行步骤205,对此本实施例中不做具体限定。It is worth noting that steps 203-204 in this embodiment are optional, and the parent pom list may not be modified in the actual execution process, but step 205 is directly executed, which is not specifically limited in this embodiment.

步骤205、获取第一依赖链路关联的jar对应的pom文件,获取该pom文件的属性列表,根据映射规则修改该pom文件属性列表中的版本号,得到第二依赖链路。Step 205: Obtain the pom file corresponding to the jar associated with the first dependency link, obtain the attribute list of the pom file, and modify the version number in the attribute list of the pom file according to the mapping rule to obtain the second dependency link.

具体的,获取第一依赖链路关联的jar对应的pom文件的属性列表的方法与获取父pom列表下pom文件的方法类似,包括:解析出该pom文件的属性列表,并将当前Maven工程的内置变量添加到所述属性列表中,当前Maven工程的内置变量包括:组织标识、项目标识和版本号。Specifically, the method of obtaining the attribute list of the pom file corresponding to the jar associated with the first dependency link is similar to the method of obtaining the pom file under the parent pom list, including: parsing out the attribute list of the pom file, and retrieving the attribute list of the current Maven project Built-in variables are added to the property list, and the built-in variables of the current Maven project include: organization ID, project ID, and version number.

本步骤中,依据解析出来属性列表,依次变更<groupId>,<artifactId>,<version>,其中version的变更按照步骤202中获取的映射规则进行替换此处与父pom列表下pom文件的修改类似,对此本实施例中不再赘述。In this step, according to the parsed attribute list, change <groupId>, <artifactId>, <version> in sequence, wherein the change of version is replaced according to the mapping rule obtained in step 202. This is similar to the modification of the pom file under the parent pom list. , which will not be repeated in this embodiment.

如步骤201中示范的链路,升级后转换为com.tmall:sak-app:war:1.0-mysuffix->com.tmall:sak-biz-common:jar:1.0-mysuffix->com.taobao.carts:carts-client:jar:1.0.13-mysuffix->com.taobao.trade:tradebase:jar:1.0.37-mysuffix->com.taobao.trade.platform:tp-client:jar:1.4.32-mysuffix->com.taobao.misccenter:misccenter-client:jar:1.5.3.2_ladder-mysuffix->com.taobao.tradesecurity:ts-client:jar:1.0.1-mysuffix->com.taobao.sharereport:share-report-common:jar:1.5.1-mysuffix。As the link demonstrated in step 201, it is converted to com.tmall:sak-app:war:1.0-mysuffix->com.tmall:sak-biz-common:jar:1.0-mysuffix->com.taobao.carts after the upgrade :carts-client:jar:1.0.13-mysuffix->com.taobao.trade:tradebase:jar:1.0.37-mysuffix->com.taobao.trade.platform:tp-client:jar:1.4.32-mysuffix ->com.taobao.misccenter:misccenter-client:jar:1.5.3.2_ladder-mysuffix->com.taobao.tradesecurity:ts-client:jar:1.0.1-mysuffix->com.taobao.sharereport:share-report -common:jar:1.5.1-mysuffix.

在本实施例中,如果依赖链路中的某个节点中不包括待变更包,则不需要要进行转换。如,依赖链路为A->B->C-SNAPHOST->D->E-SNAPSHOT->F->G,那么最终产生的结果会有如下几个包:A-mysuffix->B-mysuffix->C-mysuffix->D-mysuffix->E-mysuffix->F->G。其中A,B,C,D,E生成了新的5个包,F,G因为后面没有依赖任何的SNAPSHOT版本,所以不需要生成新的包。In this embodiment, if a node in the dependent link does not include the to-be-changed packet, no conversion is required. For example, if the dependent link is A->B->C-SNAPHOST->D->E-SNAPSHOT->F->G, then the final result will have the following packages: A-mysuffix->B-mysuffix ->C-mysuffix->D-mysuffix->E-mysuffix->F->G. Among them, A, B, C, D, and E generate 5 new packages, and F and G do not need to generate new packages because they do not depend on any SNAPSHOT version later.

有益效果:本实施例通过解析当前Maven工程的依赖链路及待变更包映射规则,根据映射规则对初始的依赖链路进行修改,从而得到稳定的依赖链路,实现了对初始依赖链路的升级,解决了在Maven工程中不能自动升级依赖链路的问题。Beneficial effect: In this embodiment, by analyzing the dependency link of the current Maven project and the mapping rule of the package to be changed, and modifying the initial dependency link according to the mapping rule, a stable dependency link is obtained, and the initial dependency link is realized. Upgrade, which solves the problem that dependency links cannot be automatically upgraded in Maven projects.

参见图3,本申请的又一实施例中提供了一种升级方法,该方法是对图2所示的实施例的实施细节的具体优化,如图3所示,该方法包括:Referring to FIG. 3 , another embodiment of the present application provides an upgrade method, which is a specific optimization of the implementation details of the embodiment shown in FIG. 2 . As shown in FIG. 3 , the method includes:

步骤301、获取当前Maven工程的第一依赖链路,将该依赖链路的相关信息存储到第一文件夹中。Step 301: Obtain the first dependency link of the current Maven project, and store the relevant information of the dependency link in a first folder.

在实际应用中,为了便于对依赖链路的后续处理,创建相应文件夹,将解析出来的链路输出到第一文件夹中,如输出到dependency.1ist文件中,对文件夹的具体命名本实施例中不做具体限定。其中依赖链路的具体解析过程同上述实施例中的步骤201类似,对此本实施例中不再赘述。In practical applications, in order to facilitate the subsequent processing of the dependency link, create a corresponding folder, and output the parsed link to the first folder, such as outputting to the dependency.1ist file, the specific naming of the folder. There is no specific limitation in the embodiment. The specific parsing process of the dependent link is similar to step 201 in the foregoing embodiment, which is not repeated in this embodiment.

步骤302、对第一依赖链路进行解析,得到将该需要变更的包转换为升级包的映射规则,并将该映射规则存储到第二文件夹中。Step 302: Analyze the first dependency link to obtain a mapping rule for converting the package to be changed into an upgrade package, and store the mapping rule in the second folder.

本步骤中获取映射规则的步骤与上述实施例中的步骤202类似,对此本实施例中不再赘述。在获取到映射规则后,将该规则单独存储到第二文件夹中,如jarRulesMap文件中。The step of acquiring the mapping rule in this step is similar to step 202 in the foregoing embodiment, which is not repeated in this embodiment. After the mapping rule is acquired, the rule is separately stored in the second folder, such as the jarRulesMap file.

步骤303、获取第一依赖链路关联的jar对应的pom的所有父pom列表,将所有的父pom列表存储到第三文件夹中。Step 303: Obtain all parent pom lists of the pom corresponding to the jar associated with the first dependency link, and store all parent pom lists in a third folder.

本实施例中,如果存在多条依赖链路,则遍历依赖链路中的每个jar的pom文件,获取当前jar对应的pom的所有父pom列表,其中父pom列表的形式为Groupid:artifactId:version,同时将该父pom列表以Groupid:artifactId:version的数据形式存储到第三文件夹中,如parentPomList中。In this embodiment, if there are multiple dependency links, the pom file of each jar in the dependency link is traversed to obtain all parent pom lists of the pom corresponding to the current jar, where the parent pom list is in the form of Groupid:artifactId: version, and store the parent pom list in the data form of Groupid:artifactId:version in the third folder, such as parentPomList.

步骤304、遍历第三文件夹中的父列表,判断是否有需要修改的父pom列表,如果是,则执行步骤305,否则执行步骤306。Step 304 , traverse the parent list in the third folder to determine whether there is a parent pom list that needs to be modified, if yes, go to step 305 , otherwise go to step 306 .

确认父pom列表中是否有待变更包,如SNAPSHOT包,如果有,则确认该父pom列表需要修改,如果没有待变更包,则不需要修改。Check whether there are packages to be changed in the parent pom list, such as the SNAPSHOT package. If so, confirm that the parent pom list needs to be modified. If there are no packages to be changed, no modification is required.

步骤305、根据映射规则修改需要修改的父pom列表下每个pom文件属性列表中的版本号。Step 305: Modify the version number in the attribute list of each pom file under the parent pom list to be modified according to the mapping rule.

步骤306、获取第一依赖链路关联的jar对应的pom文件,获取该pom文件的属性列表,根据映射规则修改该pom文件属性列表中的版本号,得到第二依赖链路。Step 306: Obtain the pom file corresponding to the jar associated with the first dependency link, obtain the attribute list of the pom file, and modify the version number in the attribute list of the pom file according to the mapping rule to obtain the second dependency link.

上述本步骤305-306与图2所示实施例中的步骤204-205类似,对此本实施例中不再赘述。The foregoing steps 305 to 306 are similar to the steps 204 to 205 in the embodiment shown in FIG. 2 , which will not be repeated in this embodiment.

步骤307、验证第二依赖链路的MD5值与第一链路的MD5值是否相同,如果是,则执行步骤308,否则,返回步骤301。Step 307 , verify whether the MD5 value of the second dependent link is the same as the MD5 value of the first link, if so, go to Step 308 , otherwise, return to Step 301 .

本步骤中,优选地,验证第二依赖链路的MD5值与第一链路的MD5值是否相同,包括:获取所述第一依赖链路中需要修改的jar,计算所述第一链路中需要修改的jar的第一MD5值;获取所述第二依赖链路中对应所述第一依赖链路中修改的jar,计算所述第二链路中对应所述第一依赖链路中修改后的jar的第二MD5值;判断所述第一MD5值与所述第二MD5值是否相同,如果是,则确认所述第二依赖链路的MD5值与所述第一链路的MD5值相同。In this step, preferably, verifying whether the MD5 value of the second dependent link is the same as the MD5 value of the first link includes: acquiring the jar that needs to be modified in the first dependent link, calculating the first link The first MD5 value of the jar that needs to be modified in the The second MD5 value of the modified jar; determine whether the first MD5 value is the same as the second MD5 value, and if so, confirm that the MD5 value of the second dependent link is the same as the first link's MD5 value. MD5 values are the same.

本实施例中,对于不包含待变更包的节点不需进行修改,所以在进行验证时,只需对第一依赖链路中修改的jar进行验证,如依赖链路为A->B->C-SNAPHOST->D->E-SNAPSHOT->F->G,修改后的得到第二依赖链路为A-mysuffix->B-mysuffix->C-mysuffix->D-mysuffix->E-mysuffix->F->G。其中A,B,C,D,E生成了新的5个包,F,G因为后面没有依赖任何的SNAPSHOT版本,所以不需要对F,G进行验证,只需验证A,B,C,D,E的MD5值在第一链路中和第二链路中是否相同。In this embodiment, the node that does not contain the package to be changed does not need to be modified, so when verifying, only the modified jar in the first dependency link needs to be verified, for example, the dependency link is A->B-> C-SNAPHOST->D->E-SNAPSHOT->F->G, the modified second dependency link is A-mysuffix->B-mysuffix->C-mysuffix->D-mysuffix->E- mysuffix->F->G. Among them, A, B, C, D, E generate new 5 packages, F, G do not need to verify F, G because they do not depend on any SNAPSHOT version later, just verify A, B, C, D , whether the MD5 value of E is the same in the first link and the second link.

在其他的可能实施方式中,也可以采用现有技术中的回归验证方法对第一依赖链路和第二依赖链路进行验证,对此本实施例不做具体限定。In other possible implementations, the regression verification method in the prior art may also be used to verify the first dependent link and the second dependent link, which is not specifically limited in this embodiment.

在验证结果错误时,可以弹出错误指示,提示开发人员重行执行步骤301-307,当然也可以不弹出错误指示,直接返回执行步骤301,对此本实施例中不再赘述。When the verification result is wrong, an error indication may be popped up, prompting the developer to perform steps 301-307 again, of course, the error indication may not be popped up, and the execution of step 301 may be directly returned, which will not be repeated in this embodiment.

步骤308、将第二依赖链路存储到Maven仓库中。Step 308: Store the second dependency link in the Maven repository.

本实施例中,为了提高效率,减少代码执行的复杂性,在得到升级后的第二依赖链路后,将该依赖链路存储到Maven仓库中,这样在其他Maven工程包含该条链路时,就不需要重新升级,可以直接调用。In this embodiment, in order to improve efficiency and reduce the complexity of code execution, after the upgraded second dependency link is obtained, the dependency link is stored in the Maven repository, so that when other Maven projects include this link , you don't need to re-upgrade, you can call it directly.

有益效果:本实施例通过解析当前Maven工程的依赖链路及待变更包映射规则,根据映射规则对初始的依赖链路进行修改,从而得到稳定的依赖链路,实现了对初始依赖链路的升级,解决了在Maven工程中不能自动升级依赖链路的问题。另外本实施例中通过文件夹对链路转换的中间数据进行管理,明确了中间数据的识别路径,提高了链路升级的执行效率。另一方面,通过升级链路jar的MD5值,就能够对升级链路进行验证,提升了线上风险的可控性。Beneficial effect: In this embodiment, by analyzing the dependency link of the current Maven project and the mapping rule of the package to be changed, and modifying the initial dependency link according to the mapping rule, a stable dependency link is obtained, and the initial dependency link is realized. Upgrade, which solves the problem that dependency links cannot be automatically upgraded in Maven projects. In addition, in this embodiment, the intermediate data converted by the link is managed through a folder, the identification path of the intermediate data is clarified, and the execution efficiency of the link upgrade is improved. On the other hand, by upgrading the MD5 value of the link jar, the upgrade link can be verified, which improves the controllability of online risks.

基于同一发明构思,本申请实施例中还提供了一种升级装置,由于该装置解决问题的原理与一种升级方法相似,因此这些装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiments of the present application also provide an upgrade apparatus. Since the principle of the apparatus for solving problems is similar to that of an upgrade method, the implementation of these apparatuses can be referred to the implementation of the method, and repeated descriptions will not be repeated.

如图4所示,装置可以包括:依赖链路获取模块401,依赖链路解析模块402,依赖链路转换模块403。As shown in FIG. 4 , the apparatus may include: a dependent link acquiring module 401 , a dependent link parsing module 402 , and a dependent link converting module 403 .

依赖链路获取模块401,用于获取当前项目构建管理Maven工程的第一依赖链路,所述第一依赖链路中包括待变更包;The dependency link obtaining module 401 is used to obtain the first dependency link of the current project construction management Maven project, and the first dependency link includes the package to be changed;

依赖链路解析模块402,用于获取所述待变更包转换为升级包的映射规则;A dependency link parsing module 402, configured to obtain a mapping rule for converting the to-be-changed package into an upgrade package;

依赖链路转换模块403,用于根据所述映射规则,修改所述第一依赖链路,得到第二依赖链路。The dependent link conversion module 403 is configured to modify the first dependent link according to the mapping rule to obtain a second dependent link.

参见图5,在另一种可能的实施方式中,所述依赖链路获取模块401,包括:Referring to FIG. 5, in another possible implementation manner, the dependent link obtaining module 401 includes:

第一获取单元401a,用于通过Maven插件获取当前Maven工程的项目对象模型pom文件;The first obtaining unit 401a is used to obtain the project object model pom file of the current Maven project through the Maven plug-in;

第一解析单元401b,用于解析所述pom文件,依次获取所述当前Maven工程的各个链路节点,得到所述当前Maven工程的第一依赖链路。The first parsing unit 401b is configured to parse the pom file, obtain each link node of the current Maven project in sequence, and obtain the first dependency link of the current Maven project.

参见图5,在另一种可能的实施方式中,所述依赖链路解析模块402,包括:Referring to FIG. 5, in another possible implementation manner, the dependency link parsing module 402 includes:

第二解析单元402a,用于解析出所述第一依赖链路中的待变更包;A second parsing unit 402a, configured to parse out the to-be-changed packet in the first dependency link;

第二获取单元402b,用于获取所述待变更包的映射规则,所述映射规则包括:如果所述待变更包中包括预设后缀名,则将所述待变更的包的版本号的后缀名对应修改为升级包的后缀名,如果所述待变更包中不包括所述预设后缀名,则在所述待变更包后添加所述升级包的后缀名;The second obtaining unit 402b is configured to obtain the mapping rule of the package to be changed, where the mapping rule includes: if the package to be changed includes a preset suffix name, then the suffix of the version number of the package to be changed is The name is correspondingly modified to the suffix name of the upgrade package. If the preset suffix name is not included in the to-be-changed package, the suffix name of the upgrade package is added after the to-be-changed package;

确认单元402c,用于根据所述待变更包的映射规则,确认与所述待变更包对应的升级包的后缀名。The confirming unit 402c is configured to confirm the suffix name of the upgrade package corresponding to the to-be-changed package according to the mapping rule of the to-be-changed package.

参见图5,在另一种可能的实施方式中,所述依赖链路转换模块403,包括:Referring to FIG. 5, in another possible implementation manner, the dependent link conversion module 403 includes:

第三获取单元403a,用于获取所述第一依赖链路关联的归档文件jar对应的pom文件;A third obtaining unit 403a, configured to obtain the pom file corresponding to the archive file jar associated with the first dependency link;

第三解析单元403b,用于解析出所述jar对应的pom文件的属性列表,并将所述当前Maven工程的内置变量添加到所述属性列表中,所述当前Maven工程的内置变量包括:组织标识、项目标识和版本号;The third parsing unit 403b is configured to parse out the property list of the pom file corresponding to the jar, and add the built-in variables of the current Maven project to the property list, where the built-in variables of the current Maven project include: organization logo, project logo and version number;

修改单元403c,用于根据所述映射规则修改所述jar对应的pom文件属性列表中的版本号,得到第二依赖链路。The modifying unit 403c is configured to modify the version number in the attribute list of the pom file corresponding to the jar according to the mapping rule to obtain a second dependency link.

参见图5,在另一种可能的实施方式中,所述依赖链路转换模块403,还包括:Referring to FIG. 5, in another possible implementation manner, the dependent link conversion module 403 further includes:

第四获取单元403d,用于在所述修改单元403c得到所述第二依赖链路之前,获取所述第一依赖链路关联的jar对应的pom文件的所有父pom列表;a fourth obtaining unit 403d, configured to obtain all parent pom lists of the pom files corresponding to the jars associated with the first dependency link before the modification unit 403c obtains the second dependency link;

所述修改单元403c还用于判断是否有需要修改的父pom列表,如果是,则根据所述映射规则修改所述需要修改的父pom列表下每个pom文件属性列表中的版本号。The modifying unit 403c is further configured to determine whether there is a parent pom list that needs to be modified, and if so, modify the version number in the attribute list of each pom file under the parent pom list that needs to be modified according to the mapping rule.

参见图5,在另一种可能的实施方式中,所述装置还包括:Referring to FIG. 5, in another possible implementation manner, the apparatus further includes:

验证模块404,用于验证所述第二依赖链路的消息摘要算法第五版MD5值与所述第一链路的MD5值是否相同,如果是,则将所述第二依赖链路存储到Maven仓库中。Verification module 404, configured to verify whether the MD5 value of the message digest algorithm version 5 of the second dependent link is the same as the MD5 value of the first link, and if so, store the second dependent link in the in the Maven repository.

参见图5,在另一种可能的实施方式中,所述验证模块404包括:Referring to FIG. 5, in another possible implementation manner, the verification module 404 includes:

第五获取单元404a,用于获取所述第一依赖链路中需要修改的jar,计算所述第一链路中需要修改的jar的第一MD5值;a fifth obtaining unit 404a, configured to obtain the jar that needs to be modified in the first dependency link, and calculate the first MD5 value of the jar that needs to be modified in the first link;

第六获取单元404b,用于获取所述第二依赖链路中对应所述第一依赖链路中修改的jar,计算所述第二链路中对应所述第一依赖链路中修改后的jar的第二MD5值;The sixth obtaining unit 404b is configured to obtain the modified jar in the second dependent link corresponding to the first dependent link, and calculate the modified jar corresponding to the first dependent link in the second link. The second MD5 value of the jar;

验证单元404c,用于判断所述第五获取单元获取的第一MD5值与所述第六获取单元获取的第二MD5值是否相同,如果相同,则确认所述第二依赖链路的MD5值与所述第一链路的MD5值相同。A verification unit 404c, configured to judge whether the first MD5 value obtained by the fifth obtaining unit is the same as the second MD5 value obtained by the sixth obtaining unit, and if they are the same, then confirm the MD5 value of the second dependent link The same as the MD5 value of the first link.

有益效果:本实施例通过解析当前Maven工程的依赖链路及待变更包映射规则,根据映射规则对初始的依赖链路进行修改,从而得到稳定的依赖链路,实现了对初始依赖链路的升级,解决了在Maven工程中不能自动升级依赖链路的问题。Beneficial effect: In this embodiment, by analyzing the dependency link of the current Maven project and the mapping rule of the package to be changed, and modifying the initial dependency link according to the mapping rule, a stable dependency link is obtained, and the initial dependency link is realized. Upgrade, which solves the problem that dependency links cannot be automatically upgraded in Maven projects.

为了描述的方便,以上所述装置的各部分以功能分为各种模块或单元分别描述。当然,在实施本申请时可以把各模块或单元的功能在同一个或多个软件或硬件中实现。For the convenience of description, each part of the device described above is divided into various modules or units by function and described respectively. Of course, when implementing the present application, the functions of each module or unit may be implemented in one or more software or hardware.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。While the preferred embodiments of the present application have been described, additional changes and modifications to these embodiments may occur to those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiment and all changes and modifications that fall within the scope of this application.

Claims (10)

1. An upgrade method, comprising the steps of:
acquiring a first dependent link of a current project construction management Maven project, wherein the first dependent link comprises a packet to be changed;
the obtaining of the mapping rule for converting the package to be changed into the upgrade package includes: analyzing the packet to be changed in the first dependent link; obtaining a mapping rule corresponding to the packet to be changed, wherein the mapping rule comprises: if the packet to be changed comprises a preset suffix name, correspondingly modifying the suffix name of the version number of the packet to be changed into the suffix name of an upgrade packet, and if the packet to be changed does not comprise the preset suffix name, adding the suffix name of the upgrade packet after the packet to be changed; confirming the suffix name of the upgrading packet corresponding to the packet to be changed according to the mapping rule of the packet to be changed;
modifying the first dependent link according to the mapping rule to obtain a second dependent link, wherein the method comprises the steps of obtaining a pom file corresponding to an archive file jar associated with the first dependent link; analyzing an attribute list of a pom file corresponding to the jar, and adding the built-in variables of the current Maven project into the attribute list, wherein the built-in variables of the current Maven project comprise: organization identity, item identity, and version number.
2. The method of claim 1, wherein the obtaining the first dependency link relationship for the current Maven project comprises:
acquiring a project object model (pom) file of a current Maven project through a Maven plug-in; and analyzing the pom file, and sequentially acquiring each link node of the current Maven project to obtain a first dependent link of the current Maven project.
3. The method of claim 1, wherein before modifying the version number in the pom file attribute list corresponding to jar according to the mapping rule to obtain the second dependent link, the method further comprises:
acquiring all father pom lists of pom files corresponding to jar associated with the first dependent link;
and judging whether a parent pom list needing to be modified exists, and if so, modifying the version number in each pom file attribute list under the parent pom list needing to be modified according to the mapping rule.
4. The method of claim 1, wherein the method further comprises:
verifying whether the MD5 value of the fifth version of the message digest algorithm of the second dependent link is the same as the MD5 value of the first dependent link, and if so, storing the second dependent link into a Maven warehouse.
5. The method of claim 4, wherein verifying whether the MD5 value of the second dependent link is the same as the MD5 value of the first dependent link comprises:
acquiring jar needing to be modified in the first dependent link, and calculating a first MD5 value of the jar needing to be modified in the first dependent link;
acquiring jar corresponding to the modification in the first dependent link in the second dependent link, and calculating a second MD5 value corresponding to the modified jar in the first dependent link in the second dependent link;
and judging whether the first MD5 value is the same as the second MD5 value, and if so, confirming that the MD5 value of the second dependent link is the same as the MD5 value of the first dependent link.
6. An upgrade apparatus, comprising:
the system comprises a dependent link acquisition module, a mapping module and a mapping module, wherein the dependent link acquisition module is used for acquiring a first dependent link of a current project construction management Maven project, and the first dependent link comprises a packet to be changed;
the dependent link analysis module is used for acquiring a mapping rule for converting the packet to be changed into an upgrading packet; wherein the dependent link parsing module comprises: the second analysis unit is used for analyzing the packet to be changed in the first dependent link; a second obtaining unit, configured to obtain a mapping rule of the packet to be changed, where the mapping rule includes: if the packet to be changed comprises a preset suffix name, correspondingly modifying the suffix name of the version number of the packet to be changed into the suffix name of an upgrade packet, and if the packet to be changed does not comprise the preset suffix name, adding the suffix name of the upgrade packet after the packet to be changed; the confirming unit is used for confirming the suffix name of the upgrading packet corresponding to the packet to be changed according to the mapping rule of the packet to be changed;
the dependent link conversion module is used for modifying the first dependent link according to the mapping rule to obtain a second dependent link;
wherein the dependent link conversion module comprises: a third obtaining unit, configured to obtain a pom file corresponding to the archived file jar associated with the first dependency chain; a third parsing unit, configured to parse an attribute list of a pom file corresponding to the jar, and add a built-in variable of the current Maven project to the attribute list, where the built-in variable of the current Maven project includes: organization identity, item identity, and version number.
7. The apparatus of claim 6, wherein the dependent link acquisition module comprises:
the system comprises a first obtaining unit, a second obtaining unit and a third obtaining unit, wherein the first obtaining unit is used for obtaining a project object model pom file of the current Maven project through a Maven plug-in;
and the first analysis unit is used for analyzing the pom file, sequentially acquiring each link node of the current Maven project and acquiring a first dependent link of the current Maven project.
8. The apparatus of claim 7, wherein the dependent link translation module further comprises:
a fourth obtaining unit, configured to obtain all parent pom lists of pom files corresponding to jar associated with the first dependent link before the modifying unit obtains the second dependent link;
and the modifying unit is also used for judging whether a parent pom list needing to be modified exists, and if so, modifying the version number in each pom file attribute list under the parent pom list needing to be modified according to the mapping rule.
9. The apparatus of claim 6, wherein the apparatus further comprises:
and the verification module is used for verifying whether the MD5 value of the fifth version of the message digest algorithm of the second dependent link is the same as the MD5 value of the first dependent link, and if so, storing the second dependent link into a Maven warehouse.
10. The apparatus of claim 9, wherein the authentication module comprises:
a fifth obtaining unit, configured to obtain jar needing to be modified in the first dependent link, and calculate a first MD5 value of jar needing to be modified in the first dependent link;
a sixth obtaining unit, configured to obtain jar corresponding to the modification in the first dependent link in the second dependent link, and calculate a second MD5 value corresponding to the modified jar in the first dependent link in the second dependent link;
and the verification unit is used for judging whether the first MD5 value acquired by the fifth acquisition unit is the same as the second MD5 value acquired by the sixth acquisition unit, and if so, confirming that the MD5 value of the second dependent link is the same as the MD5 value of the first dependent link.
CN201510175039.1A 2015-04-14 2015-04-14 Upgrading method and device Active CN106155724B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510175039.1A CN106155724B (en) 2015-04-14 2015-04-14 Upgrading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510175039.1A CN106155724B (en) 2015-04-14 2015-04-14 Upgrading method and device

Publications (2)

Publication Number Publication Date
CN106155724A CN106155724A (en) 2016-11-23
CN106155724B true CN106155724B (en) 2020-03-13

Family

ID=57336132

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510175039.1A Active CN106155724B (en) 2015-04-14 2015-04-14 Upgrading method and device

Country Status (1)

Country Link
CN (1) CN106155724B (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108228229B (en) * 2016-12-19 2021-04-13 深圳业拓讯通信科技有限公司 Method and system for managing Maven dependence
CN109271182B (en) * 2017-07-18 2022-09-06 北京京东尚科信息技术有限公司 Method and device for upgrading search engine
CN107844313B (en) * 2017-11-24 2020-05-08 武汉斗鱼网络科技有限公司 A kind of SDK version upgrade method and device in Android
CN109101236A (en) * 2018-07-06 2018-12-28 政采云有限公司 The project that rule-based engine and maven plug-in unit are realized relies on management method and system
CN109284125B (en) * 2018-08-14 2024-08-30 中国平安人寿保险股份有限公司 Method, device, equipment and medium for configuring dependency package in big data platform
CN109446161B (en) * 2018-10-18 2021-12-28 网易(杭州)网络有限公司 Information monitoring method and device, electronic equipment and storage medium
CN110045983B (en) * 2019-04-19 2021-06-01 腾讯科技(深圳)有限公司 Version library management method and device and server
CN110244967A (en) * 2019-06-18 2019-09-17 政采云有限公司 Method for updating edition and device
CN111309713B (en) * 2020-05-14 2020-08-18 深圳开源互联网安全技术有限公司 Method and device for generating Maven open source software library and storage medium
CN111897570B (en) * 2020-07-15 2024-04-12 杭州安恒信息技术股份有限公司 Multi-dependency item file extraction method and device based on Maven plug-in
CN112379916A (en) * 2020-11-12 2021-02-19 中国人寿保险股份有限公司 Method and device for modifying version number of maven project
CN112394958A (en) * 2020-11-17 2021-02-23 全知科技(杭州)有限责任公司 Lightweight upgrading method
CN113094280B (en) * 2021-04-27 2023-07-25 杭州天谷信息科技有限公司 Upgrade method, system, and readable storage medium
CN113407165B (en) * 2021-06-29 2023-04-07 抖音视界有限公司 SDK generation and self-upgrade method, device, readable medium and equipment
CN116301998B (en) * 2023-03-29 2025-11-28 重庆长安汽车股份有限公司 Cabin APP (application) assembly upgrading system based on Maven management

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968298A (en) * 2012-10-31 2013-03-13 山东浪潮齐鲁软件产业股份有限公司 Software product construction method
CN103095357A (en) * 2013-01-18 2013-05-08 成都九华圆通科技发展有限公司 Intelligence antenna self-adaptive beam forming method
CN103369044A (en) * 2013-07-11 2013-10-23 无锡交大联云科技有限公司 Mobile terminal user network perception diagnosis and treatment method based on cloud knowledge base

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8099735B2 (en) * 2007-12-21 2012-01-17 Oracle America, Inc. Method and system for module initialization
US8468194B2 (en) * 2008-12-30 2013-06-18 International Business Machines Corporation Expertise referrals using a real-time communication system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102968298A (en) * 2012-10-31 2013-03-13 山东浪潮齐鲁软件产业股份有限公司 Software product construction method
CN103095357A (en) * 2013-01-18 2013-05-08 成都九华圆通科技发展有限公司 Intelligence antenna self-adaptive beam forming method
CN103369044A (en) * 2013-07-11 2013-10-23 无锡交大联云科技有限公司 Mobile terminal user network perception diagnosis and treatment method based on cloud knowledge base

Also Published As

Publication number Publication date
CN106155724A (en) 2016-11-23

Similar Documents

Publication Publication Date Title
CN106155724B (en) Upgrading method and device
US9557988B2 (en) Workflow-based application generator
US9665849B2 (en) Employing dependency graph in software build projects
US8689177B2 (en) Integration environment generator
US10013339B2 (en) System and method for automating testing without scripting
CN107729031B (en) Code management method, device, computer device and computer-readable storage medium
US20140282372A1 (en) Code separation with semantic guarantees
CN103473076B (en) The dissemination method of a kind of code release and system
US20090319239A1 (en) Topology modeling application that handles abstract entities through the realization of conceptual objects
CN104572085B (en) The analysis method and device of application program
US20190026097A1 (en) Model based upgrade campaign generation
KR20180063240A (en) Systems and methods for building, optimizing, and implementing an infrastructure in a cloud-based computing environment
US11025489B2 (en) Automated discovery of manual configuration changes
CN111158674A (en) Component management method, system, device and storage medium
CN110543427B (en) Test case storage method and device, electronic equipment and storage medium
EP1548581A2 (en) Methods, apparatus and programs for system development
CN105468650A (en) Merge conflict processing method and device and conflicting file processing method and device
CN113568604B (en) Method and device for updating wind control strategy and computer readable storage medium
CN115658128A (en) Method, device and storage medium for generating software bill of material
Clemencic et al. A new nightly build system for lhcb
US10606569B2 (en) Declarative configuration elements
Schmiedmayer et al. Reducing the impact of breaking changes to web service clients during web api evolution
US8621430B2 (en) Method for code transformation supporting temporal abstraction of parameters
CN113741959B (en) Version package assembly method and device based on Maven
Burzlaff et al. Knowledge-driven architecture composition: Assisting the system integrator to reuse integration knowledge

Legal Events

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