排除文件与Maven组装不起作用(Exclude files with maven assembly

2019-07-18 05:25发布

我有很简单的装配描述符

<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>dist</id>
<formats>
    <format>jar</format>
</formats>
<!-- copied from jar-with-dependencies -->
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <useProjectArtifact>true</useProjectArtifact>
        <unpack>true</unpack>
        <scope>runtime</scope>
    </dependencySet>
</dependencySets>

<fileSets>
    <fileSet>
        <directory>${project.build.outputDirectory}</directory>
        <outputDirectory>/</outputDirectory>
        <useDefaultExcludes>true</useDefaultExcludes>
        <excludes>
            <exclude>**/dbAccess.*</exclude>
        </excludes>
    </fileSet>
</fileSets>

其中大部分是从复制的Maven的描述符参考文献 。 但是我组装罐子仍然包含DBACCESS。*文件。 我试过排除各种配置。

  • 改变目录:..build.directory} /班
  • 改排除模式:。DBACCESS *,** / *属性,** / *

调试输出仅仅是:

[DEBUG] The archive base directory is 'null'

[DEBUG] NOT reformatting any files in /media/truecrypt1/Development/workspace_java/baseanalysis/target/classes

[DEBUG] Adding file-set from directory: '/media/truecrypt1/Development/workspace_java/baseanalysis/target/classes'
assembly output directory is: ''

[DEBUG] Adding file-set in: /media/truecrypt1/Development/workspace_java/baseanalysis/target/classes to archive location: 

正常resouces过滤工作,如果我把它放在POM构建部分内。

Answer 1:

你需要过滤dependencySet为好。 尝试更新组件描述符

<dependencySet>
    <outputDirectory>/</outputDirectory>
    <useProjectArtifact>true</useProjectArtifact>
    <unpack>true</unpack>
    <scope>runtime</scope>
    <unpackOptions>
        <excludes>
            <exclude>**/dbAccess.*</exclude>
        </excludes>
    </unpackOptions>
</dependencySet>


文章来源: Exclude files with maven assembly does not work