简体   繁体   English

我可以使用在多模块项目中定义的自定义生命周期吗?

[英]Can I use a custom lifecycle defined in a multi-module project?

I have a project that has a complex lifecycle, so a custom lifecycle makes sense. 我有一个具有复杂生命周期的项目,因此自定义生命周期是有意义的。 However, I would like to be able to have the lifecycle defined in a plugin that is in the same multi-module build. 但是,我希望能够在同一多模块构建的插件中定义生命周期。 The plugin just defines the custom lifecycle (in a components.xml ). 该插件仅定义了自定义生命周期(在components.xml )。

apollo-server-parent
  - apollo-server-lifecycle-plugin
    - src/main/resources/META-INF/plexus/components.xml (defines apollo-server-product)
  - ApolloServer
    - pom.xml

... <packaging>apollo-server-product</packaging> ... <plugin> <groupId>ca.nanometrics.apollo</groupId> <artifactId>apollo-server-lifecycle-plugin</artifactId> <version>${project.parent.version}</version> <extensions>true</extensions> </plugin>

However, if I do this, maven won't build because it cannot find the apollo-server-lifecycle-plugin because it has not been built yet while building the reactor. 但是,如果我这样做,将无法构建Maven,因为它无法找到apollo-server-lifecycle-plugin,因为在构建反应堆时尚未构建它。 Any ideas on how to work around this? 关于如何解决此问题的任何想法? Do I have to define the plugin in a separate project? 我是否必须在单独的项目中定义插件?

An example of the error I get: 我得到的错误示例:

[ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin ca.nanometrics.apollo:apollo-server-plugin:4.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact ca.nanometrics.apollo:apollo-server-plugin:jar:4.0.0-SNAPSHOT in releases (http://.../nexus/content/groups/public) @ 
[ERROR] Unknown packaging: apollo-server-product @ ca.nanometrics.apollo:ApolloServer:[unknown-version], /opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml, line 10, column 14
     @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project ca.nanometrics.apollo:ApolloServer:4.0.0-SNAPSHOT (/opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin ca.nanometrics.apollo:apollo-server-plugin:4.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact ca.nanometrics.apollo:apollo-server-plugin:jar:4.0.0-SNAPSHOT in releases (http://.../nexus/content/groups/public) -> [Help 2]
[ERROR]     Unknown packaging: apollo-server-product @ ca.nanometrics.apollo:ApolloServer:[unknown-version], /opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml, line 10, column 14

If I am not getting you wrong here - 如果我在这里没弄错你-

You want to build ApolloServer module, which uses apollo-server-lifecycle-plugin which is also a module of your project. 您要构建ApolloServer模块,该模块使用apollo-server-lifecycle-plugin也是项目的一个模块。

Current project structure being : 当前的项目结构为:

apollo-server-parent
  - apollo-server-lifecycle-plugin
  - ApolloServer

From the multi-module guide , one simple way of doing this could be making sure that apollo-server-lifecycle-plugin is build prior to the ApolloServer module always. 多模块指南中 ,一种简单的方法可以确保始终在ApolloServer模块之前构建apollo-server-lifecycle-plugin Easiest way to do that could be to include the dependency of apollo-server-lifecycle-plugin in ApolloServer(pom.xml) which would make sure the Reactor sorting builds plugin first. 最简单的方法是在ApolloServer(pom.xml)中包含apollo-server-lifecycle-plugin的依赖关系,这将确保Reactor排序首先构建插件。

a plugin dependency on another module in the build 插件对构建中另一个模块的依赖

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

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