Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude files with maven assembly does not work

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>

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

  • changed directory: ..build.directory}/classes
  • changed exclude pattern: dbAccess.*, **/*.properties, **/*

The debug output is just:

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

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

like image 384
Muki Avatar asked Jan 15 '13 12:01

Muki


1 Answers

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>
like image 195
Peter Svensson Avatar answered Oct 22 '22 05:10

Peter Svensson