gpt4 book ai didi

java - Maven 程序集插件不排除存档中的资源

转载 作者:太空宇宙 更新时间:2023-11-04 14:36:54 24 4
gpt4 key购买 nike

我的 maven 项目的 src/main/resources 目录中有一些属性和 XML 文件。我想排除这些文件

在构建二进制文件时,即使我已经以这种方式设置了这些文件,也没有排除它们。我不知道我做错了什么。

我的 pom.xml 设置

 <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly-plugin/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

assembly.xml 设置

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources/common-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/dotcom-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/olb-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>

我正在执行 mvn package assembly:single 命令来执行相同的操作。

错误日志

[INFO] Skipping project-jar
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.074s
[INFO] Finished at: Sat Aug 23 13:30:25 PDT 2014
[INFO] Final Memory: 29M/45M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4.1:single (make-assembly) on project project-jar: Failed to create assembly: Error creating assembly archive distribution: You must set at least one 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:

最佳答案

你能解释一下你的${basedir}是什么吗?这是一个通过maven资源进程过滤的属性?然后,你必须知道:排除 src 下的文件是没有用的,它与生成的 Artifact 无关,你应该用 target/classes/your-package 替换它们。

这是一个引用,它可能不起作用,但您可以学习如何配置

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>target/classes/common-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/classes/dotcom-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/classes/olb-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>

关于java - Maven 程序集插件不排除存档中的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25460716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com