Copy spring boot packaged fatjar to another directory

Offen
#20 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Dokumentation
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
spring-boot
Bereich
documentation

Rechercherichtung

Review the repository's existing programming-tip structure before deciding where this material belongs. Use the Maven install-phase guidance and the three listed copying options as the source, and consider the work done when the fat JAR copying instructions are added in the repository's established format with the relevant command and phase details.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

There are at last 3 options to fulfill this case.

Option 1.By maven-resource-plugin:
https://stackoverflow.com/questions/6689511/how-to-place-the-output-jar-into-another-folder-with-maven#comment7915129_6689511

https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
    <executions>
        <execution>
            <id>copy-files-on-build</id>
            <phase>install</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/[TO-DIR]</outputDirectory>
                <resources>
                    <resource>
                        <directory>[FROM-DIR]</directory>
                        <!--<include>*.[MIME-TYPE]</include>-->
                        <filtering>false</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

Option 2: By maven assembly plugin

https://maven.apache.org/plugins/maven-assembly-plugin/usage.html

        <!-- when running  mvn install , copy my-web.jar to APP-META/docker/config folder automatically(for docker build)  -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>copy-installed</id>
                        <phase>install</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <type>${project.packaging}</type>
                                    <destFileName>my-web.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>../APP-META/docker-config/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Option 3: By ant run plugin
https://stackoverflow.com/questions/6689511/how-to-place-the-output-jar-into-another-folder-with-maven#comment7915129_6689511

Notes: You should execute the goal at the install phase, not the package phase. The origin jar file in install phase does not contain necessary dependencies in the file content. while the jar file in the install phase contains the necessary dependencies in it which is repackaged by spring boot plugin.

install

maven command
run mvn package install instead of mvn package, to copy the final jar to expected output directory.

Vorherrschende Sprache
Python
Sterne
5
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus davideuler/programming-tips

Alle Issues in davideuler/programming-tips

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.