简体   繁体   English

如何使用Maven阴影插件仅创建一个具有所有依赖项的可执行jar,而不是两个

[英]How to create only one executable jar with all dependencies inside it using maven shaded plugin instead of two

project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>SoclePDCFDR</groupId>
    <artifactId>SoclePDCFDR</artifactId>
    <version>0.0.1-SNAPSHOT</version>



    <dependency>
        <groupId>ojdbc</groupId>
        <artifactId>ojdbc</artifactId>
        <version>14</version>
        <type>pom</type>
    </dependency>


<build>

    <!-- <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources> -->
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                       <finalName>Test</finalName>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <shadedClassifierName>jar-with-dependencies</shadedClassifierName>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <manifestEntries>
                                    <Main-Class>com.sfdr.ms.pdc.FilesManagementMain</Main-Class>
                                <Class-Path>.</Class-Path>
                                </manifestEntries>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Kindly make use of the below plugin as reference, 请使用以下插件作为参考,

<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.bitsWilp.BITSPilani</mainClass>
                        </manifest>
                    </archive>
                    <finalName>bitsWILP</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
</plugin>

Ref: https://github.com/ramasamykasiviswanathan/BITSWilpAPI/blob/newAPIimpl/pom.xml 参考: https : //github.com/ramasamykasiviswanathan/BITSWilpAPI/blob/newAPIimpl/pom.xml

I coded for an API which has all dependencies bundled up. 我为捆绑了所有依赖关系的API进行了编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Maven创建一个没有依赖关系的可执行jar? - How can I create an executable jar without dependencies using Maven? 如何使用 Maven 创建具有依赖关系的可执行 JAR? - How can I create an executable JAR with dependencies using Maven? Maven插件创建可执行jar,依赖项未解包(带jar的jar) - Maven plugin to create executable jar with dependencies not unpacked (jar with jars) 如何使用 maven 和系统依赖项创建可执行的 jar? - How to create executable jar with maven and system dependencies? maven-shade-plugin:如何将所有依赖项和自定义本地jar添加到可执行jar? - maven-shade-plugin : how add all dependencies and custom local jar to executable jar? 使用Maven将Java代码和依赖项组合到一个jar(可执行jar)中 - Combine java code and dependencies into one jar (executable jar) using maven 如何访问Maven着色jar中的文件 - How to access file inside maven shaded jar 如何使用Maven在jar的子文件夹中创建具有依赖项的可执行jar? - How can I create an executable jar with dependencies in sub folder in jar using Maven? 创建一个可执行 JAR 及其所有依赖项,并使用 maven 程序集放入 ZIP 文件 - Create an executable JAR with all its dependencies and put in the ZIP file using maven assembly 如何创建包含所有 Maven 依赖项的不可执行 JAR 文件 - How to create a non-executable JAR file that includes all Maven dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM