0

在我的“打包”步骤结束时,我得到了 2 个罐子:一个由“maven-jar-plugin”制作,一个由“maven-shade-plugin”制作的 uber/fat/shaded 一个。

myapp.jarmyapp-uber.jar

在“安装”阶段,两个 jar 都被复制到本地存储库。而且我几乎没有(=没有)理由将 uber jar 复制到我的本地存储库。此外,除非放在我的硬盘上。而且,无论如何,它将在“部署”阶段复制到正确的位置。

以下是这些说明:

<!-- 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>
  

那么如何防止 uber jar 被复制到本地存储库?

谢谢。

4

0 回答 0