简体   繁体   中英

Copy resulting fat jar to another target folder in Spring boot project

I have Spring boot project. Everything is built OK in /target folder but I'd like to change destination folder. I tried to use maven-jar-plugin as described below but it copies only jar with compiled classes of project (small jar).

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
        <outputDirectory>${maven.multiModuleProjectDirectory}/output/bin</outputDirectory>
    </configuration>
</plugin>

Instead I want to make Maven to copy FAT jar . Maven builds FAT jar and puts the Jar to /target folder. How to change destination?

UPDATE 1

this is needed by project requirements - need to build folder structure with properties , bash scripts(as entry point) and fat jar :

在此处输入图像描述

Try to add this plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>jar-with-dependencies</shadedClassifierName>
                <outputDirectory>${maven.multiModuleProjectDirectory}/output/bin</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM