Skip to content

Commit 9b0ee8f

Browse files
Name Surnameakridl
authored andcommitted
Support Reqour_Java and mark Repour-java as deprecated
1 parent 9710b8b commit 9b0ee8f

File tree

7 files changed

+53
-11
lines changed

7 files changed

+53
-11
lines changed

adjuster/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<artifactId>quarkus-wiremock-test</artifactId>
102102
<scope>test</scope>
103103
</dependency>
104+
<dependency>
105+
<groupId>io.quarkus</groupId>
106+
<artifactId>quarkus-junit5-internal</artifactId>
107+
<scope>test</scope>
108+
</dependency>
104109
</dependencies>
105110

106111
<build>

adjuster/src/main/java/org/jboss/pnc/reqour/adjust/config/manipulator/common/CommonManipulatorConfigUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.jboss.pnc.reqour.adjust.model.UserSpecifiedAlignmentParameters;
3131
import org.jboss.pnc.reqour.common.utils.IOUtils;
3232
import org.jboss.pnc.reqour.config.ConfigConstants;
33+
import org.slf4j.Logger;
3334

3435
import lombok.extern.slf4j.Slf4j;
3536

@@ -177,11 +178,13 @@ public static boolean isPreferPersistentEnabled(AdjustRequest request) {
177178
* Get the location of the java within the container environment. In case user specified none, defaults to java
178179
* {@value DEFAULT_JAVA_VERSION}.
179180
*/
180-
public static Path getJavaLocation(List<String> userSpecifiedAlignmentParameters) {
181+
public static Path getJavaLocation(Logger userLogger, List<String> userSpecifiedAlignmentParameters) {
181182
Optional<String> jvmLocationSystemProperty = userSpecifiedAlignmentParameters.stream()
182-
.filter(p -> p.startsWith("-DRepour_Java"))
183+
.filter(p -> p.startsWith("-DRepour_Java") || p.startsWith("-DReqour_Java"))
183184
.findFirst();
184-
185+
if (jvmLocationSystemProperty.isPresent() && jvmLocationSystemProperty.get().startsWith("-DRepour_Java")) {
186+
userLogger.warn("-DRepour_Java is deprecated; use -DReqour_Java");
187+
}
185188
String javaVersion = jvmLocationSystemProperty.map(s -> s.split("=")[1])
186189
.orElse(DEFAULT_JAVA_VERSION);
187190
log.debug("Parsed java version: {}", javaVersion);

adjuster/src/main/java/org/jboss/pnc/reqour/adjust/provider/GradleProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ private void validateConfig() {
100100

101101
@Override
102102
List<String> prepareCommand() {
103-
Path javaLocation = CommonManipulatorConfigUtils.getJavaLocation(config.getUserSpecifiedAlignmentParameters());
103+
Path javaLocation = CommonManipulatorConfigUtils
104+
.getJavaLocation(userLogger, config.getUserSpecifiedAlignmentParameters());
104105
List<String> targetAndInit = getTargetAndInit();
105106

106107
return AdjustmentSystemPropertiesUtils.joinSystemPropertiesListsIntoList(

adjuster/src/main/java/org/jboss/pnc/reqour/adjust/provider/MvnProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ private void validateConfig() {
121121

122122
@Override
123123
List<String> prepareCommand() {
124-
Path javaLocation = CommonManipulatorConfigUtils.getJavaLocation(config.getUserSpecifiedAlignmentParameters());
124+
Path javaLocation = CommonManipulatorConfigUtils
125+
.getJavaLocation(userLogger, config.getUserSpecifiedAlignmentParameters());
125126
return AdjustmentSystemPropertiesUtils.joinSystemPropertiesListsIntoList(
126127
List.of(
127128
List.of(javaLocation.toString(), "-jar", config.getCliJarPath().toString()),

adjuster/src/main/java/org/jboss/pnc/reqour/adjust/provider/NpmProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ private void validateConfig() {
8484

8585
@Override
8686
List<String> prepareCommand() {
87-
Path javaLocation = CommonManipulatorConfigUtils.getJavaLocation(config.getUserSpecifiedAlignmentParameters());
87+
Path javaLocation = CommonManipulatorConfigUtils
88+
.getJavaLocation(userLogger, config.getUserSpecifiedAlignmentParameters());
8889
return AdjustmentSystemPropertiesUtils.joinSystemPropertiesListsIntoList(
8990
List.of(
9091
List.of(javaLocation.toString(), "-jar", config.getCliJarPath().toString()),

adjuster/src/test/java/org/jboss/pnc/reqour/adjust/config/manipulator/common/CommonManipulatorConfigUtilsTest.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
import static org.assertj.core.api.Assertions.assertThat;
88
import static org.assertj.core.api.Assertions.assertThatThrownBy;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
import java.nio.file.Path;
1112
import java.util.Collections;
1213
import java.util.List;
1314
import java.util.Map;
1415
import java.util.Optional;
16+
import java.util.logging.LogRecord;
1517

1618
import org.jboss.pnc.api.constants.BuildConfigurationParameterKeys;
1719
import org.jboss.pnc.api.reqour.dto.AdjustRequest;
@@ -20,6 +22,18 @@
2022
import org.jboss.pnc.reqour.adjust.model.UserSpecifiedAlignmentParameters;
2123
import org.junit.jupiter.api.Test;
2224

25+
import io.quarkus.test.LogCollectingTestResource;
26+
import io.quarkus.test.common.QuarkusTestResource;
27+
import io.quarkus.test.common.ResourceArg;
28+
import io.quarkus.test.junit.QuarkusTest;
29+
import lombok.extern.slf4j.Slf4j;
30+
31+
@QuarkusTest
32+
@QuarkusTestResource(
33+
value = LogCollectingTestResource.class,
34+
restrictToAnnotatedClass = true,
35+
initArgs = @ResourceArg(name = LogCollectingTestResource.LEVEL, value = "FINE"))
36+
@Slf4j
2337
class CommonManipulatorConfigUtilsTest {
2438

2539
@Test
@@ -221,13 +235,25 @@ void parseUserSpecifiedAlignmentParametersWithoutLocation_newlineInUsersParamete
221235

222236
@Test
223237
void getJavaLocation_noJavaVersionOverride_defaultIsUsed() {
224-
assertThat(CommonManipulatorConfigUtils.getJavaLocation(Collections.emptyList())).isEqualTo(
238+
assertThat(CommonManipulatorConfigUtils.getJavaLocation(log, Collections.emptyList())).isEqualTo(
225239
CommonManipulatorConfigUtils.getJavaOfVersion(CommonManipulatorConfigUtils.DEFAULT_JAVA_VERSION));
226240
}
227241

228242
@Test
229-
void getJavaLocation_java17VersionOverrideGiven_overrideIsUsed() {
230-
assertThat(CommonManipulatorConfigUtils.getJavaLocation(List.of("-DRepour_Java=17")))
243+
void getJavaLocation_java17VersionOverrideGiven_overrideIsUsedForRepour() {
244+
assertThat(CommonManipulatorConfigUtils.getJavaLocation(log, List.of("-DRepour_Java=17")))
245+
.isEqualTo(CommonManipulatorConfigUtils.getJavaOfVersion("17"));
246+
List<LogRecord> logRecords = LogCollectingTestResource.current().getRecords();
247+
assertTrue(
248+
logRecords.stream()
249+
.anyMatch(
250+
r -> LogCollectingTestResource.format(r)
251+
.contains("-DRepour_Java is deprecated")));
252+
}
253+
254+
@Test
255+
void getJavaLocation_java17VersionOverrideGiven_overrideIsUsedForReqour() {
256+
assertThat(CommonManipulatorConfigUtils.getJavaLocation(log, List.of("-DReqour_Java=17")))
231257
.isEqualTo(CommonManipulatorConfigUtils.getJavaOfVersion("17"));
232258
}
233259

@@ -239,13 +265,13 @@ void getJavaLocation_java24VersionOverrideGiven_overrideIsUsed() {
239265

240266
@Test
241267
void getJavaLocation_java8VersionOverrideGiven_overrideIsUsed() {
242-
assertThat(CommonManipulatorConfigUtils.getJavaLocation(List.of("-DRepour_Java=1.8.0")))
268+
assertThat(CommonManipulatorConfigUtils.getJavaLocation(log, List.of("-DRepour_Java=1.8.0")))
243269
.isEqualTo(CommonManipulatorConfigUtils.getJavaOfVersion("1.8.0"));
244270
}
245271

246272
@Test
247273
void getJavaLocation_invalidJavaVersionOverrideGiven_throwsException() {
248-
assertThatThrownBy(() -> CommonManipulatorConfigUtils.getJavaLocation(List.of("-DRepour_Java=invalid")))
274+
assertThatThrownBy(() -> CommonManipulatorConfigUtils.getJavaLocation(log, List.of("-DRepour_Java=invalid")))
249275
.isInstanceOf(AdjusterException.class)
250276
.hasMessage("Invalid Java version 'invalid' provided.");
251277
}

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@
213213
<artifactId>pom-manipulation-common</artifactId>
214214
<version>${version.pom-manipulation-common}</version>
215215
<exclusions>
216+
<exclusion>
217+
<groupId>ch.qos.logback</groupId>
218+
<artifactId>logback-classic</artifactId>
219+
</exclusion>
216220
<exclusion>
217221
<groupId>org.commonjava.maven.galley</groupId>
218222
<artifactId>galley-maven</artifactId>
@@ -390,6 +394,7 @@
390394
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
391395
<maven.home>${maven.home}</maven.home>
392396
</systemPropertyVariables>
397+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
393398
</configuration>
394399
</plugin>
395400
<plugin>

0 commit comments

Comments
 (0)