- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在我的Khatami项目 我正在使用 maven 来管理编译并将结果打包到一个可运行的 Artifact 中:顶层的可执行 shell 脚本,bin/
包含可执行 jar 及其依赖的 jar。请看我的意思here .
作为引用,这里是 Khatami 的 pom.xml
的重要部分:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>${project.groupId}.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
和完整的src/main/assembly/src.xml
:
<assembly>
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>bin</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/assembly</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>khatami</include>
</includes>
<fileMode>744</fileMode>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
</fileSet>
</fileSets>
</assembly>
和编译尝试:
$ mvn clean compile assembly:single
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building khatami 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ khatami ---
[INFO] Deleting /home/blt/projects/com/carepilot/repos/khatami/target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ khatami ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/blt/projects/com/carepilot/repos/khatami/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ khatami ---
[INFO] Compiling 1 source file to /home/blt/projects/com/carepilot/repos/khatami/target/classes
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ khatami ---
[INFO] Reading assembly descriptor: src/main/assembly/src.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.721s
[INFO] Finished at: Mon Jul 18 13:58:30 EDT 2011
[INFO] Final Memory: 8M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project khatami: Failed to create assembly: Error adding file 'com.carepilot.khatami:khatami:jar:1.0-SNAPSHOT' to archive: /home/blt/projects/com/carepilot/repos/khatami/target/classes isn't a file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我错在哪里?
最佳答案
错误信息的相关部分是
Error adding file 'com.carepilot.khatami:khatami:jar:1.0-SNAPSHOT' to archive:
/home/blt/projects/com/carepilot/repos/khatami/target/classes isn't a file.
它需要一个文件,但找不到它,因为 package
目标没有在 clean
之后运行。
如果你执行 mvn clean compile package assembly:single
它将成功构建。
我会将 assembly:single
目标添加到 package
阶段,这样它将自动构建。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>${project.groupId}.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
通过对配置的上述更改,您可以发布。
mvn clean package
assembly:single
目标将自动执行。
执行此操作的更好方法可能是使用 maven-shade-plugin而不是手动执行此操作。
关于java - maven-assembly-plugin MojoExecutionException 与 dependencySet 作为 outputDirectory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6737221/
以下是我在 pom 中构建 Maven 项目时包含的目标。 4.0.0 com.mynewproject.portlet abc-myfacts-portlet w
我遇到了这个问题,当我使用 Maven 部署我的应用程序时,请提出一些解决方案。 错误日志, [INFO] BUILD FAILURE [INFO] -------------------------
我目前正在为我的项目原型(prototype)使用此设置: mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.s4hana.arche
我正在学习 Spring 教程,但一直停留在 creating RestController App 11.4 它只是没有运行。 [INFO] ----------------------------
我正在尝试使用 Maven 构建 Android 项目。我正在尝试配置,但我无法弄清楚问题的根源是什么。 [ERROR] Failed to execute goal com.simpligility
当我执行命令./mvnw -Pprod,swagger,webpack clean package -X [ERROR] Failed to execute goal org.apache.maven
我正在使用 this tutorial 学习 spring security 和 AngularJS 。本教程的第一部分指定了对 pom.xml 的非常具体的更改。但是当我添加这些 pom.xml 更
我正在尝试从源代码构建GeoServer。尝试从“geoserver/src”运行 Maven 命令时出现以下错误。 [ERROR] Failed to execute goal pl.project
我正在研究 Apache Spark 并尝试在 Java 程序中运行 Spark,但我遇到了一些问题。 我使用 Maven 构建程序并创建了一个新的 Maven 项目。这是 pom.xml spa
AbstractMavenMojo 的执行方法声明它抛出两个异常:MojoExecutionException 和 MojoFailureException。抛出任一结果都会导致构建停止,并且日志在每
我在使用maven从源代码编译hadoop时遇到了一些问题。这是错误,任何人都可以帮助我吗?谢谢。 [ERROR] Failed to execute goal org.apache.hadoop:h
我从命令行运行 Maven-Project 时遇到问题我在 cmd 中使用此命令来运行名为 mainClass 的类 mvn -e exec:java -Dexec.mainClass="com
在我的Khatami项目 我正在使用 maven 来管理编译并将结果打包到一个可运行的 Artifact 中:顶层的可执行 shell 脚本,bin/ 包含可执行 jar 及其依赖的 jar。请看我的
我尝试通过运行 atlas-cli pi 命令来编译我的自定义 jira 插件。当我使用存储库时它起作用了 http://repo1.maven.org/maven2/ .现在改为http://sea
这个问题几乎与MojoExecutionException when generate sources cxf-xjc-plugin:3.3.0 java11重复。但有两个异常(exception):
当为 Google App Engine 运行 Maven 构建时,我收到构建错误: org.apache.maven.plugin.MojoExecutionException: The DataN
我是一名优秀的程序员,十分优秀!