0

At the end of my "package" step I end up with 2 jars : the one made by the "maven-jar-plugin" and the uber/fat/shaded one made by "maven-shade-plugin".

myapp.jar and myapp-uber.jar

At the "install" phase both jar are copied to the local repository. And I see little (=no) reason to have the uber jar copied to my local repository. Further more, it takes unless place on my HDD. And, anyway it will copied to right location at the "deploy" phase.

Here are those instructions :

<!-- Regular jar -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <phase>package</phase>
        </execution>
    </executions>
    <configuration>
        <archive>
            <manifestEntries>
                <SplashScreen-Image>icons/splash.png</SplashScreen-Image>
                <url>${project.url}</url>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

<!-- Uber jar -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>exe</shadedClassifierName>
                <finalName>${project.exe_finalname}</finalName>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>myapp.MainClass</mainClass>
                    </transformer>                            
                </transformers>                        
            </configuration>
        </execution>
    </executions>
</plugin>  

<!-- Deploy -->
<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <phase>deploy</phase>
            <configuration>
                <target name="Pushing to builds repository"><!-- ... --></target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
</plugins>
  

So how can I prevent the uber jar from being copied to the local repository ?

Thanks.

lvr123
  • 524
  • 6
  • 24
  • 1
    First what is the real problem with installing the artifact in your local cache? Really hard disk space? And why are you using antrun plugin to deploy things? This looks like a misuse of Maven because Maven is a build tool and not a deployment tool... Also those steps like deploy should be done from a CI/CD solution – khmarbaise Mar 21 '21 at 08:32
  • What I develop is purely home-made for a home-usage (although distributed freely on the web to anyone interested). The shaded jar is the "executable" packaging. And the "deployment" is merely a copy to a folder where I store all the released versions (hence a antrun task). And yes HDD place is important. My HDD is getting full. And one option is to avoid storing unuseful jar in my .m2 folder. – lvr123 Mar 21 '21 at 13:53
  • Central is for open source and so it's intended exactly for such things... and the best is via central because everybody knows this... So storing a directory with release versions? Hm why not make a release via github/gitlab which already has such functionality. So know it becomes strange because on one hand you say storing a release but on the other you don't want to store/create the jar? Apart from that of how mach space do we talk about... ? – khmarbaise Mar 21 '21 at 14:00
  • For the time being I moved from the shade plugin to the javapackager plugin which turns more aligned to my goal (build (a) distributable version(s) of my app) and store in the local repository only a non-fat jar. – lvr123 Mar 21 '21 at 21:08

0 Answers0