[英]How to unpack the resource from another module in a multimodule package properly?
I use Maven to work with a multi module where it has multiple modules. 我使用Maven处理具有多个模块的多模块。
module-jax-rs
. I use swagger-maven-plugin
to generate Swagger json and bundle it as a resource in module-jax-rs
. 其中之一是一个JAX-RS项目(我们称其为module-jax-rs
。我使用swagger-maven-plugin
生成Swagger json并将其作为资源捆绑在module-jax-rs
。 module-python
is a python module where it relies on Swagger Json in module-jax-rs
to generate a Swagger client using another Maven plugin swagger-codegen-maven-plugin
另一个模块module-python
是一个python模块,它依靠module-jax-rs
Swagger Json来使用另一个Maven插件生成Swagger客户端swagger-codegen-maven-plugin
swagger.json
file from module-jax-rs
before compile module-python
. 但是,为此,我需要在编译module-python
之前从module-jax-rs
解压缩swagger.json
文件。 mvn package
but not with mvn compile
since mvn compile
does not generate the package that I can extract from. 这对mvn package
但对mvn compile
无效,因为mvn compile
不会生成可从中提取的软件包。 What should I do to make it possible to still run mvn compile
without running into the following error? 我应该怎么做才能仍然运行mvn compile
而不会遇到以下错误?
[ERROR] Failed to execute goal org.apache.maven.plugins:
maven-dependency-plugin:2.10:unpack-dependencies (unpack)
on project module-python: Artifact has not been packaged yet.
When used on reactor artifact, unpack should be executed after
packaging: see MDEP-98. -> [Help 1]
You can basically copy the swagger.json into the module-python with something like the antrun plugin and the file's relative path. 您基本上可以使用诸如antrun插件和文件的相对路径之类的东西将swagger.json复制到module-python中。
However this is not really the proper way of doing using resources from another module even one in the same multi-module project. 但是,这实际上不是使用来自另一个模块的资源(甚至是同一多模块项目中的一个模块)的正确方法。 Generally the correct way to use resources from other modules is to allow the module with the required resources to package and install those resources into a jar files, and then simply import that jar file in any module that needs it. 通常,使用其他模块资源的正确方法是允许具有所需资源的模块将这些资源打包并安装到jar文件中,然后只需将该jar文件导入任何需要它的模块中。 Of course for this to happen you have to run the package goal. 当然要做到这一点,您必须运行包装目标。
I am not sure why you are trying to avoid the package goal. 我不确定为什么您要避免达成打包目标。 I have never come across a situation where there was good reason for not running it. 我从未遇到过有充分理由不运行它的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.