简体   繁体   English

Maven发布流程替代

[英]Maven Release process alternative

Problem: 20 different JAVA projects with a lot of inter-dependencies. 问题: 20个不同的JAVA项目相互依赖。 Every time there is a bug fix after code-lock, we have to release a bunch of artifacts as needed depending on which artifact changed. 每次在代码锁定后进行bug修复时,我们都必须根据需要更改一堆工件,具体取决于所更改的工件。 For example, if artifact 3 had an unlock and needed a bug fix, we will need to release (using maven release plugin) projects 3,4,5,6,7 and 10 (because 4,5,6,7 and 10 are dependent on 3). 例如,如果工件3具有解锁功能并且需要修复错误,我们将需要发布(使用Maven版本插件)项目3、4、5、6、7和10(因为4,5、6、7和10是取决于3)。 Co-ordinating between teams to get this task done takes time. 团队之间进行协调以完成此任务需要花费时间。 Plus building each artifact takes a good 20-40 min. 再加上构建每个工件需要花费20-40分钟。

We want to shorten this process. 我们要缩短这个过程。 We are thinking of the following: 我们正在考虑以下内容:

  1. Use snapshots for artifacts with time-stamps 将快照用于带有时间戳记的工件
  2. Promote individual artifacts to repository using jenkins jobs and tag svn. 使用jenkins作业和标记svn将单个工件提升到存储库。
  3. Update dependencies using mvn version:set command for each project that needs the dependency. 使用mvn version:set命令为每个需要依赖项的项目更新依赖项。

Has anyone implemented a solution similar to as described above? 有没有人实现与上述类似的解决方案? If so, what issues did you run into? 如果是这样,您遇到了什么问题?

Any other suggestions that will not rebuild the artifacts and allow us to release 15-20 artifacts at a click of a button will be helpful :) 任何其他不会重建工件并允许我们单击按钮释放15-20个工件的建议都将是有用的:)

Unfortunately you have to rebuild your artifact if you change your pom file. 不幸的是,如果更改pom文件,则必须重建工件。 Otherwise your state in your VCS does not represent the state your are working with. 否则,您在VCS中的状态将不代表您正在使用的状态。

Lets make an example. 让我们举个例子。 Project A, Project B where B dependends on A: 项目A,项目B,其中项目B依赖于项目A:

Project A: pom.xml 项目A:pom.xml

   <version>1.0-SNAPSHOT</version>
   Some dependencies etc. 

Project B: pom.xml 项目B:pom.xml

   <version>1.0-SNAPSHOT</version>

   Some dependencies etc. 
   <dependency>
     <groupId>project.a</groupId>
     <artifactId>A</artifactId>
     <version>1.0-SNAPSHOT</version>
   </dependency>

Now you build Project A and B. The state in your repository represents the states of the pom files with their state/dependencies to SNAPSHOT. 现在,您构建项目A和B。存储库中的状态代表pom文件的状态及其对SNAPSHOT的依赖性。

Now you will change Project A to make "release" from it but you don't rebuild your artifact. 现在,您将更改Project A以从中释放“项目”,但不重建项目。 Than the following is in your version control and may be you do a tagging of it. 比以下版本在您的版本控制中,可能是您对其进行了标记。

Project A: pom.xml 项目A:pom.xml

   <version>1.0</version>
   Some dependencies etc. 

Second you do the same with Project B: Project B: pom.xml 其次,您对项目B执行相同的操作:项目B:pom.xml

   <version>1.0</version>

   Some dependencies etc. 
   <dependency>
     <groupId>project.a</groupId>
     <artifactId>A</artifactId>
     <version>1.0</version>
   </dependency>

But you don't rebuild your aritfact either. 但是你也不重建自己的立场。 The result is your repository does contains artifacts which represent the state of the SNAPSHOT but your version control says something different. 结果是您的存储库确实包含表示SNAPSHOT状态的工件,但是您的版本控件说的却有所不同。 This is only very simple example of the problem. 这只是问题的非常简单的例子。 If you have more projects etc. the worse the thing will become. 如果您有更多的项目等,情况将会变得更糟。

Furthermore i would recosinder thinking about changing the project structure, cause based on what you've written about the dependencies it looks like those project should be released together so it might a good idea to create a multi-module build out of them. 此外,我会重新考虑更改项目结构的原因,基于您撰写的关于依赖项的内容,应该将这些项目一起发布,因此从中创建一个多模块的构建可能是一个好主意。

Furthermore the rebuilding can be done by using appropriate jobs in Jenkins which can handle dependencies or you might consider using build pipeline plugin to handle such things. 此外,可以通过在Jenkins中使用适当的作业来完成重建,该作业可以处理依赖关系,或者您可以考虑使用构建管道插件来处理此类问题。

But one other questions comes to my mind: Why do your builds take so long? 但是我想到另一个问题:为什么构建需要这么长时间? You might investigate why they are taking so long and reduce the release time over all. 您可能会调查为什么他们要花这么长时间并减少所有发布时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM