0

Currently I have a multi module project with maven, in the super pom I have added the modules of the projects. From the SparkAppBuilder module I intend to build the jar project that contains the SparkDriver and SparkProcess projects. ProjectStructure

To do this from the SparkAPPBuilder module, add the maven-assembly-plugin plugin, I see that it builds the project by adding my 2 modules, but the problem is that it is generating the jar with all the dependencies that are in my local repository, so the jar weighs more than 150MB.

This is my SparkAppBuilderPOM:

<profile>
            <id>dev</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.5</version>
                        <executions>
                            <execution>
                                <id>assembly</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptorRefs>
                                        <descriptorRef>jar-with-dependencies</descriptorRef>
                                    </descriptorRefs>
                                    <archive>
                                        <manifest>
                                            <addClasspath>true</addClasspath>
                                            <classpathPrefix>lib/</classpathPrefix>
                                            <mainClass>com.streaming.example.DirectStreaming</mainClass>
                                        </manifest>
                                    </archive>
                                    <finalName>JavaStreamingDirect</finalName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.1.1</version>
                        <configuration>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <classpathPrefix>lib/</classpathPrefix>
                                    <mainClass>com.streaming.example.DirectStreaming</mainClass>
                                </manifest>
                            </archive>
                            <finalName>JavaStreamingDirect</finalName>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
...

<dependencies>
        <dependency>
            <groupId>com.spark.driver</groupId>
            <artifactId>SparkDriver</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.spark.streaming</groupId>
            <artifactId>SparkProcess</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>

    </dependencies>

Do you know why you add my entire local repository in the assmbly phase?

Thanks so much.

Regards

1 Answer 1

1

A jar-with-dependencies also contains all transitive dependencies. Those are usually needed to run the project because they are the dependencies of your dependencies.

So it is not unusual that this jar is large. You should look in your mvn dependency:tree where most of the stuff comes from -- then you might be able to reduce the amount by changing the dependencies of your modules.

So: The jar-with-dependencies does not contain the whole local repository, just the whole dependency tree.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much for your help, let me check dependency tree and i'll reorganize my dependencies, i think should i usage dependency management. I will post my comments and result as soon as I adjust

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.