diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 27ea06464..c35ba3c0c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,13 +22,13 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.6, 23.0.0.3] + RUNTIME_VERSION: [23.0.0.6, 23.0.0.9] java: [17, 11, 8] exclude: - java: 8 - RUNTIME_VERSION: 23.0.0.3 + RUNTIME_VERSION: 23.0.0.6 - java: 17 - RUNTIME_VERSION: 23.0.0.3 + RUNTIME_VERSION: 23.0.0.6 name: ${{ matrix.RUNTIME }} ${{ matrix.RUNTIME_VERSION }}, Java ${{ matrix.java }}, Linux steps: # Checkout repos @@ -80,13 +80,13 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.6, 23.0.0.3] + RUNTIME_VERSION: [23.0.0.6, 23.0.0.9] java: [17, 11, 8] exclude: - java: 8 - RUNTIME_VERSION: 23.0.0.3 + RUNTIME_VERSION: 23.0.0.6 - java: 17 - RUNTIME_VERSION: 23.0.0.3 + RUNTIME_VERSION: 23.0.0.6 name: ${{ matrix.RUNTIME }} ${{ matrix.RUNTIME_VERSION }}, Java ${{ matrix.java }}, Windows steps: # Checkout repos diff --git a/README.md b/README.md index d4eea4e13..5af33a49a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The Liberty Maven plugin supports install and operational control of Liberty run ## Build -Use Maven 3.5.0 or later to build the Liberty Maven plugin. +As of version 3.9 of the plugin, you must use Maven 3.8.6 or later to build the Liberty Maven plugin. We conveniently provide the [maven-wrapper](https://maven.apache.org/wrapper/maven-wrapper-plugin/index.html) script, so you do not need to download maven yourself if you are not using it yet. * `./mvnw install` : builds the plugin, skipping all tests @@ -32,7 +32,7 @@ We conveniently provide the [maven-wrapper](https://maven.apache.org/wrapper/mav ### Liberty Maven Plugin -The Liberty Maven Plugin provides a number of goals for managing a Liberty server and applications. Maven 3.5.0 or later is recommended to use the Liberty Maven Plugin. +The Liberty Maven Plugin provides a number of goals for managing a Liberty server and applications. As of version 3.9 of the plugin, Maven 3.8.6 or later is required to use the Liberty Maven Plugin. #### Java Support @@ -55,7 +55,7 @@ To enable Liberty Maven Plugin in your project add the following to your `pom.xm io.openliberty.tools liberty-maven-plugin - 3.8.1 + 3.9 ... @@ -104,12 +104,12 @@ Example using the `runtimeArtifact` parameter to install a WebSphere Liberty run io.openliberty.tools liberty-maven-plugin - 3.8.1 + 3.9 com.ibm.websphere.appserver.runtime wlp-webProfile8 - 23.0.0.2 + 23.0.0.9 zip @@ -124,12 +124,12 @@ Example using the `runtimeArtifact` parameter to install an Open Liberty beta ru io.openliberty.tools liberty-maven-plugin - 3.8.1 + 3.9 io.openliberty.beta openliberty-runtime - 23.0.0.3-beta + 23.0.0.10-beta zip @@ -238,7 +238,7 @@ Example: io.openliberty.tools liberty-maven-plugin - [3.8.1,) + 3.9 true /opt/ibm/wlp diff --git a/docs/dev.md b/docs/dev.md index 045eea7c8..a4f79e306 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -39,7 +39,7 @@ Dev mode can be run on a single Maven module or on a multi module Maven project To start dev mode on a multi module project, run the following from the directory containing the multi module `pom.xml`: ``` -$ mvn io.openliberty.tools:liberty-maven-plugin:3.4:dev +$ mvn io.openliberty.tools:liberty-maven-plugin:3.9:dev ``` To start dev mode on a multi module project by using the short-form `liberty` name for the Liberty Maven plugin: @@ -125,50 +125,50 @@ Integration tests can read the following system properties to obtain information #### devc, Container Mode -Start a Liberty server in a local container using the Dockerfile that you provide. An alternative to the `devc` goal is to specify the `dev` goal with the `-Dcontainer` option. +Start a Liberty server in a local container using the Containerfile or Dockerfile that you provide. An alternative to the `devc` goal is to specify the `dev` goal with the `-Dcontainer` option. When dev mode runs with container support, it builds a container image and runs the container. You can examine the commands that it uses to build and run the container by viewing the console output of dev mode. Additionally, it still provides the same features as the `dev` goal. It monitors files for changes and runs tests either automatically or on demand. This mode also allows you to attach a debugger to work on your application. You can review the logs generated by your server in the Liberty directory in your project e.g. target/liberty/wlp/usr/servers/defaultServer/logs. -N.B. starting in 3.6.1, dev mode invokes `generate-features` if the `generateFeatures` configuration parameter is set to true. Ensure that the `generated-features.xml` configuration file is copied to your Docker image via your Dockerfile. +N.B. starting in 3.6.1, dev mode invokes `generate-features` if the `generateFeatures` configuration parameter is set to true. Ensure that the `generated-features.xml` configuration file is copied to your container image via your Containerfile/Dockerfile. ```dockerfile COPY --chown=1001:0 target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/generated-features.xml /config/configDropins/overrides/ ``` -If on Linux, it is recommended that you copy the entire `configDropins/overrides` directory to your Docker image via your Dockerfile. +If on Linux, it is recommended that you copy the entire `configDropins/overrides` directory to your container image via your Containerfile/Dockerfile. ```dockerfile COPY --chown=1001:0 target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides /config/configDropins/overrides ``` ###### Prerequisites -You need to install the Docker runtime locally (Docker Desktop on macOS or Windows, or Docker on Linux) to use this Maven goal. The installed Docker Client and Engine versions must be 18.03.0 or higher. +You need to install Podman or the Docker runtime (Docker Desktop on macOS or Windows, or Docker on Linux) locally to use this Maven goal. If using Podman, version 4.4.4 or higher is required. If using Docker, the installed Docker Client and Engine versions must be 18.03.0 or higher. -###### Dockerfile +###### Containerfile/Dockerfile -Your project must have a Dockerfile to use dev mode in container mode. A sample Dockerfile is shown in [Building an application image](https://github.com/openliberty/ci.docker/#building-an-application-image). The parent image must be one of the [Open Liberty container images](https://github.com/openliberty/ci.docker/#container-images), or an image using Linux with Open Liberty configured with the same paths as the Open Liberty container images. The Dockerfile must copy the application .war file and the server configuration files that the application requires into the container. +Your project must have a Containerfile or Dockerfile to use dev mode in container mode. An example of container configuration is shown in [Building an application image](https://github.com/openliberty/ci.docker/#building-an-application-image). The parent image must be one of the [Open Liberty container images](https://github.com/openliberty/ci.docker/#container-images), or an image using Linux with Open Liberty configured with the same paths as the Open Liberty container images. The container config file must copy the application .war file and the server configuration files that the application requires into the container. -Dev mode works with a temporary, modified copy of your Dockerfile to allow for hot deployment during development as detailed below. When dev mode starts up, it pulls the latest version of the parent image defined in the Dockerfile, builds the container image, then runs the container. Note that the context of the `docker build` command used to generate the container image is the directory containing the Dockerfile, unless the `dockerBuildContext` parameter is specified. When dev mode exits, the container is stopped and deleted, and the logs are preserved in the directory mentioned above. +Dev mode works with a temporary, modified copy of your container config file to allow for hot deployment during development as detailed below. When dev mode starts up, it pulls the latest version of the parent image defined in the container config file, builds the container image, then runs the container. Note that the context of the container's `build` command used to generate the container image is the directory containing the container config file, unless the `containerBuildContext` parameter is specified. When dev mode exits, the container is stopped and deleted, and the logs are preserved in the directory mentioned above. -Hot deployment is made possible because the application is installed as a loose application WAR. This method uses a file type of `.war.xml` which is functionally equivalent to the `.war` file. Dev mode only supports the application under development in the current project so to avoid application conflicts, dev mode removes all Dockerfile commands that copy or add a `.war` file. +Hot deployment is made possible because the application is installed as a loose application WAR. This method uses a file type of `.war.xml` which is functionally equivalent to the `.war` file. Dev mode only supports the application under development in the current project so to avoid application conflicts, dev mode removes all commands that copy or add a `.war` file from the container config file. -The `.war.xml` file is generated in the `defaultServer/apps` or the `defaultServer/dropins` directory so these directories are mounted in the container. Therefore any files that the Dockerfile may have copied into these directories in the container image will not be accessible. +The `.war.xml` file is generated in the `defaultServer/apps` or the `defaultServer/dropins` directory so these directories are mounted in the container. Therefore any files that the container config file may have copied into these directories in the container image will not be accessible. -There are other features of the Dockerfile which are not supported for hot deployment of changes. See the section on [File Tracking](#File-Tracking) for details. +There are other features of the Containerfile/Dockerfile which are not supported for hot deployment of changes. See the section on [File Tracking](#File-Tracking) for details. Finally, if dev mode detects the Liberty command `RUN configure.sh` it will insert the environment variable command `ENV OPENJ9_SCC=false` in order to skip the configuration of the [shared class cache](https://github.com/OpenLiberty/ci.docker/#openj9-shared-class-cache-scc). ###### File Tracking -Dev mode offers different levels of file tracking and deployment depending on the way the file is specified in the Dockerfile. +Dev mode offers different levels of file tracking and deployment depending on the way the file is specified in the Containerfile/Dockerfile. 1. When you use the COPY command on an individual file, dev mode can track file changes and hot deploy them to the container subject to the limitations below. **This is the recommended way to deploy files for dev mode,** so that you can make changes to those files at any time without needing to rebuild the image or restart the container. - E.g. `COPY target/liberty/wlp/usr/servers/defaultServer/server.xml /config/` - - Note that the Dockerfile must copy only one `.war` file for the application. See the section on [Dockerfiles](#Dockerfile) for details. + - Note that the container config file must copy only one `.war` file for the application. See the section on [container config files](#Containerfile/Dockerfile) for details. 2. You can use the COPY command to deploy an entire directory and its sub-directories. In this case, dev mode will detect file changes and automatically rebuild the image and restart the container upon changes. 3. The ADD command can be used on individual files, including tar files, as well as on directories. Again, dev mode will rebuild the image and restart the container when it detects file changes. -4. Certain Dockerfile features are not supported by dev mode. In these cases, the files specified are not tracked. If you change these files, you must rebuild the image and restart the container manually. **Type r and press Enter to rebuild the image and restart the container.** +4. Certain Containerfile/Dockerfile features are not supported by dev mode. In these cases, the files specified are not tracked. If you change these files, you must rebuild the image and restart the container manually. **Type r and press Enter to rebuild the image and restart the container.** - variable substitution used in the COPY or ADD command e.g. `$PROJECT/config` - wildcards used in the COPY or ADD command e.g. `target/liberty/wlp/usr/servers/defaultServer/configDropins/*` - paths relative to WORKDIR e.g. `WORKDIR /other/project` followed by `COPY test.txt relativeDir/` - - files copied from a different part of a multistage Docker build e.g. `COPY --from=` + - files copied from a different part of a multistage Podman or Docker build e.g. `COPY --from=` ###### Console Actions @@ -177,7 +177,7 @@ While dev mode is running in container mode, perform the following in the comman * g - toggle the automatic generation of features, type g and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. * o - optimize the list of generated features, type o and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. * Enter - run tests on demand, press Enter. -* r - rebuild the Docker image and restart the container, type r and press Enter. +* r - rebuild the container image and restart the container, type r and press Enter. * h - see the help menu for available actions, type h and press Enter. * q - stop the server and quit dev mode, press Ctrl-C or type q and press Enter. @@ -188,13 +188,29 @@ The following limitations apply to Linux: * In dev mode, the Open Liberty server runs in the container on the UID (user identifier) of the current user. This is so that the server can access the configuration files from your project and you can access the Open Liberty log files. Outside of dev mode, the Open Liberty server will run on the UID specified in the Docker image. * Use of editors like `vim`: when you edit a configuration file with `vim` it will delete the file and rewrite it when you save. This necessitates a container restart. To avoid the restart edit your .vimrc file and add the line `set backupcopy=yes` +### Podman Troubleshooting +Podman VMs may need to be configured to run in rootful mode depending on how permissions are used in the container. This can be done with the following commands: +``` +podman machine stop +podman machine set --rootful=true +podman machine start +``` + +If permissions issues continue with Podman the machine may need to be deleted and reinitialized. This can be done as follows: +``` +podman machine stop +podman machine rm +podman machine init --rootful=true +podman machine start +``` + ###### Multiple Modules The `devc` goal is supported with multi module Maven projects in the same way as the [`dev` goal](#multiple-modules) but substitute `dev` for `devc` in the examples. ###### Examples -Start dev mode with the server in a container using the Dockerfile in the project root. +Start dev mode with the server in a container using the Containerfile/Dockerfile in the project root. ``` $ mvn liberty:devc ``` @@ -205,11 +221,11 @@ Customizing the container configuration in `pom.xml`. Note that changing these io.openliberty.tools liberty-maven-plugin - 3.4 + 3.9 true - -e key=value - myDockerfile + -e key=value + myDockerfile ``` @@ -225,19 +241,19 @@ The container ports and mapped local ports will be displayed when dev mode start If you use the default ports and you run multiple instances of dev mode in container mode, the containers will use different local port mappings to avoid errors. The first instance will use the local ports 9080 and 9443, the second instance will use 9081 and 9444, and so on. -To publish additional ports, add them to the `dockerRunOpts` parameter either in the `pom.xml` file or on the `mvn` command line. For example: +To publish additional ports, add them to the `containerRunOpts` parameter either in the `pom.xml` file or on the `mvn` command line. For example: ``` --DdockerRunOpts="-p 8000:8000" +-DcontainerRunOpts="-p 8000:8000" ``` -To map the container ports to specific local ports that are not the default, use the `skipDefaultPorts` parameter and specify Docker port mappings using the `dockerRunOpts` parameter: +To map the container ports to specific local ports that are not the default, use the `skipDefaultPorts` parameter and specify container port mappings using the `containerRunOpts` parameter: ``` --DskipDefaultPorts -DdockerRunOpts="-p 10000:9080 -p 10001:9443" +-DskipDefaultPorts -DcontainerRunOpts="-p 10000:9080 -p 10001:9443" ``` -Alternatively, you can have Docker map random ephemeral local ports to the exposed container ports as follows. +Alternatively, you can have Podman/Docker map random ephemeral local ports to the exposed container ports as follows. ``` --DskipDefaultPorts -DdockerRunOpts="-P" +-DskipDefaultPorts -DcontainerRunOpts="-P" ``` Note that you do not need to specify an alternative for the debug port. Dev mode will automatically find an open local port to map the container debug port to. @@ -248,10 +264,10 @@ These parameters are available in addition to the ones in the `dev` section abov | Parameter | Description | Required | | -------- | ----------- | ------- | -| container | If set to `true`, run the server in the container specified by the `dockerfile` parameter. Setting this to `true` is equivalent to using the `devc` goal. The default value is `false` when the `dev` goal is used, and `true` when the `devc` goal is used. | No | -| dockerRunOpts | Specifies options to add to the `docker run` command when using dev mode to launch your server in a container. For example, `-e key=value` is recognized by `docker run` to define an environment variable with the name `key` and value `value`. | No | -| dockerfile | Location of a Dockerfile to be used by dev mode to build the Docker image for the container that will run your Liberty server. The default value is `Dockerfile`. | No | -| dockerBuildContext | The Docker build context directory to be used by dev mode for the `docker build` command. The default location is the directory of the Dockerfile. | No | -| dockerBuildTimeout | Maximum time to wait (in seconds) for the completion of the Docker operation to build the image. The value must be an integer greater than 0. The default value is `600` seconds. | No | -| skipDefaultPorts | If set to `true`, dev mode will not publish the default Docker port mappings of `9080:9080` (HTTP) and `9443:9443` (HTTPS). Use this option if you would like to specify alternative local ports to map to the exposed container ports for HTTP and HTTPS using the `dockerRunOpts` parameter. | No | -| keepTempDockerfile | If set to `true`, dev mode will not delete the temporary modified copy of your Dockerfile used to build the Docker image. This file is handy in case you need to debug the process of building the Docker image. The path of the temporary Dockerfile can be seen when dev mode displays the `docker build` command. The default value is `false`.| No | +| container | If set to `true`, run the server in the container specified by the `containerfile` parameter. Setting this to `true` is equivalent to using the `devc` goal. The default value is `false` when the `dev` goal is used, and `true` when the `devc` goal is used. | No | +| containerRunOpts | Specifies options to add to the `run` command when using dev mode to launch your server in a container. For example, `-e key=value` is recognized by `run` to define an environment variable with the name `key` and value `value`. This attribute replaces the deprecated `dockerRunOpts` attribute. | No | +| containerfile | Location of a Containerfile/Dockerfile to be used by dev mode to build the image for the container that will run your Liberty server. The default value is `Containerfile` or `Dockerfile`. This attribute replaces the deprecated `dockerfile` attribute. | No | +| containerBuildContext | The container build context directory to be used by dev mode for the `build` command. The default location is the directory of the Containerfile/Dockerfile. This attribute replaces the deprecated `dockerBuildContext` attribute. | No | +| containerBuildTimeout | Maximum time to wait (in seconds) for the completion of the container operation to build the image. The value must be an integer greater than 0. The default value is `600` seconds. This attribute replaces the deprecated `dockerBuildTimeout` attribute. | No | +| skipDefaultPorts | If set to `true`, dev mode will not publish the default container port mappings of `9080:9080` (HTTP) and `9443:9443` (HTTPS). Use this option if you would like to specify alternative local ports to map to the exposed container ports for HTTP and HTTPS using the `containerRunOpts` parameter. | No | +| keepTempContainerfile | If set to `true`, dev mode will not delete the temporary modified copy of your Containerfile used to build the contianer image. This file is handy in case you need to debug the process of building the container image. The path of the temporary Containerfile can be seen when dev mode displays the container's `build` command. The default value is `false`. This attribute replaces the deprecated `keepTempDockerfile` attribute. | No | diff --git a/docs/test-start.md b/docs/test-start.md index b9ed0218b..46015fd36 100644 --- a/docs/test-start.md +++ b/docs/test-start.md @@ -25,7 +25,7 @@ Example: io.openliberty.tools liberty-maven-plugin - [3.0.1,) + 3.9 true true diff --git a/docs/test-stop.md b/docs/test-stop.md index 7e5ce3254..4b1458a38 100644 --- a/docs/test-stop.md +++ b/docs/test-stop.md @@ -25,7 +25,7 @@ Example: io.openliberty.tools liberty-maven-plugin - [3.0.1,) + 3.9 true true diff --git a/liberty-maven-app-parent/pom.xml b/liberty-maven-app-parent/pom.xml index 84517cb77..67afcf33b 100644 --- a/liberty-maven-app-parent/pom.xml +++ b/liberty-maven-app-parent/pom.xml @@ -20,7 +20,7 @@ io.openliberty.tools liberty-maven - 3.8.3-SNAPSHOT + 3.10-SNAPSHOT liberty-maven-app-parent @@ -44,7 +44,7 @@ io.openliberty.tools liberty-maven-plugin - 3.8.3-SNAPSHOT + 3.10-SNAPSHOT stop-before-clean diff --git a/liberty-maven-plugin/pom.xml b/liberty-maven-plugin/pom.xml index c9b24968d..7ce934350 100644 --- a/liberty-maven-plugin/pom.xml +++ b/liberty-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.openliberty.tools liberty-maven - 3.8.3-SNAPSHOT + 3.10-SNAPSHOT liberty-maven-plugin @@ -37,7 +37,7 @@ io.openliberty.tools liberty-ant-tasks - 1.9.13-SNAPSHOT + 1.9.13 org.apache.maven @@ -88,7 +88,7 @@ io.openliberty.tools ci.common - 1.8.27-SNAPSHOT + 1.8.29 org.twdata.maven @@ -224,6 +224,7 @@ binary-scanner-it/pom.xml springboot-3-tests/pom.xml + dev-container-it/pom.xml @@ -264,6 +265,7 @@ install-features-it/pom.xml binary-scanner-it/pom.xml springboot-3-tests/pom.xml + dev-container-it/pom.xml @@ -300,6 +302,7 @@ dev-it/pom.xml + dev-container-it/pom.xml generate-features-it/pom.xml binary-scanner-it/pom.xml springboot-3-tests/pom.xml @@ -337,6 +340,7 @@ dev-it/pom.xml + dev-container-it/pom.xml basic-it/pom.xml assembly-it/pom.xml assembly-with-code-it/pom.xml diff --git a/liberty-maven-plugin/src/it/dev-container-it/pom.xml b/liberty-maven-plugin/src/it/dev-container-it/pom.xml new file mode 100755 index 000000000..1538be9f5 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/pom.xml @@ -0,0 +1,121 @@ + + + 4.0.0 + + io.openliberty.tools.it + dev-container-it + 1.0-SNAPSHOT + jar + + + UTF-8 + UTF-8 + 8 + 8 + + + + + junit + junit + 4.13.2 + + + io.openliberty.tools + liberty-maven-plugin + @pom.version@ + + + commons-httpclient + commons-httpclient + 3.1 + test + + + commons-io + commons-io + 2.11.0 + + + org.codehaus.plexus + plexus-utils + 3.4.2 + + + + + + + io.openliberty.tools + liberty-maven-plugin + @pom.version@ + + + ${runtimeGroupId} + ${runtimeArtifactId} + ${runtimeVersion} + zip + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0 + + true + 1 + true + 2400 + -enableassertions + ${project.build.directory} + + **/*Test.java + + + @pom.version@ + ${runtimeVersion} + + false + + + + integration-test + + integration-test + + + + verify + verify + + verify + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0 + + true + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + test-jar + + + + + + + + diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/Containerfile b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/Containerfile new file mode 100644 index 000000000..f3a200656 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/Containerfile @@ -0,0 +1,33 @@ +# Start with OL runtime. +# tag::from[] +FROM icr.io/appcafe/open-liberty:full-java11-openj9-ubi +# end::from[] + +ARG VERSION=1.0 +ARG REVISION=SNAPSHOT +# tag::label[] + +LABEL \ + org.opencontainers.image.authors="Your Name" \ + org.opencontainers.image.vendor="IBM" \ + org.opencontainers.image.url="local" \ + org.opencontainers.image.source="https://github.com/OpenLiberty/guide-docker" \ + org.opencontainers.image.version="$VERSION" \ + org.opencontainers.image.revision="$REVISION" \ + vendor="Open Liberty" \ + name="system" \ + version="$VERSION-$REVISION" \ + summary="The system microservice from the Docker Guide" \ + # tag::description[] + description="This image contains the system microservice running with the Open Liberty runtime." + # end::description[] +# end::label[] + + +USER root + +COPY --chown=1001:0 src/main/liberty/config/server.xml /config/ + +COPY --chown=1001:0 target/*.war /config/apps/ + +USER 1001 diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/pom.xml b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/pom.xml new file mode 100644 index 000000000..ca93ef4f3 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/pom.xml @@ -0,0 +1,123 @@ + + + + 4.0.0 + + io.openliberty.tools + dev-containers-it + 1.0-SNAPSHOT + war + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + 9080 + 9443 + + + + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + false + + + + + + + + + jakarta.platform + jakarta.jakartaee-api + 9.1.0 + provided + + + org.eclipse.microprofile + microprofile + 5.0 + pom + provided + + + + + org.junit.jupiter + junit-jupiter + 5.8.2 + test + + + org.jboss.resteasy + resteasy-client + 6.0.0.Final + test + + + org.jboss.resteasy + resteasy-json-binding-provider + 6.0.0.Final + test + + + org.glassfish + jakarta.json + 2.0.1 + test + + + javax.xml.bind + jaxb-api + 2.3.1 + test + + + + + rest + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + + io.openliberty.tools + liberty-maven-plugin + SUB_VERSION + + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + + ${liberty.var.default.http.port} + + + + + + + diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/PropertiesResource.java b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/PropertiesResource.java new file mode 100644 index 000000000..eaa21955b --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/PropertiesResource.java @@ -0,0 +1,43 @@ +// tag::copyright[] +/******************************************************************************* + * Copyright (c) 2017, 2022 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ +// end::copyright[] +package io.openliberty.guides.rest; + +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Produces; + +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.Json; + +// tag::Path[] +@Path("properties") +// end::Path[] +public class PropertiesResource { + + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject getProperties() { + + JsonObjectBuilder builder = Json.createObjectBuilder(); + + System.getProperties() + .entrySet() + .stream() + .forEach(entry -> builder.add((String) entry.getKey(), + (String) entry.getValue())); + + return builder.build(); + } +} diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/SystemApplication.java b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/SystemApplication.java new file mode 100644 index 000000000..a1ee88610 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/java/io/openliberty/guides/rest/SystemApplication.java @@ -0,0 +1,21 @@ +// tag::copyright[] +/******************************************************************************* + * Copyright (c) 2017, 2022 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ +// end::copyright[] +package io.openliberty.guides.rest; + +import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.ApplicationPath; + +@ApplicationPath("system") +public class SystemApplication extends Application { + +} diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/liberty/config/server.xml b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/liberty/config/server.xml new file mode 100644 index 000000000..35e7d6a49 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/liberty/config/server.xml @@ -0,0 +1,16 @@ + + + + restfulWS-3.0 + jsonb-2.0 + jsonp-2.0 + + + + + + + + + diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/WEB-INF/web.xml b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..a3823f10b --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,10 @@ + + + Liberty Project + + + index.html + + \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/index.html b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/index.html new file mode 100644 index 000000000..d4f1f67db --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/main/webapp/index.html @@ -0,0 +1,41 @@ + + + +

