9

我有非常简单的程序集描述符

<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 Descriptor Refs复制的。但是我组装的 jar 仍然包含 dbAccess.* 文件。我尝试了各种排除配置。

  • 更改目录:..build.directory}/classes
  • 更改排除模式:dbAccess.*、**/*.properties、**/*

调试输出只是:

[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: 

如果我将它放在 pom.xml 的构建部分中,则正常的资源过滤可以工作。

4

1 回答 1

12

您还需要过滤dependencySet。尝试将您的程序集描述符更新为

<dependencySet>
    <outputDirectory>/</outputDirectory>
    <useProjectArtifact>true</useProjectArtifact>
    <unpack>true</unpack>
    <scope>runtime</scope>
    <unpackOptions>
        <excludes>
            <exclude>**/dbAccess.*</exclude>
        </excludes>
    </unpackOptions>
</dependencySet>
于 2013-01-17T12:32:23.813 回答