Maven插件中的胖子罐中包含可选的子罐

如何创建具有特定依赖项的胖子。 我有spark项目,需要2个我要添加到应用程序jar中的外部jar。当我创建可执行jar时,jar中不包含任何依赖项,而当我创建胖jar时,所有依赖关系都被添加,包括spark等。我只想在我的jar中添加这两个jar。下面是我使用maven程序集插件创建的pom文件。

<dependencies>

    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.11</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-sql_2.11</artifactId>
        <version>2.2.0</version>
    </dependency>

    <!-- Below dependencies need to be added in Application jar -->

    <dependency>
        <groupId>netacuity</groupId>
        <artifactId>common-netacuity-db</artifactId>
        <version>3.1.2</version>
    </dependency>
    <dependency>
        <groupId>netacuity</groupId>
        <artifactId>common</artifactId>
        <version>2.1.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <!-- get all project dependencies -->
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <!-- MainClass in mainfest make a executable jar -->
                <archive>
                    <manifest>
                        <mainClass>com....App</mainClass>
                    </manifest>
                </archive>

            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <!-- bind to the packaging phase -->
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
评论