如何跳过maven中的JAR部署并仅部署程序集

时间:2017-12-06 11:47:18

标签: maven

我的项目打包到Spring Boot fat-jar。

我配置了2个额外的构建插件:

  • 使用Launch4j Plugin生成可执行文件(它获取生成的fat-jar并将其嵌入可执行文件中)
  • 以ZIP形式组装生成的可执行文件

现在我想将程序集生成zip部署到我的maven存储库。

这是我的build部分:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.akathist.maven.plugins.launch4j</groupId>
            <artifactId>launch4j-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>l4j-clui</id>
                    <phase>package</phase>
                    <goals>
                        <goal>launch4j</goal>
                    </goals>
                    <configuration>
                        <headerType>console</headerType>
                        <outfile>target/${project.build.finalName}.exe</outfile>
                        <jar>target/${project.build.finalName}.jar</jar>
                        <manifest>launch4j/besser-updater.manifest</manifest>
                        <classPath>
                            <mainClass>org.springframework.boot.loader.JarLauncher</mainClass>
                        </classPath>
                        <jre>
                            <minVersion>1.8.0_131</minVersion>
                            <jdkPreference>preferJre</jdkPreference>
                            <runtimeBits>32/64</runtimeBits>
                        </jre>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptors>
                            <descriptor>launch4j/assembly.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

如何配置部署阶段以忽略 jar 工件并仅部署 zip 程序集文件?

2 个答案:

答案 0 :(得分:3)

我找到了解决方案。我只是忽略了default-deploy执行ID。

<build>
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
                <!-- disable standard deploy -->
                <execution>
                    <id>default-deploy</id>
                    <phase>none</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

答案 1 :(得分:0)

您是使用程序集部署还是在谈论简单地避免在远程仓库中安装依赖项?

如果你在谈论组装插件,你可以轻松地用它来排除罐子

https://maven.apache.org/plugins/maven-assembly-plugin/examples/single/including-and-excluding-artifacts.html

您可以避免像这样部署单个工件:

onPositionChanged() {
    const position = this.marker.getPosition();

    // do something with position
}

render() {
    return <Marker
        onPositionChanged={ ::this.onPositionChanged }
        ref={input => this.marker = input}
    />
}

然后,您可以指定要部署的特定文件,包括部署插件配置。

参考:http://prystash.blogspot.ie/2009/06/maven-excluding-module-from-deploy.html

希望有所帮助......