OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
125 stars 90 forks source link

liberty:package should create server, install features and deploy app implicitly #667

Open yeekangc opened 4 years ago

yeekangc commented 4 years ago

Like liberty:run, liberty:package should create the server, install the needed features and deploy the application implicitly if necessary.

Users can then easily run "mvn liberty:package" to obtain a runnable jar or a server package for use. Otherwise, users have to bind goals themselves or use and/or customize a parent POM with the necessary lifecycle binding.

This has uses in the Spring Boot scenarios. Other runtimes/frameworks do not appear to require separate goals either.

FYI, @gkwan-ibm @Emily-Jiang.

yeekangc commented 4 years ago

https://draft-guides.mybluemix.net/guides/spring-boot.html is an example where simplification can be provided so users don't have to bind the goals themselves.

lulseged commented 4 years ago

3.1 which is the latest and is packaging correctly. But can not start or run packaged application. liberty:run is broken between 3.0.1 and 3.1. It should work not only with spring boot but should work with IDEs and others.

yeekangc commented 4 years ago

@lulseged, can you elaborate on the issue(s) you ran into when you "start or run" the "packaged application"?

Yes, we aren't looking at this for Spring Boot only but for common scenarios and tools in general.

lulseged commented 4 years ago

Packaging works fine. When packaging, my application (ear) is copied to $WLP/usr/shared/apps/ Configuration files(bootstrap.properties and server.xml) are copied to $WLP/usr/servers/inventory/ So far so good. It works same with both 3.0.1 and 3.1.

The problem comes when running packaged application with liberty-maven-plugin: liberty:run With 3.0.1, I see liberty-maven-plugin executing:

[INFO] --- liberty-maven-plugin:3.0.1:run (start) @ inventory-resource-ear --- [INFO] CWWKM2102I: Using pre-installed assembly : D:\appz\wlp-19.0.0.10. [INFO] CWWKM2102I: Using serverName : inventory. [INFO] CWWKM2102I: Using serverDirectory : D:\appz\wlp-19.0.0.10\usr\servers\inventory. [INFO] CWWKM2107I: Installation type is pre-existing; skipping installation. [INFO] Copying 6 files to D:\appz\wlp-19.0.0.10\usr\servers\inventory [INFO] CWWKM2144I: Update server configuration file server.xml from E:\banking\inventory\inventory-resource-ear\target\classes\config\server.xml. [INFO] CWWKM2144I: Update server configuration file bootstrap.properties from E:\banking\inventory\inventory-resource-ear\target\classes\config\bootstrap.properties. [INFO] CWWKM2144I: Update server configuration file server.env from E:\banking\inventory\inventory-resource-ear\target\classes\config\server.env. [INFO] CWWKM2001I: server.config.dir is D:\appz\wlp-19.0.0.10\usr\servers\inventory. [INFO] CWWKM2001I: server.output.dir is D:\appz\wlp-19.0.0.10\usr\servers\inventory. [INFO] CWWKM2001I: Invoke command is ["D:\appz\wlp-19.0.0.10\bin\server.bat", run, inventory].

With 3.1 it is going wrong:

[INFO] --- liberty-maven-plugin:3.1:run (start) @ inventory-resource-ear --- [INFO] CWWKM2102I: Using pre-installed assembly : D:\appz\wlp-19.0.0.10. [INFO] CWWKM2102I: Using serverName : inventory. [INFO] CWWKM2102I: Using serverDirectory : D:\appz\wlp-19.0.0.10\usr\servers\inventory. [INFO] Running maven-compiler-plugin:compile [INFO] Toolchain in maven-compiler-plugin: JDK[d:\appz\java\jdk-11.0.5.10] [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to E:\banking\inventory\inventory-resource-ear\target\classes [INFO] skip execution goal configuration validation for maven-resources-plugin:resources [INFO] Running maven-resources-plugin:resources

Reported error is: Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.1:run (start) on project inventory-resource-ear: Unable to execute mojo

[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.1:run (start) on project inventory-resource-ear: Unable to execute mojo: Unable to parse configuration of mojo org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources for parameter goal: Cannot find 'goal' in class org.apache.maven.plugins.resources.ResourcesMojo -> [Help 1]

It works fine if I use start instead of run. But start runs in the background.

BR Lulseged

cherylking commented 4 years ago

@lulseged Can you open a separate issue for this and provide your pom.xml? Also, I just wanted to point out that the start and run goals do not use the packaged server from the package goal. They use the local directory in which the Liberty server was installed/created and the application was built.

lulseged commented 4 years ago

Start/run will use what is packaged in the local liberty installation.

I have opened a separate issue. #685

dougbreaux commented 1 month ago

It looks like for now I have to run this to get the features installed and the app deployed before making the runnable jar. Which was definitely not expected and doesn't seem to match the online references like https://github.com/openliberty/guide-getting-started#running-the-application-from-a-minimal-runnable-jar

$ mvn package liberty:install-feature liberty:deploy liberty:package -Dinclude=runnable
scottkurz commented 1 month ago

It looks like for now I have to run this to get the features installed and the app deployed before making the runnable jar. Which was definitely not expected and doesn't seem to match the online references like https://github.com/openliberty/guide-getting-started#running-the-application-from-a-minimal-runnable-jar

The sequence of commands in this guide can't necessarily be executed in any order.

Still, I appreciate the point. We have discussed an overlapping issue too in #739 and I suggested supporting a 'skipServerStart' flag, so if we did that you could have:

mvn liberty:run -DskipServerStart liberty:package -Dinclude=runnable

I think this might be good enough, and might make a separate config for 'package' unnecessary, (in that issue and other dups we noted the package use case).