本文介绍了使用Maven程序集排除文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的汇编描述符

I have very simple assembly descriptor

<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描述符引用.但是,我组装的jar仍包含dbAccess.*文件.我尝试了各种排除配置.

which is mostly copied from the Maven Descriptor Refs. However my assembled jar still contains the dbAccess.* files. I tried various configurations for exclude.

调试输出仅为:

[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的build部分中,则正常的资源过滤将起作用.

The normal resouces filtering works if I put it inside the build section in the pom.

推荐答案

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

You need to filter the dependencySet as well.Try updating your assembly descriptor as

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

这篇关于使用Maven程序集排除文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!