简体   繁体   中英

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 ).

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. 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.

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. 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.

a plugin dependency on another module in the build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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