mavenmaven-assembly-plugin

How do I only build the jar-WITHOUT-dependencies in Maven?


I'm compiling Kotlin(JRE) and deploying it to a little robot. I've had very good luck creating a jar-with-dependencies, thank you StackOverflow.

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>${project.main.class}</mainClass>
            </manifest>
        </archive>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

But the jar is BIG, like 25mb big. The jar without the dependencies is a totally sane 26kb, which really makes a difference because packaging up that big JAR is slow, then I have to scp deploy it to the bot every time.

I was able to preload all the dependencies into a folder on the bot, via mvn dependency:copy-dependencies and copying them over. (again, thank you StackOverflow). Now I need an easy way to set a property that will make it JUST compile and copy the target/MYBOT-1.0-SNAPSHOT.jar and not bother trying to compile the target/MYBOT-1.0-SNAPSHOT-jar-with-dependencies.jar file every time.


Solution

  • Set the property <assembly.skipAssembly> to true (in the <properties> section of your POM). Then the jar-with-dependencies will not be built.