I want to build my spring boot app, but I have to transfer the files around a lot into different servers. But my "libs" folder inside my "jar" file, is too big now. It's 100MB++.
What I want is to periodically update my webapp, that is like 1MB or something, and keep a copy of my 100MB "libs" folder on the output directory at different servers. Only updating the libs rarely.
The following POM file makes a 100MB JAR... and then makes 100MB "libs" folder. Then zips the two together. But I don't know how to make 100MBJAR smaller (what springboot libs are most important to be compiled together?). I think I need an <include>
tag or something.
But I haven't found the right way to configure "spring boot maven plugin" so that it only includes the most essential files from SpringBoot & TomCat Embedded, but keeps most of the other libraries outside in a different folder.
(bottom of my) POM.xml
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<excludes>
<exclude>node_modules/**</exclude>
<exclude>bower_components/**</exclude>
<exclude>node/**</exclude>
</excludes>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<projectNameTemplate>[groupId].[artifactId]</projectNameTemplate>
</configuration>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
<mainClass>${fully.qualified.main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>antrun-archive</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="final.name" value="${project.build.directory}/${project.build.finalName}"/>
<property name="archive.includes" value="${project.build.finalName}.${project.packaging} ${project.build.finalName}.lib/*"/>
<property name="tar.destfile" value="${final.name}.tar"/>
<!-- <zip basedir="${project.build.directory}" destfile="${final.name}.zip" includes="${archive.includes}" /> -->
<tar basedir="${project.build.directory}" destfile="${tar.destfile}" includes="${archive.includes}" />
<gzip src="${tar.destfile}" destfile="${tar.destfile}.gz" />
<!-- <bzip2 src="${tar.destfile}" destfile="${tar.destfile}.bz2" /> -->
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>