Q:

Include dependencies in Maven assembly without include the actual artifact

I would like to create a Maven assembly that contains the transitive dependencies of an artifact without actually including the artifact itself. I have tried to exclude the artifact from the assembly, but then its dependencies aren't included as a result.
ArtifactA has DependencyA, DependencyB
Assembly should contain DependencyA, DependencyB (without ArtifactA)
And I would preferrably like to do this without having to explicitly specifiy what dependencies to be included in the assembly because this will be done with multiple projects that have many dependencies.
Thank you!

A:

I finally got it to work. This will produce an artifact that only contains the dependencies of the depende
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>moduletest</groupId>
    <artifactId>moduletest</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <dependencies>
        <dependency>
            <groupId>dependency</groupId>
            <artifactId>dependency</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

assembly.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>module</id>

    <includeBaseDirectory>false</includeBaseDirectory>

    <formats>
        <format>zip</format>
    </formats>

    <dependencySets>
        <dependencySet>
            <excludes>
                <exclude>dependency:dependency</exclude>
            </excludes>
            <useProjectArtifact>false</useProjectArtifact>
            <useTransitiveDependencies>true</useTransitiveDependencies>
        </dependencySet>
    </dependencySets>

</assembly>

