Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding packages from jars in maven assembly descriptor

Tags:

java

maven-2

I have the following syntax problem.

I have a jar file that is created from other unpacked jar files. I am trying to exclude some package from being in the the new jar file.

Here is my assembly descriptor

<assembly>
<id>gs-jar</id>
<formats>
    <format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<dependencySets>
    <dependencySet>
        <unpack>true</unpack>
        <scope>runtime</scope>
        <includes>
            <include>com.delver:shci-commons</include>
            <include>com.delver:shci-model</include>
            <include>com.delver:gigaspaces-persistence</include>
            <include>com.delver:gigaspaces-mirror</include>
            <include>com.delver:recommendation</include>
        </includes>
        <unpackOptions>
            <excludes>
                <exclude>
                    Ohio.Model*
                </exclude>
                <exclude>log4j.properties</exclude>
                <exclude>gslicense.xml</exclude>
            </excludes>
        </unpackOptions>
    </dependencySet>
</dependencySets>
</assembly>

As you see I am trying to excluded the package that starts with Ohio.Model , but somehow it get s included anyway.

Is there something wrong with the syntax ?

like image 863
Roman Avatar asked Jun 10 '10 10:06

Roman


People also ask

How you can exclude dependency in Maven?

Exclude a dependency You can use a diagram to exclude a dependency from the project's POM. Select a dependency in the diagram window. From the context menu, choose Exclude. From the list, select the module (if any) where the exclusion definition will be added.

What is assembly descriptor in Maven?

So in order for you to customize the way the Assembly Plugin creates your assemblies, you need to know how to use the Assembly Descriptor. This descriptor specifies the type of assembly archive to create, the contents of the assembly, and the ways in which dependencies or its modules are bundled with an assembly.

What is exclusion tag in Maven?

Exclusions are set on a specific dependency in your POM, and are targeted at a specific groupId and artifactId. When you build your project, that artifact will not be added to your project's classpath by way of the dependency in which the exclusion was declared.

What is Maven Shade plugin?

This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.


1 Answers

Found it

            <exclude>
               **/Ohio/**
            </exclude>
like image 188
Roman Avatar answered Oct 16 '22 13:10

Roman