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
5 changes: 3 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches: '**'
pull_request:
branches: [ main ]
branches: [ main, prepare-config]

env:
# server-config-props-it fix
Expand Down Expand Up @@ -100,6 +100,7 @@ jobs:
with:
repository: OpenLiberty/ci.common
path: ci.common
ref: prepare-config
- name: Checkout ci.ant
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -206,7 +207,7 @@ jobs:
- name: Clone ci.ant and ci.common repos to github.workspace
run: |
echo ${{github.workspace}}
git clone https://github.com/OpenLiberty/ci.common.git ${{github.workspace}}/ci.common
git clone https://github.com/OpenLiberty/ci.common.git --branch prepare-config --single-branch ${{github.workspace}}/ci.common
git clone https://github.com/OpenLiberty/ci.ant.git ${{github.workspace}}/ci.ant
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ The Liberty Maven Plugin provides the following goals.
| [install-server](docs/install-server.md#install-server) | Installs the Liberty runtime. This goal is implicitly invoked by all the other plugin goals and usually does not need to be executed explicitly. |
| [java-dump](docs/java-dump.md#java-dump) | Dump diagnostic information from the server JVM. |
| [package](docs/package.md#package) | Package a Liberty server. |
| [prepare-config](docs/prepare-config.md#prepare-config) | Prepare Liberty configuration and generate liberty-plugin-config.xml without creating the server or installing Liberty. Useful for IDE and language server support. |
| [prepare-feature](docs/prepare-feature.md#prepare-feature) | Prepare a user feature for installation to the Liberty runtime. |
| [run](docs/run.md#run) | Start a Liberty server in the foreground. The run goal implicitly creates the server, installs features referenced by the server.xml file, and deploys the application before starting the Liberty server. |
| [start](docs/start.md#start) | Start a Liberty server in the background. The server instance will be automatically created if it does not exist. |
Expand Down
99 changes: 99 additions & 0 deletions docs/prepare-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## prepare-config

---

Prepare Liberty configuration and generate `liberty-plugin-config.xml` with a mock Liberty server structure. This lightweight goal creates a temporary Liberty server structure, copies configuration files, and generates metadata needed by IDE tools and language servers.

**What this goal does:**
1. Creates a mock Liberty server structure in `target/.libertyls-var-cache/wlp/usr/servers/{serverName}/` (configurable)
2. Copies all configuration files (server.xml, bootstrap.properties, server.env, jvm.options, etc.) to the mock server
3. Generates `liberty-plugin-config.xml` pointing to the mock server structure

**Note:** This goal does NOT install Liberty runtime. It only creates a minimal directory structure and copies configuration files.

---

### Usage

Run directly from the command line:

```bash
mvn liberty:prepare-config
```

Or configure it to run automatically:

```xml
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-config</id>
<phase>initialize</phase>
<goals>
<goal>prepare-config</goal>
</goals>
</execution>
</executions>
</plugin>
```

---

### Configuration

The goal uses the [common parameters](common-parameters.md) and [common server parameters](common-server-parameters.md).

The temporary directory for the mock server structure defaults to `.libertyls-var-cache` (a hidden directory). To override this, use the system property:

```bash
mvn liberty:prepare-config -DprepareConfigTempDir=my-temp-dir
```

This will create the mock server structure in `target/my-temp-dir/wlp/usr/servers/{serverName}/` instead of the default location.

---

### Generated Files

The goal generates:

1. **Mock Liberty Server Structure** in `target/.libertyls-var-cache/`:
```
target/.libertyls-var-cache/
└── wlp/
└── usr/
└── servers/
└── {serverName}/
├── server.xml
├── bootstrap.properties
├── server.env
└── jvm.options
```

2. **Configuration Metadata File** `target/liberty-plugin-config.xml` containing project metadata, dependencies, and configuration file paths for IDE tools and language servers.

---

### Use Cases

- **IDE Language Server Support**: Provides metadata for code completion, validation, and diagnostics in Liberty configuration files
- **Quick Configuration Validation**: Validate configuration without full project build
- **CI/CD Integration**: Generate configuration metadata early in the pipeline

**For full variable resolution features**, install Liberty first:

```bash
mvn liberty:create
mvn liberty:prepare-config
```

---

### See Also

- [Common Parameters](common-parameters.md)
- [Common Server Parameters](common-server-parameters.md)
- [create goal](create.md) - Install Liberty and create server
- [dev goal](dev.md) - Development mode with hot reload
2 changes: 1 addition & 1 deletion liberty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>io.openliberty.tools</groupId>
<artifactId>ci.common</artifactId>
<version>1.8.41</version>
<version>1.8.42-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Integration test configuration for prepare-config goal
invoker.goals=initialize
invoker.maven.version=3.6.0+
65 changes: 65 additions & 0 deletions liberty-maven-plugin/src/it/prepare-config-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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>

<groupId>net.wasdev.wlp.maven.test</groupId>
<artifactId>prepare-config-it</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>prepare-config</id>
<phase>initialize</phase>
<goals>
<goal>prepare-config</goal>
</goals>
<configuration>
<serverName>testServer</serverName>
<includeServerInfo>true</includeServerInfo>
</configuration>
</execution>
</executions>
<configuration>
<assemblyArtifact>
<groupId>${runtimeGroupId}</groupId>
<artifactId>${runtimeArtifactId}</artifactId>
<version>${runtimeVersion}</version>
<type>zip</type>
</assemblyArtifact>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Bootstrap properties for prepare-config integration test
default.http.port=9080
default.https.port=9443
app.context.root=/
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<server description="Test server for prepare-config goal">

<featureManager>
<feature>jakartaee-9.1</feature>
<feature>microProfile-5.0</feature>
</featureManager>

<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443" />

<webApplication location="prepare-config-it.war" contextRoot="/" />

<applicationManager autoExpand="true"/>

</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Prepare Config Test</title>
</head>
<body>
<h1>Prepare Config Integration Test</h1>
<p>This is a test application for the prepare-config goal.</p>
</body>
</html>
Loading
Loading