diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1ca5870c9..cc101f2e5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,7 +40,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macOS-latest, windows-latest ] - java: [ "11", "17", "21" ] + java: [ "17", "21", "22" ] fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/cli/pom.xml b/cli/pom.xml index 30e80c2bf..57a64558d 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -93,6 +93,17 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + @{argLine} -javaagent:${com.ginsberg:junit5-system-exit:jar} + + true + 9091 + + + diff --git a/cli/src/main/java/org/jboss/pnc/build/finder/cli/Main.java b/cli/src/main/java/org/jboss/pnc/build/finder/cli/Main.java index 9864d85ba..8756e193e 100644 --- a/cli/src/main/java/org/jboss/pnc/build/finder/cli/Main.java +++ b/cli/src/main/java/org/jboss/pnc/build/finder/cli/Main.java @@ -722,10 +722,7 @@ public Void call() { for (LocalFile filename : entry.getValue()) { newMap.put( new Checksum(checksumType, entry.getKey(), filename), - entry.getValue() - .stream() - .map(LocalFile::getFilename) - .collect(Collectors.toUnmodifiableList())); + entry.getValue().stream().map(LocalFile::getFilename).toList()); } } } diff --git a/cli/src/test/java/org/jboss/pnc/build/finder/cli/MainTest.java b/cli/src/test/java/org/jboss/pnc/build/finder/cli/MainTest.java index 0f7e2c8ac..35b2149f8 100644 --- a/cli/src/test/java/org/jboss/pnc/build/finder/cli/MainTest.java +++ b/cli/src/test/java/org/jboss/pnc/build/finder/cli/MainTest.java @@ -30,8 +30,6 @@ import org.jboss.pnc.build.finder.core.TestUtils; import org.jboss.pnc.build.finder.core.Utils; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.io.TempDir; import org.junitpioneer.jupiter.StdIo; import org.junitpioneer.jupiter.StdOut; @@ -54,7 +52,6 @@ private static ParseResult parseCommandLine(Object command, String[] args) { @ExpectSystemExitWithStatus(0) @StdIo @Test - @DisabledForJreRange(min = JRE.JAVA_18) void testHelp(StdOut out) { String[] args = { "--help" }; @@ -70,7 +67,6 @@ void testHelp(StdOut out) { @ExpectSystemExitWithStatus(0) @StdIo @Test - @DisabledForJreRange(min = JRE.JAVA_18) void testVersion(StdOut out) { String[] args = { "--version" }; ParseResult parseResult = parseCommandLine(new Main(), args); @@ -170,7 +166,6 @@ void testParsing(@TempDir File folder) throws IOException { @ExpectSystemExitWithStatus(0) @StdIo @Test - @DisabledForJreRange(min = JRE.JAVA_18) void testConfig(@TempDir File folder, StdOut out) throws IOException { File configFile = TestUtils.loadFile("config.json"); File inputFile = TestUtils.loadFile("nested.war"); @@ -210,7 +205,6 @@ void testConfig(@TempDir File folder, StdOut out) throws IOException { @ExpectSystemExitWithStatus(0) @StdIo @Test - @DisabledForJreRange(min = JRE.JAVA_18) void testDebug(@TempDir File folder, StdOut out) throws IOException { File configFile = TestUtils.loadFile("config.json"); File inputFile = TestUtils.loadFile("nested.war"); @@ -267,7 +261,6 @@ void testDebug(@TempDir File folder, StdOut out) throws IOException { @ExpectSystemExitWithStatus(0) @StdIo @Test - @DisabledForJreRange(min = JRE.JAVA_18) void testQuiet(@TempDir File folder, StdOut out) throws IOException { File configFile = TestUtils.loadFile("config.json"); File inputFile = TestUtils.loadFile("nested.war"); diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinder.java b/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinder.java index 8bd8acbac..55d5c7144 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinder.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinder.java @@ -281,15 +281,12 @@ private void handleRPMs(Collection>> rpmEntri .map(KojiRpmInfo::getBuildId) .filter(Objects::nonNull) .map(KojiIdOrName::getFor) - .collect(Collectors.toUnmodifiableList()); + .toList(); Future> futureRpmBuildInfos = pool.submit(() -> session.getBuild(rpmBuildIds)); Future>> futureRpmTagInfos = pool.submit(() -> session.listTags(rpmBuildIds)); Future>> futureRpmRpmInfos = pool.submit(() -> session.listBuildRPMs(rpmBuildIds)); List rpmBuildInfos = futureRpmBuildInfos.get(); - List taskIds = rpmBuildInfos.stream() - .map(KojiBuildInfo::getTaskId) - .filter(Objects::nonNull) - .collect(Collectors.toUnmodifiableList()); + List taskIds = rpmBuildInfos.stream().map(KojiBuildInfo::getTaskId).filter(Objects::nonNull).toList(); int taskIdsSize = taskIds.size(); List rpmTaskInfos = null; Future> futureRpmTaskInfos = null; @@ -439,7 +436,7 @@ private KojiBuild findBestBuildFromCandidates(List candidates, List candidateIds = candidates.stream() .map(KojiBuild::getBuildInfo) .map(KojiBuildInfo::getId) - .collect(Collectors.toUnmodifiableList()); + .toList(); LOGGER.debug("Found {} builds containing archive with checksum {}: {}", candidatesSize, checksum, candidateIds); @@ -461,7 +458,7 @@ private KojiBuild findBestBuildFromCandidates(List candidates, List cachedBuilds = candidateIds.stream() .map(id -> builds.get(new BuildSystemInteger(id, BuildSystem.koji))) .filter(Objects::nonNull) - .collect(Collectors.toUnmodifiableList()); + .toList(); if (!cachedBuilds.isEmpty()) { KojiBuild build = cachedBuilds.get(cachedBuilds.size() - 1); @@ -473,13 +470,13 @@ private KojiBuild findBestBuildFromCandidates(List candidates, List completedBuilds = candidates.stream() .filter(build -> build.getBuildInfo().getBuildState() == KojiBuildState.COMPLETE) - .collect(Collectors.toUnmodifiableList()); + .toList(); List completedTaggedBuilds = completedBuilds.stream() .filter(build -> build.getTags() != null && !build.getTags().isEmpty()) - .collect(Collectors.toUnmodifiableList()); + .toList(); List completedTaggedBuiltBuilds = completedTaggedBuilds.stream() .filter(build -> !build.isImport()) - .collect(Collectors.toUnmodifiableList()); + .toList(); if (!completedTaggedBuiltBuilds.isEmpty()) { KojiBuild build = completedTaggedBuiltBuilds.get(completedTaggedBuiltBuilds.size() - 1); @@ -530,7 +527,7 @@ private KojiBuild findBestBuildFromCandidates(List candidates, List handleNotFoundFile(String filename) { LOGGER.debug("Handle not found file: {}", filename); @@ -581,7 +578,7 @@ private Optional handleNotFoundFile(String filename) { * using a particular checksum type, but then was found later using another checksum type. * * @param filename the filename - * @return the parent of the file name (separated by "!/"") + * @return the parent of the file name (separated by "!/") */ private Optional handleFoundFile(String filename) { LOGGER.debug("Handle found file: {}", filename); @@ -688,10 +685,7 @@ public Map findBuilds(Map findBuilds(Map archivesToEnrich = archives.stream() - .flatMap(List::stream) - .collect(Collectors.toUnmodifiableList()); + List archivesToEnrich = archives.stream().flatMap(List::stream).toList(); session.enrichArchiveTypeInfo(archivesToEnrich); @@ -857,9 +849,7 @@ public Map findBuilds(Map idsOrNames = buildIds.stream() - .map(KojiIdOrName::getFor) - .collect(Collectors.toUnmodifiableList()); + List idsOrNames = buildIds.stream().map(KojiIdOrName::getFor).toList(); Future> futureArchiveBuilds = pool.submit(() -> session.getBuild(idsOrNames)); Future>> futureTagInfos = pool.submit(() -> session.listTags(idsOrNames)); List queries = new ArrayList<>(buildIdsSize); @@ -1222,7 +1212,7 @@ private static List getKojiBuildsForArchives( Set buildIds = archiveInfos.stream() .map(KojiArchiveInfo::getBuildId) .collect(Collectors.toCollection(HashSet::new)); - return buildIds.stream().map(allBuilds::get).collect(Collectors.toUnmodifiableList()); + return buildIds.stream().map(allBuilds::get).toList(); } public Map> getFoundChecksums() { @@ -1402,7 +1392,7 @@ public Map call() throws KojiClientException { .map(LicenseInfo::getSpdxLicenseId) .sorted() .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); if (LOGGER.isInfoEnabled()) { LOGGER.info( @@ -1415,7 +1405,7 @@ public Map call() throws KojiClientException { kojiBuild -> kojiBuild.getArchives() .stream() .anyMatch(kojiLocalArchive -> !kojiLocalArchive.getLicenses().isEmpty())) - .collect(Collectors.toUnmodifiableList()); + .toList(); int numBuildsWithLicenses = buildsWithLicenses.size(); LOGGER.info( "{} / {} = {}% of builds have license information", @@ -1426,7 +1416,7 @@ public Map call() throws KojiClientException { List archives = allBuilds.values() .stream() .flatMap(kojiBuild -> kojiBuild.getArchives().stream()) - .collect(Collectors.toUnmodifiableList()); + .toList(); int numArchives = archives.size(); long numArchivesWithLicenses = archives.stream() .filter(kojiLocalArchive -> !kojiLocalArchive.getLicenses().isEmpty()) diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinderUtils.java b/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinderUtils.java index 7d55486f6..784cc3e82 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinderUtils.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/BuildFinderUtils.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import java.util.zip.ZipOutputStream; import org.apache.commons.codec.binary.Hex; @@ -348,10 +347,7 @@ private static List getArchiveExtensionsFromKoji(BuildConfig config, Cli throws KojiClientException { Map allArchiveTypesMap = session.getArchiveTypeMap(); - List allArchiveTypes = allArchiveTypesMap.values() - .stream() - .map(KojiArchiveType::getName) - .collect(Collectors.toUnmodifiableList()); + List allArchiveTypes = allArchiveTypesMap.values().stream().map(KojiArchiveType::getName).toList(); List archiveTypes = config.getArchiveTypes(); List archiveTypesToCheck; @@ -365,9 +361,7 @@ private static List getArchiveExtensionsFromKoji(BuildConfig config, Cli String.join(", ", archiveTypes)); } - archiveTypesToCheck = archiveTypes.stream() - .filter(allArchiveTypesMap::containsKey) - .collect(Collectors.toUnmodifiableList()); + archiveTypesToCheck = archiveTypes.stream().filter(allArchiveTypesMap::containsKey).toList(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( @@ -387,7 +381,7 @@ private static List getArchiveExtensionsFromKoji(BuildConfig config, Cli .stream() .map(KojiArchiveType::getExtensions) .flatMap(List::stream) - .collect(Collectors.toUnmodifiableList()); + .toList(); List extensions = config.getArchiveExtensions(); List extensionsToCheck; @@ -399,9 +393,7 @@ private static List getArchiveExtensionsFromKoji(BuildConfig config, Cli String.join(", ", extensions)); } - extensionsToCheck = extensions.stream() - .filter(allArchiveExtensions::contains) - .collect(Collectors.toUnmodifiableList()); + extensionsToCheck = extensions.stream().filter(allArchiveExtensions::contains).toList(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/Checksum.java b/core/src/main/java/org/jboss/pnc/build/finder/core/Checksum.java index a35777a5e..47bab194f 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/Checksum.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/Checksum.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.Serial; import java.io.Serializable; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -34,7 +35,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; import org.apache.commons.codec.binary.Hex; import org.apache.commons.lang3.StringUtils; @@ -55,6 +55,7 @@ public class Checksum implements Comparable, Serializable { private static final Logger LOGGER = LoggerFactory.getLogger(Checksum.class); + @Serial private static final long serialVersionUID = -7347509034711302799L; private static final int BUFFER_SIZE = 1024; @@ -256,9 +257,7 @@ public static Set checksum(FileObject fo, Collection che } static Optional findByType(Collection checksums, ChecksumType type) { - List list = checksums.stream() - .filter(checksum -> checksum.getType() == type) - .collect(Collectors.toUnmodifiableList()); + List list = checksums.stream().filter(checksum -> checksum.getType() == type).toList(); Checksum checksum = null; if (!list.isEmpty()) { diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/DistributionAnalyzer.java b/core/src/main/java/org/jboss/pnc/build/finder/core/DistributionAnalyzer.java index 3e9b7f16f..c21a39297 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/DistributionAnalyzer.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/DistributionAnalyzer.java @@ -353,7 +353,7 @@ public Map> checksumFiles() thro .stream() .flatMap(Collection::stream) .map(LicenseInfo::getSpdxLicenseId) - .collect(Collectors.toUnmodifiableList()); + .toList(); Set uniqueLicenses = new TreeSet<>(totalLicenses); Map licenseCountMap = totalLicenses.stream().collect(groupingBy(identity(), counting())); String licenseCounts = licenseCountMap.entrySet() @@ -497,11 +497,10 @@ private void listArchive(FileObject fo) { private static String getMessage(Throwable t) { StringBuilder sb = new StringBuilder(32); - if (t instanceof java.nio.file.FileSystemException) { - java.nio.file.FileSystemException fse = (java.nio.file.FileSystemException) t; + if (t instanceof java.nio.file.FileSystemException fse) { if (fse instanceof DirectoryNotEmptyException) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append(": "); } @@ -667,7 +666,7 @@ private List addLicensesFromJar(FileObject jar, List lo .map(localFile -> addLicensesFromJar(jar, localFile)) .filter(not(Collection::isEmpty)) .flatMap(Collection::stream) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private List addLicensesFromJar(FileObject jar, FileObject localFile) { diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/MavenUtils.java b/core/src/main/java/org/jboss/pnc/build/finder/core/MavenUtils.java index 9f64d44a5..57399eb82 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/MavenUtils.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/MavenUtils.java @@ -25,7 +25,6 @@ import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.apache.commons.vfs2.FileContent; import org.apache.commons.vfs2.FileObject; @@ -149,10 +148,7 @@ public static String getGAV(MavenProject project) { * @return the list of Maven projects (may be empty) */ public static List getLicenses(MavenProject project, LicenseSource source) { - return project.getLicenses() - .stream() - .map(license -> new LicenseInfo(license, source)) - .collect(Collectors.toUnmodifiableList()); + return project.getLicenses().stream().map(license -> new LicenseInfo(license, source)).toList(); } /** diff --git a/core/src/main/java/org/jboss/pnc/build/finder/core/PncBuildFinder.java b/core/src/main/java/org/jboss/pnc/build/finder/core/PncBuildFinder.java index 38f78b310..3ba8c1c5d 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/core/PncBuildFinder.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/core/PncBuildFinder.java @@ -240,46 +240,30 @@ private Optional findArtifactInPnc(Checksum checksum, Collection lookupPncArtifactsByChecksum(Checksum checksum) throws RemoteResourceException { - switch (checksum.getType()) { - case md5: - return pncClient.getArtifactsByMd5(checksum.getValue()).getAll(); - - case sha1: - return pncClient.getArtifactsBySha1(checksum.getValue()).getAll(); - - case sha256: - return pncClient.getArtifactsBySha256(checksum.getValue()).getAll(); - - default: - throw new IllegalArgumentException( - "Unsupported checksum type requested! Checksum type " + checksum.getType() - + " is not supported."); - } + return switch (checksum.getType()) { + case md5 -> pncClient.getArtifactsByMd5(checksum.getValue()).getAll(); + case sha1 -> pncClient.getArtifactsBySha1(checksum.getValue()).getAll(); + case sha256 -> pncClient.getArtifactsBySha256(checksum.getValue()).getAll(); + }; } private static int getArtifactQuality(Object obj) { Artifact a = (Artifact) obj; ArtifactQuality quality = a.getArtifactQuality(); - switch (quality) { - case NEW: - return 1; - case VERIFIED: - return 2; - case TESTED: - return 3; - case DEPRECATED: - return -1; - case BLACKLISTED: - return -2; - case TEMPORARY: - return -3; - case DELETED: - return -4; - default: + return switch (quality) { + case NEW -> 1; + case VERIFIED -> 2; + case TESTED -> 3; + case DEPRECATED -> -1; + case BLACKLISTED -> -2; + case TEMPORARY -> -3; + case DELETED -> -4; + default -> { LOGGER.warn("Unsupported ArtifactQuality! Got: {}", quality); - return -100; - } + yield -100; + } + }; } private static Optional getBestPncArtifact(Collection artifacts) { diff --git a/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiClientSession.java b/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiClientSession.java index 2ce143a63..cbe2bdcbb 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiClientSession.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiClientSession.java @@ -26,7 +26,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.commonjava.o11yphant.metrics.api.MetricRegistry; import org.commonjava.util.jhttpc.auth.MemoryPasswordManager; @@ -240,7 +239,7 @@ public List getTaskInfo(List taskIds, List reque @Override public List> listTags(List idsOrNames) throws KojiClientException { - List buildIds = idsOrNames.stream().map(KojiIdOrName::getId).collect(Collectors.toUnmodifiableList()); + List buildIds = idsOrNames.stream().map(KojiIdOrName::getId).toList(); return helper.listTagsByIds(buildIds, session); } diff --git a/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiLocalArchive.java b/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiLocalArchive.java index 66bbfb599..f45c0da7c 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiLocalArchive.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/koji/KojiLocalArchive.java @@ -75,17 +75,12 @@ public static boolean isMissingBuildTypeInfo(KojiArchiveInfo archive) { return false; } - switch (archiveBuildType) { - case "image": - return archive.getArch() == null; - case "maven": - return archive.getGroupId() == null; - case "win": - return archive.getPlatforms() == null; - case "rpm": - default: - return false; - } + return switch (archiveBuildType) { + case "image" -> archive.getArch() == null; + case "maven" -> archive.getGroupId() == null; + case "win" -> archive.getPlatforms() == null; + default -> false; + }; } public KojiArchiveInfo getArchive() { diff --git a/core/src/main/java/org/jboss/pnc/build/finder/pnc/client/PncUtils.java b/core/src/main/java/org/jboss/pnc/build/finder/pnc/client/PncUtils.java index a045efa0b..65ca398b1 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/pnc/client/PncUtils.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/pnc/client/PncUtils.java @@ -357,19 +357,12 @@ public static KojiArchiveInfo artifactToKojiArchiveInfo(PncBuild pncbuild, Artif private static String getBuildType(PncBuild pncBuild) { BuildType buildType = pncBuild.getBuild().getBuildConfigRevision().getBuildType(); - switch (buildType) { - case MVN: - return MAVEN; - case GRADLE: - return GRADLE; - case NPM: - return NPM; - case SBT: - return SBT; - default: - LOGGER.warn("Unsupported build type conversion for: {}", buildType); - return UNKNOWN; - } + return switch (buildType) { + case MVN -> MAVEN; + case GRADLE -> GRADLE; + case NPM -> NPM; + case SBT -> SBT; + }; } public static void fixNullVersion(KojiBuild kojibuild, KojiArchiveInfo archiveInfo) { diff --git a/core/src/main/java/org/jboss/pnc/build/finder/protobuf/MultiValuedMapProtobufWrapper.java b/core/src/main/java/org/jboss/pnc/build/finder/protobuf/MultiValuedMapProtobufWrapper.java index fddb7a306..1d000b229 100644 --- a/core/src/main/java/org/jboss/pnc/build/finder/protobuf/MultiValuedMapProtobufWrapper.java +++ b/core/src/main/java/org/jboss/pnc/build/finder/protobuf/MultiValuedMapProtobufWrapper.java @@ -16,7 +16,6 @@ package org.jboss.pnc.build.finder.protobuf; import java.util.Collection; -import java.util.stream.Collectors; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.multimap.HashSetValuedHashMap; @@ -59,7 +58,7 @@ Collection> getEntries() { .entrySet() .stream() .map(a -> new MultiValuedMapProtobufEntry<>(a.getKey(), a.getValue())) - .collect(Collectors.toUnmodifiableList()); + .toList(); } /** @@ -93,7 +92,7 @@ static class MultiValuedMapProtobufEntry { @ProtoFactory MultiValuedMapProtobufEntry(WrappedMessage key, Collection values) { this.key = (K) key.getValue(); - this.values = values.stream().map(a -> (V) a.getValue()).collect(Collectors.toUnmodifiableList()); + this.values = values.stream().map(a -> (V) a.getValue()).toList(); } @ProtoField(number = 1) @@ -103,7 +102,7 @@ WrappedMessage getKey() { @ProtoField(number = 2) Collection getValues() { - return this.values.stream().map(WrappedMessage::new).collect(Collectors.toUnmodifiableList()); + return this.values.stream().map(WrappedMessage::new).toList(); } } } diff --git a/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedAndDeletedBuildTest.java b/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedAndDeletedBuildTest.java index f5e326ac7..ec6edefcc 100644 --- a/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedAndDeletedBuildTest.java +++ b/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedAndDeletedBuildTest.java @@ -48,7 +48,7 @@ static void setup() throws MalformedURLException { } @Test - void testDeletedAndCompleteBuilds() throws KojiClientException, MalformedURLException { + void testDeletedAndCompleteBuilds() throws KojiClientException { Map> checksumTable = getChecksumTable(); try (KojiClientSession session = new KojiClientSession(config.getKojiHubURL())) { diff --git a/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedBuildTest.java b/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedBuildTest.java index c2a05d741..071961463 100644 --- a/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedBuildTest.java +++ b/core/src/test/java/org/jboss/pnc/build/finder/core/CompletedBuildTest.java @@ -47,7 +47,7 @@ static void setup() throws MalformedURLException { } @Test - void testCompletedBuilds() throws KojiClientException, MalformedURLException { + void testCompletedBuilds() throws KojiClientException { Map> checksumTable = getChecksumTable(); try (KojiClientSession session = new KojiClientSession(config.getKojiHubURL())) { diff --git a/core/src/test/java/org/jboss/pnc/build/finder/core/DeletedBuildTest.java b/core/src/test/java/org/jboss/pnc/build/finder/core/DeletedBuildTest.java index bdb1c08cf..dd881c527 100644 --- a/core/src/test/java/org/jboss/pnc/build/finder/core/DeletedBuildTest.java +++ b/core/src/test/java/org/jboss/pnc/build/finder/core/DeletedBuildTest.java @@ -47,7 +47,7 @@ static void setup() throws MalformedURLException { } @Test - void testDeletedBuild() throws KojiClientException, MalformedURLException { + void testDeletedBuild() throws KojiClientException { try (KojiClientSession session = new KojiClientSession(config.getKojiHubURL())) { BuildFinder finder = new BuildFinder(session, config); Map builds = finder.findBuilds(getChecksumTable()); diff --git a/core/src/test/java/org/jboss/pnc/build/finder/core/EmptyBuildsTest.java b/core/src/test/java/org/jboss/pnc/build/finder/core/EmptyBuildsTest.java index 64d1170f1..f86dcbd7f 100644 --- a/core/src/test/java/org/jboss/pnc/build/finder/core/EmptyBuildsTest.java +++ b/core/src/test/java/org/jboss/pnc/build/finder/core/EmptyBuildsTest.java @@ -93,7 +93,7 @@ Map> getChecksumTable() { } @Test - void shouldSkipOnEmptyZipFile() throws MalformedURLException, KojiClientException { + void shouldSkipOnEmptyZipFile() throws KojiClientException { // 76cdb2bad9582d23c1f6f4d868218d6c is md5 for empty zip file with size of 22 bytes String filename = "empty.zip"; Collection filenames = Collections.singletonList("empty.zip"); diff --git a/core/src/test/java/org/jboss/pnc/build/finder/core/SkipImportTest.java b/core/src/test/java/org/jboss/pnc/build/finder/core/SkipImportTest.java index f2aa1ff93..2a3ad0fe5 100644 --- a/core/src/test/java/org/jboss/pnc/build/finder/core/SkipImportTest.java +++ b/core/src/test/java/org/jboss/pnc/build/finder/core/SkipImportTest.java @@ -47,7 +47,7 @@ static void setup() throws MalformedURLException { } @Test - void testMultiImportsKeepEarliest() throws KojiClientException, MalformedURLException { + void testMultiImportsKeepEarliest() throws KojiClientException { Map> checksumTable = getChecksumTable(); try (KojiClientSession session = new KojiClientSession(config.getKojiHubURL())) { diff --git a/maven-version-rules.xml b/maven-version-rules.xml index 8c83f508d..31a826592 100644 --- a/maven-version-rules.xml +++ b/maven-version-rules.xml @@ -30,21 +30,6 @@ .+-rc\d+ - - - [^1]\..+ - - - - - ([^1]\..+|1\.[^9].*) - - - - - ([^2]\..+|2\.[^2].*|2\.2[^3].*) - - [^3]\..+ diff --git a/pom.xml b/pom.xml index 0b9ba3d2b..8ae9b5890 100644 --- a/pom.xml +++ b/pom.xml @@ -65,14 +65,14 @@ - 11 + 17 3.6.3 UTF-8 true 1.5.12 2.18.1 - 1.1.2 + 2.0.2 4.0.0 1.5.6-7 4.8.6 @@ -86,8 +86,8 @@ 2.17.0 4.7.6 4.2.28 - 2.23.0 - 1.9.0 + 2.24.1 + 1.12.0 7.7.0 4.4 1.27.1 diff --git a/report/src/main/java/org/jboss/pnc/build/finder/report/GAVReport.java b/report/src/main/java/org/jboss/pnc/build/finder/report/GAVReport.java index 89759aff9..45c14a998 100644 --- a/report/src/main/java/org/jboss/pnc/build/finder/report/GAVReport.java +++ b/report/src/main/java/org/jboss/pnc/build/finder/report/GAVReport.java @@ -56,7 +56,7 @@ public GAVReport(File outputDirectory, Collection builds) { + localArchive.getArchive().getVersion()) .sorted() .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/report/src/main/java/org/jboss/pnc/build/finder/report/HTMLReport.java b/report/src/main/java/org/jboss/pnc/build/finder/report/HTMLReport.java index 3f76661f9..27d932835 100644 --- a/report/src/main/java/org/jboss/pnc/build/finder/report/HTMLReport.java +++ b/report/src/main/java/org/jboss/pnc/build/finder/report/HTMLReport.java @@ -57,7 +57,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -241,7 +240,7 @@ private static List gln(KojiBuild build) { .filter(StringUtils::isNotEmpty) .sorted() .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/report/src/main/java/org/jboss/pnc/build/finder/report/NVRReport.java b/report/src/main/java/org/jboss/pnc/build/finder/report/NVRReport.java index ce0855a58..9b26e0597 100644 --- a/report/src/main/java/org/jboss/pnc/build/finder/report/NVRReport.java +++ b/report/src/main/java/org/jboss/pnc/build/finder/report/NVRReport.java @@ -56,7 +56,7 @@ public NVRReport(File outputDirectory, Collection builds) { .map(KojiBuildInfo::getNvr) .sorted(String::compareToIgnoreCase) .distinct() - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/report/src/main/java/org/jboss/pnc/build/finder/report/ProductReport.java b/report/src/main/java/org/jboss/pnc/build/finder/report/ProductReport.java index a97042d1b..67c361e44 100644 --- a/report/src/main/java/org/jboss/pnc/build/finder/report/ProductReport.java +++ b/report/src/main/java/org/jboss/pnc/build/finder/report/ProductReport.java @@ -77,12 +77,12 @@ public ProductReport(File outputDirectory, Collection builds) { build -> build.getTaskRequest() != null && build.getTaskRequest().asBuildRequest() != null && build.getTaskRequest().asBuildRequest().getTarget() != null) .map(build -> build.getTaskRequest().asBuildRequest().getTarget()) - .collect(Collectors.toUnmodifiableList()); + .toList(); Map map = targets.stream().collect(Collectors.groupingBy(identity(), counting())); List> countList = map.entrySet() .stream() .sorted(Entry. comparingByValue().reversed()) - .collect(Collectors.toUnmodifiableList()); + .toList(); MultiValuedMap prodMap = new ArrayListValuedHashMap<>(); for (KojiBuild build : builds) { @@ -113,9 +113,7 @@ public ProductReport(File outputDirectory, Collection builds) { for (Entry> entry : entrySet) { String target = entry.getKey(); Collection prodBuilds = entry.getValue(); - List buildList = prodBuilds.stream() - .map(build -> build.getBuildInfo().getNvr()) - .collect(Collectors.toUnmodifiableList()); + List buildList = prodBuilds.stream().map(build -> build.getBuildInfo().getNvr()).toList(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} ({}): {}", target, targetToProduct(target), buildList); diff --git a/report/src/main/java/org/jboss/pnc/build/finder/report/Report.java b/report/src/main/java/org/jboss/pnc/build/finder/report/Report.java index 40ae19d8d..a0fa8ad7f 100644 --- a/report/src/main/java/org/jboss/pnc/build/finder/report/Report.java +++ b/report/src/main/java/org/jboss/pnc/build/finder/report/Report.java @@ -17,7 +17,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; import java.util.Optional; @@ -74,9 +73,7 @@ public void outputText() throws IOException { return; } - Files.write( - new File(outputDirectory, baseFilename + ".txt").toPath(), - renderText.get().getBytes(StandardCharsets.UTF_8)); + Files.writeString(new File(outputDirectory, baseFilename + ".txt").toPath(), renderText.get()); } public abstract ContainerTag> toHTML(); @@ -88,9 +85,7 @@ public void outputHTML() throws IOException { return; } - Files.write( - new File(outputDirectory, baseFilename + ".html").toPath(), - renderText.get().getBytes(StandardCharsets.UTF_8)); + Files.writeString(new File(outputDirectory, baseFilename + ".html").toPath(), renderText.get()); } public String getName() {