1

I am trying to create a runnale openliberty server as part of my release process. I have a a multi module maven project with a submodule dedicated to packaging the server as a runnable. When I do a mvn clean package a lovely executable jar is produced which bundles one of the other submodules (war). The problem I am facing is when I do a maven deploy to our asset repo the packaged server is being uploaded as a zip file rather than a jar file. Does anyone know how to get the deploy plugin to upload the jar?

Here is a sample pom file

<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>
Charles
  • 4,372
  • 9
  • 41
  • 80
  • Are you using the Maven Deploy Plugin? Can you post your Maven Deploy Plugin configuration? – Charles Oct 18 '18 at 15:30
  • @Charles there is nothing special in the deploy plugin config ... just a base plugin reference. – Edwin Quai Hoi Oct 24 '18 at 06:03
  • So I'm confused since the Maven Deploy Plugin shouldn't modify anything about the project artifact....so how could the build have produced a JAR but then the deploy plugin deploys a zip? Where did that zip come from? – Charles Oct 24 '18 at 14:19
  • @Charles the liberty-maven-plugin has been configured to produce a runnable jar file which contains the app server + the app. I would like it to be the asset that gets deployed into my maven repo but I think the packaging type makes the deploy plugin think it should be a zip – Edwin Quai Hoi Oct 29 '18 at 13:42
  • [Here](https://github.com/WASdev/ci.maven/blob/master/liberty-maven-plugin/src/main/java/net/wasdev/wlp/maven/plugins/server/PackageServerMojo.java) is the package server mojo. If you look at the code, you can see that if you have `include=runnable` and packaging type as `liberty-assembly`, it will set the project artifact to the runnable JAR, with the .jar extension - and that is what you're seeing in the target directory. As far as I know the deploy plugin only deploys existing artifacts, it doesn't create new ones. So I'm not sure how you're producing a JAR but deploying a WAR. – Charles Oct 30 '18 at 19:42
  • This is why I would like to see your deploy configuration, in case something stands out to me. In fact if you could reproduce your entire pom, that would be the most helpful. Everything looks right from the sample pom that you posted. – Charles Oct 30 '18 at 19:45

1 Answers1

1

I don't have an answer to your question but an explanation why this happens. Every packaging type (jar, war, liberty-assembly) defines a fixed extension for the artifact(s) it creates. The liberty-assembly types defines zip as it extension. This extension is used by the maven-install-plugin and maven-deploy-plugin regardless how the local file is names. I did quite some code digging but couldn't find a way to change this. It's probably sth. that only liberty-maven-plugin can change/fix.

sithmein
  • 437
  • 3
  • 11