Skip to content

Commit 22403f6

Browse files
authored
Merge pull request #497 from turkeylurkey/merge-main-0130
Merge main into the latest generate features branch
2 parents 5c0f9b2 + f1261b5 commit 22403f6

File tree

8 files changed

+385
-98
lines changed

8 files changed

+385
-98
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# ci.common [![Build Status](https://github.com/OpenLiberty/ci.common/workflows/CI/badge.svg)](https://github.com/OpenLiberty/ci.common/actions?branch=main) [![Maven Central Latest](https://maven-badges.herokuapp.com/maven-central/io.openliberty.tools/ci.common/badge.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.openliberty.tools%22%20AND%20a%3A%22ci.common%22)
1+
# ci.common [![Build Status](https://github.com/OpenLiberty/ci.common/workflows/CI/badge.svg)](https://github.com/OpenLiberty/ci.common/actions?branch=main) [![Maven Central Latest](https://maven-badges.herokuapp.com/maven-central/io.openliberty.tools/ci.common/badge.svg)](https://central.sonatype.com/artifact/io.openliberty.tools/ci.common)
22
Common library for Open Liberty and WebSphere Liberty Maven and Gradle plugins. Used internally by [ci.gradle](https://github.com/OpenLiberty/ci.gradle) and [ci.maven](https://github.com/OpenLiberty/ci.maven).

pom.xml

Lines changed: 126 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,67 @@
11
<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">
22
<modelVersion>4.0.0</modelVersion>
33

4-
<parent>
5-
<groupId>net.wasdev.maven.parent</groupId>
6-
<artifactId>parent</artifactId>
7-
<version>1.4</version>
8-
<relativePath />
9-
</parent>
10-
114
<groupId>io.openliberty.tools</groupId>
125
<artifactId>ci.common</artifactId>
13-
<version>1.8.38-SNAPSHOT</version>
6+
<version>1.8.41-SNAPSHOT</version>
147
<packaging>jar</packaging>
158

169
<name>ci.common</name>
10+
<description>Common library for Open Liberty and WebSphere Liberty Maven and Gradle plugins.</description>
11+
<url>https://github.com/openliberty/ci.common</url>
1712

1813
<licenses>
1914
<license>
20-
<name>The Apache Software License, Version 2.0</name>
21-
<url>https://raw.github.com/openliberty/ci.common/main/LICENSE</url>
22-
<distribution>repo</distribution>
15+
<name>The Apache Software License, Version 2.0</name>
16+
<url>https://raw.github.com/openliberty/ci.common/main/LICENSE</url>
17+
<distribution>repo</distribution>
2318
</license>
2419
</licenses>
2520

21+
<developers>
22+
<developer>
23+
<name>Cheryl King</name>
24+
<email>developers@openliberty.io</email>
25+
<organization>Open Liberty</organization>
26+
<url>https://github.com/OpenLiberty</url>
27+
</developer>
28+
</developers>
29+
2630
<scm>
2731
<connection>scm:git:git@github.com:openliberty/ci.maven.git</connection>
2832
<developerConnection>scm:git:git@github.com:openliberty/ci.common.git</developerConnection>
2933
<url>git@github.com:openliberty/ci.common.git</url>
3034
<tag>HEAD</tag>
3135
</scm>
3236

37+
<distributionManagement>
38+
<snapshotRepository>
39+
<id>maven-central-snapshots</id>
40+
<name>Maven Central Snapshot Repository</name>
41+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
42+
</snapshotRepository>
43+
<repository>
44+
<id>maven-central-releases</id>
45+
<name>Maven Central Release Repository</name>
46+
<url>https://central.sonatype.com/api/v1/publisher</url>
47+
</repository>
48+
</distributionManagement>
49+
50+
<repositories>
51+
<!-- Configure Sonatype OSS Maven snapshots repository -->
52+
<repository>
53+
<id>sonatype-nexus-snapshots</id>
54+
<name>Sonatype Nexus Snapshots</name>
55+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
56+
<snapshots>
57+
<enabled>true</enabled>
58+
</snapshots>
59+
<releases>
60+
<enabled>false</enabled>
61+
</releases>
62+
</repository>
63+
</repositories>
64+
3365
<properties>
3466
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3567
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -48,7 +80,7 @@
4880
<dependency>
4981
<groupId>commons-io</groupId>
5082
<artifactId>commons-io</artifactId>
51-
<version>2.14.0</version>
83+
<version>2.20.0</version>
5284
</dependency>
5385
<dependency>
5486
<groupId>javax.xml.bind</groupId>
@@ -59,12 +91,92 @@
5991
<dependency>
6092
<groupId>io.openliberty.tools</groupId>
6193
<artifactId>liberty-ant-tasks</artifactId>
62-
<version>1.9.16</version>
94+
<version>1.9.17</version>
6395
</dependency>
6496
<dependency>
6597
<groupId>com.fasterxml.jackson.core</groupId>
6698
<artifactId>jackson-core</artifactId>
67-
<version>2.15.2</version>
99+
<version>2.19.2</version>
68100
</dependency>
69101
</dependencies>
102+
103+
<build>
104+
<plugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-release-plugin</artifactId>
108+
<version>3.1.1</version>
109+
<configuration>
110+
<autoVersionSubmodules>true</autoVersionSubmodules>
111+
<useReleaseProfile>false</useReleaseProfile>
112+
<releaseProfiles>sonatype-oss-release</releaseProfiles>
113+
<goals>deploy</goals>
114+
</configuration>
115+
</plugin>
116+
</plugins>
117+
</build>
118+
119+
<profiles>
120+
<profile>
121+
<id>sonatype-oss-release</id>
122+
<build>
123+
<plugins>
124+
<plugin>
125+
<groupId>org.sonatype.central</groupId>
126+
<artifactId>central-publishing-maven-plugin</artifactId>
127+
<version>0.8.0</version>
128+
<extensions>true</extensions>
129+
<configuration>
130+
<publishingServerId>maven-central-releases</publishingServerId>
131+
<deploymentName>${project.artifactId}</deploymentName>
132+
</configuration>
133+
</plugin>
134+
<plugin>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-source-plugin</artifactId>
137+
<version>3.3.1</version>
138+
<executions>
139+
<execution>
140+
<id>attach-sources</id>
141+
<goals>
142+
<goal>jar-no-fork</goal>
143+
</goals>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-javadoc-plugin</artifactId>
150+
<version>3.11.2</version>
151+
<configuration>
152+
<bottom><![CDATA[Copyright &#169; {currentYear} the original author or authors.]]></bottom>
153+
<failOnError>false</failOnError>
154+
</configuration>
155+
<executions>
156+
<execution>
157+
<id>attach-javadocs</id>
158+
<goals>
159+
<goal>jar</goal>
160+
</goals>
161+
</execution>
162+
</executions>
163+
</plugin>
164+
<plugin>
165+
<groupId>org.apache.maven.plugins</groupId>
166+
<artifactId>maven-gpg-plugin</artifactId>
167+
<version>3.2.8</version>
168+
<executions>
169+
<execution>
170+
<id>sign-artifacts</id>
171+
<phase>verify</phase>
172+
<goals>
173+
<goal>sign</goal>
174+
</goals>
175+
</execution>
176+
</executions>
177+
</plugin>
178+
</plugins>
179+
</build>
180+
</profile>
181+
</profiles>
70182
</project>

src/main/java/io/openliberty/tools/common/plugins/config/ServerConfigDocument.java

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2017, 2025.
2+
* (C) Copyright IBM Corporation 2017, 2026.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@
3434
import java.util.Set;
3535
import java.util.Map;
3636
import java.util.Properties;
37+
import java.util.regex.Matcher;
38+
import java.util.regex.Pattern;
3739

3840
import javax.xml.XMLConstants;
3941
import javax.xml.parsers.DocumentBuilder;
@@ -46,13 +48,12 @@
4648
import javax.xml.xpath.XPathFactory;
4749

4850
import io.openliberty.tools.common.plugins.util.LibertyPropFilesUtility;
51+
import io.openliberty.tools.common.plugins.util.OSUtil;
4952
import io.openliberty.tools.common.plugins.util.PluginExecutionException;
5053
import org.apache.commons.io.comparator.NameFileComparator;
5154
import org.w3c.dom.Document;
5255
import org.w3c.dom.Element;
5356
import org.w3c.dom.NodeList;
54-
import org.w3c.dom.Node;
55-
import org.w3c.dom.NamedNodeMap;
5657
import org.xml.sax.SAXException;
5758

5859
import io.openliberty.tools.common.CommonLoggerI;
@@ -88,6 +89,10 @@ public class ServerConfigDocument {
8889
private static final XPathExpression XPATH_SERVER_INCLUDE;
8990
public static final XPathExpression XPATH_SERVER_VARIABLE;
9091
private static final XPathExpression XPATH_ALL_SERVER_APPLICATIONS;
92+
// Windows style: !VAR!
93+
private static final Pattern WINDOWS_EXPANSION_VAR_PATTERN;
94+
// Linux style: ${VAR}
95+
private static final Pattern LINUX_EXPANSION_VAR_PATTERN;
9196

9297

9398
static {
@@ -106,6 +111,8 @@ public class ServerConfigDocument {
106111
// correct
107112
throw new RuntimeException(ex);
108113
}
114+
WINDOWS_EXPANSION_VAR_PATTERN = Pattern.compile("!(\\w+)!");
115+
LINUX_EXPANSION_VAR_PATTERN = Pattern.compile("\\$\\{(\\w+)\\}");
109116
}
110117

111118
public Set<String> getLocations() {
@@ -321,6 +328,64 @@ public void processServerEnv() throws Exception, FileNotFoundException {
321328
parsePropertiesFromFile(new File(libertyDirectoryPropertyToFile.get(ServerFeatureUtil.WLP_USER_DIR),
322329
"shared" + File.separator + serverEnvString));
323330
parsePropertiesFromFile(getFileFromConfigDirectory(serverEnvString));
331+
Map<String, String> resolvedMap = new HashMap<>();
332+
333+
props.forEach((k, v) -> {
334+
String key = (String) k;
335+
String value = (String) v;
336+
Set<String> resolveInProgressProps = new HashSet<>();
337+
resolveInProgressProps.add(key);
338+
resolvedMap.put(key, resolveExpansionProperties(props, value, key, resolveInProgressProps));
339+
});
340+
341+
// After all resolutions are calculated, update the original props
342+
props.putAll(resolvedMap);
343+
}
344+
345+
/**
346+
* Resolves property placeholders recursively with safety guards.
347+
* Uses appendReplacement to ensure a single-pass scan and strict depth control.
348+
*
349+
* @param props The properties source.
350+
* @param value The string currently being processed.
351+
* @param key key of property being processed.
352+
* @param resolveInProgressProps The set of variables in the current stack to detect loops.
353+
* @return The resolved string or raw text if depth/circularity limits are hit.
354+
*/
355+
private String resolveExpansionProperties(Properties props, String value, String key, Set<String> resolveInProgressProps) {
356+
if (value == null) return null;
357+
Pattern pattern = OSUtil.isWindows() ? WINDOWS_EXPANSION_VAR_PATTERN : LINUX_EXPANSION_VAR_PATTERN;
358+
Matcher matcher = pattern.matcher(value);
359+
StringBuffer sb = new StringBuffer();
360+
while (matcher.find()) {
361+
String finalReplacement;
362+
String varName = matcher.group(1);
363+
// 2. Circular Reference Guard
364+
if (resolveInProgressProps.contains(varName)) {
365+
log.warn("Circular reference detected: " + varName + " depends on itself in value " + value + ". Skipping expansion.");
366+
break;
367+
}
368+
String replacement = props.getProperty(varName);
369+
if (replacement != null) {
370+
// 3. Recursive call
371+
// Add to stack before recursing
372+
resolveInProgressProps.add(varName);
373+
try {
374+
finalReplacement = resolveExpansionProperties(props, replacement, key, resolveInProgressProps);
375+
} finally {
376+
// Remove from stack after finishing this branch (backtracking)
377+
resolveInProgressProps.remove(varName);
378+
}
379+
} else {
380+
// Variable not found in Properties; leave the original ${VAR} or !VAR!
381+
finalReplacement = matcher.group(0); // Keep original
382+
}
383+
matcher.appendReplacement(sb, Matcher.quoteReplacement(finalReplacement));
384+
log.info(String.format("Resolving Property %s for expression %s. Resolved expression value is %s", varName , value , sb));
385+
}
386+
// 4. Finalize the string
387+
matcher.appendTail(sb);
388+
return sb.toString();
324389
}
325390

326391
/**

src/main/java/io/openliberty/tools/common/plugins/util/BinaryScannerUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class BinaryScannerUtil {
3030
public static final String BINARY_SCANNER_MAVEN_GROUP_ID = "com.ibm.websphere.appmod.tools";
3131
public static final String BINARY_SCANNER_MAVEN_ARTIFACT_ID = "binary-app-scanner";
3232
public static final String BINARY_SCANNER_MAVEN_TYPE = "jar";
33-
public static final String BINARY_SCANNER_MAVEN_VERSION = "[24.0.0.2]";
33+
public static final String BINARY_SCANNER_MAVEN_VERSION = "[25.0.0.2]";
3434

3535
public static final String GENERATED_FEATURES_FILE_NAME = "generated-features.xml";
3636
public static final String GENERATED_FEATURES_DIR_PATH = "configDropins/overrides/";

0 commit comments

Comments
 (0)