【问题标题】:OpenLiberty Maven PluginOpenLiberty Maven 插件
【发布时间】:2018-10-18 03:49:17
【问题描述】:

我正在尝试创建一个 runnale openliberty 服务器作为我发布过程的一部分。我有一个多模块 maven 项目,其中有一个子模块,专门用于将服务器打包为可运行文件。当我执行mvn clean package 时,会生成一个可爱的可执行 jar,它捆绑了其他子模块之一(war)。我面临的问题是,当我将 maven 部署到我们的资产仓库时,打包的服务器被上传为 zip 文件,而不是 jar 文件。有谁知道如何让部署插件上传jar

这是一个示例 pom 文件

<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>
    <parent>
        <groupId>au.com.xxxx.xxxx</groupId>
        <artifactId>xxx-backend-parent</artifactId>
        <version>0.0.16-SNAPSHOT</version>
    </parent>
    <artifactId>xxxx-openliberty-server</artifactId>
    <packaging>liberty-assembly</packaging>
    <name>fusion-openliberty-server</name>
    <description>Runnable Jar containing xxxxand the OpenLiberty applictaion server</description>


    <dependencies>
        <!-- Package xxxx-application.war with server assembly -->
        <dependency>
            <groupId>au.com.xxx.xxx</groupId>
            <artifactId>xxxx-application</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Enable liberty-maven-plugin -->
            <plugin>
                <groupId>net.wasdev.wlp.maven.plugins</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>2.6.1</version>
                <extensions>true</extensions>
                <configuration>
                    <assemblyArtifact>
                        <groupId>io.openliberty</groupId>
                        <artifactId>openliberty-javaee8</artifactId>
                        <version>18.0.0.3</version>
                        <type>zip</type>
                    </assemblyArtifact>
                    <include>runnable</include>
                    <serverName>xxx</serverName>
                    <appsDirectory>apps</appsDirectory>
                    <serverEnv>${basedir}/src/main/resources/server.env</serverEnv>
                    <configFile>${basedir}/src/main/resources/server.xml</configFile>
                    <jvmOptionsFile>${basedir}/src/main/resources/jvm.options</jvmOptionsFile>
                    <bootstrapProperties>
                        <app.context.root>xxx-app</app.context.root>
                        <default.http.port>5000</default.http.port>
                        <default.https.port>5443</default.https.port>
                    </bootstrapProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

【问题讨论】:

  • 您在使用 Maven 部署插件吗?您可以发布您的 Maven 部署插件配置吗?
  • @Charles 在部署插件配置中没有什么特别之处......只是一个基本插件参考。
  • 所以我很困惑,因为 Maven 部署插件不应该修改有关项目工件的任何内容....那么构建如何生成 JAR 但部署插件部署了 zip?那个拉链是从哪里来的?
  • @Charles liberty-maven-plugin 已配置为生成一个可运行的 jar 文件,其中包含应用程序服务器 + 应用程序。我希望它成为部署到我的 maven 存储库中的资产,但我认为打包类型使部署插件认为它应该是一个 zip
  • Here 是包服务器 mojo。如果您查看代码,您可以看到如果您有include=runnable 和包装类型为liberty-assembly,它会将项目工件设置为可运行的JAR,扩展名为.jar - 这就是您所看到的在目标目录中。据我所知,部署插件只部署现有的工件,它不会创建新的工件。所以我不确定你是如何生成 JAR 而是如何部署 WAR 的。

标签: maven open-liberty liberty-maven-plugin


【解决方案1】:

我没有你的问题的答案,但解释了为什么会发生这种情况。每种打包类型(jar、war、liberty-assembly)都为其创建的工件定义了一个固定的扩展。 liberty-assembly 类型将zip 定义为它的扩展名。无论本地文件的名称如何,maven-install-pluginmaven-deploy-plugin 都使用此扩展名。我做了很多代码挖掘,但找不到改变它的方法。大概是……只有liberty-maven-plugin 可以更改/修复。

【讨论】:

    猜你喜欢
    • 2022-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 2013-03-06
    • 2010-10-05
    • 2011-04-16
    相关资源
    最近更新 更多