Skip to content

Commit

Permalink
Avoid using non existing maven settings
Browse files Browse the repository at this point in the history
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos.
Use ci settings.xml full path for test that uses settings parameter.

Fixes #28090

Signed-off-by: Adler Fleurant <[email protected]>
  • Loading branch information
AdlerFleurant committed Sep 22, 2022
1 parent 1e1320a commit a5ff366
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-actions-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ concurrency:
env:
# Workaround testsuite locale issue
LANG: en_US.UTF-8
COMMON_MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"
COMMON_MAVEN_ARGS: "-e -B --settings ${{ github.workspace }}/.github/mvn-settings.xml --fail-at-end"
NATIVE_TEST_MAVEN_ARGS: "-Dtest-containers -Dstart-containers -Dquarkus.native.native-image-xmx=5g -Dnative -Dnative.surefire.skip -Dformat.skip -Dno-descriptor-tests install -DskipDocs"
JVM_TEST_MAVEN_ARGS: "-Dtest-containers -Dstart-containers -Dformat.skip -DskipDocs -Dquarkus.test.hang-detection-timeout=60"
DB_USER: hibernate_orm_test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jdk-early-access-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
# Workaround testsuite locale issue
LANG: en_US.UTF-8
MAVEN_OPTS: -Xmx2g -XX:MaxMetaspaceSize=1g
JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-containers -Dstart-containers -Dtest-resteasy-reactive-large-files -Dformat.skip"
JVM_TEST_MAVEN_OPTS: "-e -B --settings ${{ github.workspace }}/.github/mvn-settings.xml -Dtest-containers -Dstart-containers -Dtest-resteasy-reactive-large-files -Dformat.skip"
DB_USER: hibernate_orm_test
DB_PASSWORD: hibernate_orm_test
DB_NAME: hibernate_orm_test
Expand Down
36 changes: 34 additions & 2 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
<maven.repo.local>${settings.localRepository}</maven.repo.local>
<maven.settings>${session.request.userSettingsFile.path}</maven.settings>
<!-- some dev tools tests need the following properties -->
<project.version>${project.version}</project.version>
<project.groupId>${project.groupId}</project.groupId>
Expand All @@ -461,7 +460,6 @@
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
<maven.repo.local>${settings.localRepository}</maven.repo.local>
<maven.settings>${session.request.userSettingsFile.path}</maven.settings>
<!-- some dev tools tests need the following properties -->
<project.version>${project.version}</project.version>
<project.groupId>${project.groupId}</project.groupId>
Expand Down Expand Up @@ -1281,5 +1279,39 @@
</plugins>
</build>
</profile>

<profile>
<id>user-session-settings</id>
<activation>
<file>
<exists>${session.request.userSettingsFile.path}</exists>
</file>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<!-- combine.self suppresses warnings about java.io.tmpdir being defined twice -->
<systemPropertyVariables combine.self="override">
<maven.settings>${session.request.userSettingsFile.path}</maven.settings>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<maven.settings>${session.request.userSettingsFile.path}</maven.settings>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
6 changes: 4 additions & 2 deletions devtools/cli/src/test/java/io/quarkus/cli/CliDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Result execute() throws Exception {
PrintStream errPs = new PrintStream(err);
System.setErr(errPs);

final Map<String, String> originalProps = collectOverridenProps(newArgs);
final Map<String, String> originalProps = collectOverriddenProps(newArgs);

Result result = new Result();
QuarkusCli cli = new QuarkusCli();
Expand Down Expand Up @@ -109,7 +109,7 @@ protected void resetProperties(Map<String, String> originalProps) {
}
}

protected Map<String, String> collectOverridenProps(List<String> newArgs) {
protected Map<String, String> collectOverriddenProps(List<String> newArgs) {
final Map<String, String> originalProps = new HashMap<>();
for (String s : newArgs) {
if (s.startsWith("-D")) {
Expand All @@ -121,6 +121,8 @@ protected Map<String, String> collectOverridenProps(List<String> newArgs) {
originalProps.put(propName, origValue);
} else if (System.getProperties().contains(propName)) {
originalProps.put(propName, "true");
} else {
originalProps.put(propName, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.cli;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Files;
Expand Down Expand Up @@ -59,7 +59,7 @@ static void setup() throws Exception {

final BootstrapMavenContext mavenContext = new BootstrapMavenContext(
BootstrapMavenContext.config().setWorkspaceDiscovery(false));
final Settings settings = getBaseMavenSettings(mavenContext.getUserSettings().toPath());
final Settings settings = getBaseMavenSettings(mavenContext.getUserSettings());

Profile profile = new Profile();
settings.addActiveProfile("qs-test-registry");
Expand Down Expand Up @@ -106,11 +106,9 @@ protected static String getCurrentQuarkusVersion() {
return v;
}

private static Settings getBaseMavenSettings(Path mavenSettings) throws IOException {
if (Files.exists(mavenSettings)) {
try (BufferedReader reader = Files.newBufferedReader(mavenSettings)) {
return new DefaultSettingsReader().read(reader, Map.of());
}
private static Settings getBaseMavenSettings(File mavenSettings) throws IOException {
if (mavenSettings != null && mavenSettings.exists()) {
return new DefaultSettingsReader().read(mavenSettings, Map.of());
}
return new Settings();
}
Expand Down

0 comments on commit a5ff366

Please sign in to comment.