Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/common-server-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Starting with the 3.1 release of the liberty-maven-plugin, support is added to s

If Liberty configuration is specified with Maven properties, the above indicated files are created in the target Liberty server. By default there is no merging behavior for the Maven properties with files located in the `configDirectory` or the specific configuration file parameters such as `bootstrapPropertiesFile`, `jvmOptionsFile` and `serverEnvFile`. However, the `liberty.env.{var}` Maven properties can be merged with other configured `server.env` files by setting the `mergeServerEnv` parameter to `true`.

As a special case when `mergeServerEnv` is `false`, an existing `keystore_password` property in the default generated `server.env` file in the target server will be merged in if there is no `serverEnvFile` configured nor `server.env` file located in the `configDirectory`, and the `keystore_password` env var is not defined as a Maven property.
As a special case when `mergeServerEnv` is `false`, existing `keystore_password` and `ltpa_keys_password` properties in the default generated `server.env` file in the target server will be merged in if there is no `serverEnvFile` configured nor `server.env` file located in the `configDirectory`, and these env vars are not defined as Maven properties.

Note that properties specified with `-D` on the command line are also analyzed for the property name formats listed above and take precedence over Maven properties specified in the pom.xml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void testServerEnvFileExists() throws Exception {

# default server.env
keystore_password=sfKRrA1ioLdtIFQC9bEfkua
ltpa_keys_password=<default_value>

# Configured server.env
CONFIG_SERVER_ENV=TEST
Expand All @@ -47,6 +48,7 @@ public void testServerEnvFileExists() throws Exception {
# Merged server.env
# Generated by liberty-maven-plugin
keystore_password=sfKRrA1ioLdtIFQC9bEfkua
ltpa_keys_password=<default_value>
CONFIG_SERVER_ENV=TEST
ConfigDir=TEST
TEST_PROP_3=blue
Expand Down Expand Up @@ -78,9 +80,10 @@ public void check_server_env_contents() throws Exception {

// The contents of the default server.env can change over time.
// After 20.0.0.3, for example, the WLP_SKIP_MAXPERMSIZE was removed.
// Just confirm the keystore_password is present to prove the default server.env was merged with the plugin config.
Assert.assertTrue("Number of env properties should be >= 7, but is "+serverEnvContents.size(), serverEnvContents.size() >= 7);
// Just confirm the keystore_password and ltpa_keys_password are present to prove the default server.env was merged with the plugin config.
Assert.assertTrue("Number of env properties should be >= 8, but is "+serverEnvContents.size(), serverEnvContents.size() >= 8);
Assert.assertTrue("keystore_password mapping found", serverEnvContents.containsKey("keystore_password"));
Assert.assertTrue("ltpa_keys_password mapping found", serverEnvContents.containsKey("ltpa_keys_password"));
Assert.assertTrue("ConfigDir=TEST mapping found", serverEnvContents.get("ConfigDir").equals("TEST"));
Assert.assertTrue("CONFIG_SERVER_ENV=TEST mapping found", serverEnvContents.get("CONFIG_SERVER_ENV").equals("TEST"));
Assert.assertTrue("TEST_PROP_3=blue", serverEnvContents.get("TEST_PROP_3").equals("blue"));
Expand Down
187 changes: 187 additions & 0 deletions liberty-maven-plugin/src/it/merge-server-env-ltpa-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>io.openliberty.tools.it</groupId>
<artifactId>tests</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>merge-server-env-ltpa-it</artifactId>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<liberty.env.CUSTOM_PROP>customValue</liberty.env.CUSTOM_PROP>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>@pom.version@</version>
<extensions>true</extensions>
<configuration>
<stripVersion>true</stripVersion>
<serverName>test</serverName>
<deployPackages>project</deployPackages>
<looseApplication>false</looseApplication>
<mergeServerEnv>true</mergeServerEnv>
<serverEnvFile>src/test/resources/server.env</serverEnvFile>
<configDirectory>src/test/resources/configDir</configDirectory>
</configuration>
<executions>
<execution>
<id>install-liberty</id>
<phase>package</phase>
<goals>
<goal>install-server</goal>
</goals>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>[26.0.0.4,)</version>
<type>zip</type>
</assemblyArtifact>
</configuration>
</execution>
<execution>
<id>create-liberty-server</id>
<phase>package</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
<execution>
<id>install-artifact</id>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
</execution>
<execution>
<id>start-liberty-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>install-feature</goal>
<goal>start</goal>
</goals>
<configuration>
<background>true</background>
<verifyTimeout>40</verifyTimeout>
</configuration>
</execution>
<execution>
<id>check-liberty-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>status</goal>
</goals>
</execution>
<execution>
<id>stop-liberty-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
<execution>
<id>clean-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<cleanDropins>true</cleanDropins>
<cleanApps>true</cleanApps>
<cleanLogs>false</cleanLogs>
<cleanWorkarea>false</cleanWorkarea>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkMode>once</forkMode>
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
<argLine>-enableassertions</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<includes>
<include>**/*MergeServerEnvLtpaTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading
Loading