9

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Muki
  • 3,513
  • 3
  • 27
  • 50
  • Whats the exact content of the created jar? Since you don't post your `pom.xml` it's hard to tell whats expected in it. Running plain maven with the descriptor in the question will create a jar with a jar file in it if I remember correctly. – Peter Svensson Jan 16 '13 at 09:10
  • Ah, sorry. The _unpack_ flag should be _true_. The content of the jar, should be the classes compiled in _target/classes_ and the unpack _scope:runtime dependencies_ and not containing the _dbAccess.*_ files – Muki Jan 17 '13 at 10:40
  • Sorry, wasn't able to try it out. Works smooth. Thank you :) – Muki Jan 30 '13 at 18:54

1 Answers1

12

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>
Peter Svensson
  • 6,105
  • 1
  • 31
  • 31