Welcome to your Open Liberty application

+

Open Liberty is a lightweight open framework for building fast and efficient cloud-native Java microservices. Find out more at openliberty.io.

+
+

Eclipse MicroProfile

+

+ The Eclipse MicroProfile project is an open community with the aim of optimizing enterprise Java for a microservices architecture. + MicroProfile evolves with guidance from the community. +

+

+ If you want to share your thoughts, you can post straight to the + MicroProfile Google group. +

+

+ For more information about the features used in this application, see the Open Liberty documentation: +

+

+
+ + diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java new file mode 100644 index 000000000..56bc66361 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java @@ -0,0 +1,62 @@ +// tag::copyright[] +/******************************************************************************* + * Copyright (c) 2017, 2022 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ +// end::copyright[] +package it.io.openliberty.guides.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import jakarta.json.JsonObject; + +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Response; + + +public class EndpointIT extends BaseDevTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + setUpBeforeClass(null, "../resources/basic-dev-project", true, false, null, null); + + File f = new File("liberty/wlp"); + assertTrue(f.getCanonicalFile() + " exists", f.exists()); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + BaseDevTest.cleanUpAfterClass(); + } + + @Test + public void testGetProperties() { + String port = System.getProperty("liberty.test.port"); + String url = "http://localhost:" + port + "/"; + + Client client = ClientBuilder.newClient(); + + WebTarget target = client.target(url + "system/properties-new"); + Response response = target.request().get(); + JsonObject obj = response.readEntity(JsonObject.class); + + assertEquals(200, response.getStatus(), "Incorrect response code from " + url); + + assertEquals("/opt/ol/wlp/output/defaultServer/", + obj.getString("server.output.dir"), + "The system property for the server output directory should match " + + "the Open Liberty container image."); + + response.close(); + } +} diff --git a/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java new file mode 100644 index 000000000..99b46d797 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java @@ -0,0 +1,347 @@ +package net.wasdev.wlp.test.it; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.Scanner; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.io.input.ReversedLinesFileReader; +import org.apache.commons.io.FileUtils; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +public class BaseDevTest { + + static String customLibertyModule; + static String customPomModule; + static File basicDevProj; + static File logFile; + static File logErrorFile; + static File targetDir; + static File pom; + static BufferedWriter writer; + static Process process; + + /** + * Setup and optionally start dev/run + * + * @param params Params for the dev/run goal + * @param projectRoot The Maven project root + * @param isDevMode Use dev if true, use run if false. Ignored if startProcessDuringSetup is false. + * @param startProcessDuringSetup If this method should start the actual dev/run process + * @param libertyConfigModule For multi module project, the module where Liberty configuration is located + * @param pomModule For multi module project, the module where the pom is located. If null, use the project root. + * @throws IOException + * @throws InterruptedException + * @throws FileNotFoundException + */ + protected static void setUpBeforeClass(String params, String projectRoot, boolean isDevMode, boolean startProcessDuringSetup, + String libertyConfigModule, String pomModule) throws IOException, InterruptedException, FileNotFoundException { + customLibertyModule = libertyConfigModule; + customPomModule = pomModule; + + basicDevProj = new File(projectRoot); + + assertTrue(projectRoot+" directory does not exist", basicDevProj.exists()); + + logFile = new File(basicDevProj, "logFile.txt"); + logErrorFile = new File(basicDevProj, "logErrorFile.txt"); + + if (customPomModule == null) { + pom = new File(basicDevProj, "pom.xml"); + } else { + pom = new File(new File(basicDevProj, customPomModule), "pom.xml"); + } + assertTrue(pom.getCanonicalPath()+" file does not exist", pom.exists()); + + replaceVersion(); + + if (startProcessDuringSetup) { + startProcess(params, isDevMode); + } + } + + protected static void startProcess(String params, boolean isDevMode) throws IOException, InterruptedException, FileNotFoundException { + startProcess(params, isDevMode, "mvn liberty:"); + } + + protected static void startProcess(String params, boolean isDevMode, String mavenPluginCommand) throws IOException, InterruptedException, FileNotFoundException { + startProcess(params, isDevMode, mavenPluginCommand, true); + } + + protected static void startProcess(String params, boolean isDevMode, String mavenPluginCommand, boolean verifyServerStart) throws IOException, InterruptedException, FileNotFoundException { + // run dev mode on project + String goal; + if(isDevMode) { + goal = "dev"; + } else { + goal = "run"; + } + + StringBuilder command = new StringBuilder(mavenPluginCommand + goal); + if (params != null) { + command.append(" " + params); + } + ProcessBuilder builder = buildProcess(command.toString()); + + builder.redirectOutput(logFile); + builder.redirectError(logErrorFile); + process = builder.start(); + assertTrue("process is not alive", process.isAlive()); + + OutputStream stdin = process.getOutputStream(); + + writer = new BufferedWriter(new OutputStreamWriter(stdin)); + + if (verifyServerStart) { + // check that the server has started + assertTrue(getLogTail(), verifyLogMessageExists("CWWKF0011I", 120000)); + if (isDevMode) { + assertTrue(verifyLogMessageExists("Liberty is running in dev mode.", 60000)); + } + + // verify that the target directory was created + if (customLibertyModule == null) { + targetDir = new File(basicDevProj, "target"); + } else { + targetDir = new File(new File(basicDevProj, customLibertyModule), "target"); + } + assertTrue("target directory does not exist: "+targetDir.getCanonicalPath(), targetDir.exists()); + } + } + + protected static String getLogTail() throws IOException { + return getLogTail(logFile); + } + + protected static String getLogTail(File log) throws IOException { + int numLines = 100; + ReversedLinesFileReader object = null; + try { + object = new ReversedLinesFileReader(log, StandardCharsets.UTF_8); + List reversedLines = new ArrayList(); + + for (int i = 0; i < numLines; i++) { + String line = object.readLine(); + if (line == null) { + break; + } + reversedLines.add(line); + } + StringBuilder result = new StringBuilder(); + for (int i = reversedLines.size() - 1; i >=0; i--) { + result.append(reversedLines.get(i) + "\n"); + } + return "Last "+numLines+" lines of log at "+log.getAbsolutePath()+":\n" + + "===================== START =======================\n" + + result.toString() + + "====================== END ========================\n"; + } finally { + if (object != null) { + object.close(); + } + } + } + + protected static void cleanUpAfterClass() throws Exception { + cleanUpAfterClass(true); + } + + protected static void cleanUpAfterClass(boolean isDevMode) throws Exception { + cleanUpAfterClass(isDevMode, true); + } + + protected static void cleanUpAfterClass(boolean isDevMode, boolean checkForShutdownMessage) throws Exception { + stopProcess(isDevMode, checkForShutdownMessage); + + if (logFile != null && logFile.exists()) { + assertTrue("Could not delete log file: "+logFile.getCanonicalPath(), logFile.delete()); + } + if (logErrorFile != null && logErrorFile.exists()) { + assertTrue("Could not delete logError file: "+logErrorFile.getCanonicalPath(), logErrorFile.delete()); + } + } + + protected static void clearLogFile() throws Exception { + if (logFile != null && logFile.exists()) { + BufferedWriter logWriter = new BufferedWriter(new FileWriter(logFile)); + logWriter.close(); + } + } + + private static void stopProcess(boolean isDevMode, boolean checkForShutdownMessage) throws IOException, InterruptedException, FileNotFoundException, IllegalThreadStateException { + // shut down dev mode + if (writer != null) { + int serverStoppedOccurrences = countOccurrences("CWWKE0036I", logFile); + + try { + if(isDevMode) { + writer.write("exit\n"); // trigger dev mode to shut down + } else { + process.destroy(); // stop run + } + writer.flush(); + + } catch (IOException e) { + } finally { + try { + writer.close(); + } catch (IOException io) { + } + } + + try { + process.waitFor(120, TimeUnit.SECONDS); + } catch (InterruptedException e) { + } + + // test that the server has shut down + if (checkForShutdownMessage) { + assertTrue(getLogTail(), verifyLogMessageExists("CWWKE0036I", 20000, ++serverStoppedOccurrences)); + } + } + } + + protected static ProcessBuilder buildProcess(String processCommand) { + ProcessBuilder builder = new ProcessBuilder(); + builder.directory(basicDevProj); + + String os = System.getProperty("os.name"); + if (os != null && os.toLowerCase().startsWith("windows")) { + builder.command("CMD", "/C", processCommand); + } else { + builder.command("bash", "-c", processCommand); + } + return builder; + } + + private static void replaceVersion() throws IOException { + String pluginVersion = System.getProperty("mavenPluginVersion"); + replaceString("SUB_VERSION", pluginVersion, pom); + String runtimeVersion = System.getProperty("runtimeVersion"); + replaceString("RUNTIME_VERSION", runtimeVersion, pom); + } + + protected static void replaceString(String str, String replacement, File file) throws IOException { + Path path = file.toPath(); + Charset charset = StandardCharsets.UTF_8; + String content = new String(Files.readAllBytes(path), charset); + + content = content.replaceAll(str, replacement); + Files.write(path, content.getBytes(charset)); + } + + protected static boolean verifyLogMessageExists(String message, int timeout) + throws InterruptedException, FileNotFoundException, IOException { + return verifyLogMessageExists(message, timeout, logFile); + } + + protected static boolean verifyLogMessageExists(String message, int timeout, File log) + throws InterruptedException, FileNotFoundException, IOException { + int waited = 0; + int sleep = 10; + while (waited <= timeout) { + Thread.sleep(sleep); + waited += sleep; + if (readFile(message, log)) { + return true; + } + } + return false; + } + + protected static boolean verifyLogMessageExists(String message, int timeout, int occurrences) + throws InterruptedException, FileNotFoundException, IOException { + return verifyLogMessageExists(message, timeout, logFile, occurrences); + } + + protected static boolean verifyLogMessageExists(String message, int timeout, File log, int occurrences) + throws InterruptedException, FileNotFoundException, IOException { + int waited = 0; + int sleep = 10; + while (waited <= timeout) { + Thread.sleep(sleep); + waited += sleep; + if (countOccurrences(message, log) == occurrences) { + return true; + } + } + return false; + } + + protected static boolean readFile(String str, File file) throws FileNotFoundException, IOException { + BufferedReader br = new BufferedReader(new FileReader(file)); + String line = br.readLine(); + try { + while (line != null) { + if (line.contains(str)) { + return true; + } + line = br.readLine(); + } + } finally { + br.close(); + } + return false; + } + + /** + * Count number of lines that contain the given string + */ + protected static int countOccurrences(String str, File file) throws FileNotFoundException, IOException { + int occurrences = 0; + BufferedReader br = new BufferedReader(new FileReader(file)); + String line = br.readLine(); + try { + while (line != null) { + if (line.contains(str)) { + occurrences++; + } + line = br.readLine(); + } + } finally { + br.close(); + } + return occurrences; + } + + @Rule + public TestWatcher watchman = new TestWatcher() { + @Override + protected void failed(Throwable thr, Description description) { + try { + System.out.println("Failure log in " + logFile + ", tail of contents = " + getLogTail(logFile)); + } catch (IOException e) {} + } + }; +} diff --git a/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/DevContainerTest.java b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/DevContainerTest.java new file mode 100644 index 000000000..ee08c7fa1 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/DevContainerTest.java @@ -0,0 +1,38 @@ +package net.wasdev.wlp.test.it; + +import static org.junit.Assert.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.nio.file.Files; +import java.util.Scanner; + +import org.apache.commons.io.FileUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class DevContainerTest extends BaseDevTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + setUpBeforeClass(null, "../resources/container-test-project", true, false, null, null); + + // run dev mode with container flag + startProcess("-Dcontainer", true); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + BaseDevTest.cleanUpAfterClass(); + } + + @Test + public void runContainerTest() throws Exception { + // Verify that container was built correctly + assertTrue("The container build did not complete: "+getLogTail(), verifyLogMessageExists("Completed building container image.", 2000)); + assertTrue("The application start message is missing: "+getLogTail(), verifyLogMessageExists("CWWKZ0001I: Application rest started", 2000)); + } + +} diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java index 5466ecfe0..4a6c0c5df 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java @@ -192,15 +192,15 @@ public class DevMojo extends LooseAppSupport { protected boolean pollingTest; /** - * Dockerfile used to build a Docker image to then start a container with + * Containerfile used to build an image to then start a container with */ - @Parameter(property = "dockerfile") + @Parameter(alias="containerfile", property = "containerfile") private File dockerfile; /** - * Context (directory) to use for the Docker build when building the container image + * Context (directory) to use for the build when building the container image */ - @Parameter(property = "dockerBuildContext") + @Parameter(alias="containerBuildContext", property = "containerBuildContext") private File dockerBuildContext; /** @@ -230,30 +230,30 @@ public class DevMojo extends LooseAppSupport { private File testOutputDirectory; /** - * Additional options for the docker run command when dev mode starts a + * Additional options for the container run command when dev mode starts a * container. */ - @Parameter(property = "dockerRunOpts") + @Parameter(alias="containerRunOpts", property = "containerRunOpts") private String dockerRunOpts; /** - * Specify the amount of time in seconds that dev mode waits for the docker + * Specify the amount of time in seconds that dev mode waits for the container * build command to run to completion. Default to 600 seconds. */ - @Parameter(property = "dockerBuildTimeout", defaultValue = "600") + @Parameter(alias="containerBuildTimeout", property = "containerBuildTimeout", defaultValue = "600") private int dockerBuildTimeout; /** - * If true, the default Docker port mappings are skipped in the docker run + * If true, the default container port mappings are skipped in the container run * command */ @Parameter(property = "skipDefaultPorts", defaultValue = "false") private boolean skipDefaultPorts; /** - * If true, preserve the temporary Dockerfile used in the docker build command + * If true, preserve the temporary Containerfile/Dockerfile used in the container build command */ - @Parameter(property = "keepTempDockerfile", defaultValue = "false") + @Parameter(alias="keepTempContainerfile", property = "keepTempContainerfile", defaultValue = "false") private boolean keepTempDockerfile; private boolean isExplodedLooseWarApp = false; @@ -1369,7 +1369,7 @@ private void doDevMode() throws MojoExecutionException { } runLibertyMojoCreate(); // If non-container, install features before starting server. Otherwise, user - // should have "RUN features.sh" in their Dockerfile if they want features to be + // should have "RUN features.sh" in their Containerfile/Dockerfile if they want features to be // installed. // Added check here for the new skip install feature parameter. // Need to also check if this is a new Liberty installation or not. The isNewInstallation flag is set by runLibertyMojoCreate. diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java index c8fdce107..c8a0a21a5 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java @@ -288,9 +288,13 @@ protected Plugin getLibertyPluginForProject(MavenProject currentProject) { } Plugin projectPlugin = currentProject.getPlugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID + ":" + LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID); if (projectPlugin == null) { + getLog().debug("Did not find liberty-maven-plugin configured in currentProject: "+currentProject.toString()); projectPlugin = getPluginFromPluginManagement(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID, currentProject); + } else { + getLog().debug("Found liberty-maven-plugin configured in currentProject: "+currentProject.toString()); } if (projectPlugin == null) { + getLog().debug("Did not find liberty-maven-plugin in pluginManagement in currentProject: "+currentProject.toString()); projectPlugin = plugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID, "LATEST"); } if (version != null) { @@ -370,8 +374,10 @@ protected void runLibertyMojoGenerateFeatures(Element classFiles, boolean optimi private void runLibertyMojo(String goal, Xpp3Dom config) throws MojoExecutionException { getLog().info("Running liberty:" + goal); getLog().debug("configuration:\n" + config); - executeMojo(getLibertyPlugin(), goal(goal), config, - executionEnvironment(project, session, pluginManager)); + getLog().debug("project:\n" + project); + MavenSession tempSession = session.clone(); + tempSession.setCurrentProject(project); + executeMojo(getLibertyPlugin(), goal(goal), config, executionEnvironment(project, tempSession, pluginManager)); } private void copyDependencies() throws MojoExecutionException, IOException { diff --git a/pom.xml b/pom.xml index 729b9eb3b..6b62e8e12 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ io.openliberty.tools liberty-maven - 3.8.3-SNAPSHOT + 3.10-SNAPSHOT pom Liberty Tools for Maven