Java Maven 组装:组装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/967779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven assembly:assembly
提问by javamonkey79
Hello I am trying to create a custom descriptor ref in my parent pom which packages all dependencies with sources. I got the assembly.xml nailed down pretty well, but when I add it to my base POM assembly:assembly fails like so:
您好,我正在尝试在我的父 pom 中创建一个自定义描述符 ref,它将所有依赖项与源打包在一起。我很好地确定了 assembly.xml,但是当我将它添加到我的基础 POM 程序集时:程序集失败如下:
[INFO] [assembly:assembly]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error reading assemblies: No assembly descriptors found.
But assembly:single seems to work correctly. I've tried adding the jar-with-dependencies ref into the POM as well, but I am not sure if this is even possible.
但是 assembly:single 似乎可以正常工作。我也尝试将 jar-with-dependencies ref 添加到 POM 中,但我不确定这是否可行。
Here is what I have in my base pom:
这是我的基本 pom 中的内容:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
<dependencies>
<dependency>
<groupId>mycompany.jar.assembly</groupId>
<artifactId>jar-with-dependencies-and-sources-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Does anyone out there know who to get this to work when I invoke mvn assembly:assembly from the command line?
当我从命令行调用 mvn assembly:assembly 时,有没有人知道谁让这个工作?
Thanks in advance.
提前致谢。
采纳答案by super_aardvark
I'm not sure, but I have a suspicion. You define assembly:single as part of the package phase, and identify the descriptor there in the execution element. This may mean the plugin doesn't know where to look for the descriptor when you run assembly:assembly. Try copying your <configuration>
element to outside of the <executions>
element.
我不确定,但我有一个怀疑。您将 assembly:single 定义为包阶段的一部分,并在执行元素中标识那里的描述符。这可能意味着当您运行 assembly:assembly 时,插件不知道在哪里查找描述符。尝试将您的<configuration>
元素复制到元素之外<executions>
。
One of my poms looks like this, and I use assembly:assembly all the time:
我的一个 poms 看起来像这样,我一直使用 assembly:assembly:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<finalName>myJar</finalName>
<descriptors>
<descriptor>src/main/config/descriptor.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>org.foo.Bar</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Note src/main/config
isn't a Maven standard path, but I haven't defined any special handling of it.
Notesrc/main/config
不是 Maven 标准路径,但我没有定义任何特殊处理。
回答by artemb
Where do you have your assembly.xml? Maven's working directory is the directory of a module (the one which contains pom.xml). If your assembly.xml is no in the same directory as this pom.xml, you should specify the path
你的 assembly.xml 在哪里?Maven 的工作目录是模块的目录(包含 pom.xml 的目录)。如果你的 assembly.xml 和这个 pom.xml 不在同一个目录下,你应该指定路径