Maven部署插件-deployAtEnd不起作用 [英] Maven deploy plugin - deployAtEnd not working

查看:488
本文介绍了Maven部署插件-deployAtEnd不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将deployAtEnd属性设置为true的多模块项目中使用maven-deploy-plugin.

I'm using maven-deploy-plugin in multi-module project with deployAtEnd property set to true.

在根项目中执行mvn deploy之后,将为每个子项目执行deploy插件-我可以看到类似以下内容的内容: [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ subproject-name --- [INFO] Deploying package:subproject-name:v1.1 at end 上一次调用是针对根项目的: [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ parent-project --- [INFO] Deploying package:parent-project:v1.1 at end 仅此而已,实际部署没有执行.

After executing mvn deploy in root project, deploy plugin is executed for each subproject - I can see something like: [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ subproject-name --- [INFO] Deploying package:subproject-name:v1.1 at end Last invocation is for root project: [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ parent-project --- [INFO] Deploying package:parent-project:v1.1 at end and that's all, actual deployment is not executed.

如何使用deployAtEnd=true使deploy插件在多模块项目中正常工作?

How do I make deploy plugin work correctly in multi-module project with deployAtEnd=true?

推荐答案

在我们今天刚遇到此问题时,我在maven-deploy-plugin中发现了相关问题:

As we just ran into this issue today, I found the related issue in maven-deploy-plugin:

https://issues.apache.org/jira /plugins/servlet/mobile#issue/MDEPLOY-193

本期JérômeJoslet移植:

我今天发布了这个问题,并找到了解决方法.

I issue this problem today and found a workaround.

maven-deploy-plugin将其状态记录在静态变量中.一为 堆叠部署请求(deployRequests)和另一个用于计数的请求 准备好的项目(readyProjectsCounter).发生问题时, 是一个以上的静态变量,用于计算已准备好的项目.这 当有多个加载了部署的类加载器时发生 插件的类.这导致多个类实例和多个 静态变量实例.一些模块依靠一个实例, 其他模块放在另一个模块上.

The maven-deploy-plugin records its state in static variables. One for stacking deploy requests (deployRequests) and another one for counting ready project (readyProjectsCounter). When the problem occurs, there is more than one static variable used to count ready projects. This happens when there is more than one classloader that loads the deploy plugin's classes. This leads to multiple class instances and multiple static variable instances. Some module count on one instance and others modules on another one.

结果是部署插件 永远不要刷新其挂起的部署请求,因为没有计数器等于 反应堆中的项目数.

The result is that the deploy plugin never flush its pending deploy requests since no counter is equal to the number of project in the reactor.

如下所述 文档: https://svn. apache.org/repos/infra/websites/production/maven/content/reference/maven-classloading.html :

As mentionned in the following documentation : https://svn.apache.org/repos/infra/websites/production/maven/content/reference/maven-classloading.html :

对于使用构建扩展的项目,插件类加载器为 连接到项目类加载器.这使插件代码可以访问两者 Maven API软件包和项目构建导出的软件包 扩展名. Maven将为每个创建一个并且只有一个类加载器 唯一的插件+依赖项+构建扩展名组合.

For projects that use build extensions, plugin classloaders are wired to project classloaders. This gives plugin code access to both Maven API packages and packages exported by the project build extensions. Maven will create one and only one classloader for each unique plugin+dependencies+build-extensions combination.

Maven保证每个只有一个项目类加载器 一组独特的项目构建扩展名和相同的类加载器 具有构建扩展集的所有项目都可以使用.

Maven guarantees there will be one and only one project classloader for each unique set of project build extensions and the same classloader will be used by all projects that have the set of build extensions.

解决方法是声明所有扩展插件及其所有额外功能 <dependencies>,在父项目中.这样可以确保相同 classloader用于在所有模块中加载插件.

The workaround is to declare all extension plugins, with all their extra <dependencies>, in the parent project. This assures that the same classloader is used for loading plugin in all modules.

这篇关于Maven部署插件-deployAtEnd不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