diff --git a/adoptium-marketplace-server/adoptium-repo/pom.xml b/adoptium-marketplace-server/adoptium-repo/pom.xml index a4a387b1..7cc976e2 100644 --- a/adoptium-marketplace-server/adoptium-repo/pom.xml +++ b/adoptium-marketplace-server/adoptium-repo/pom.xml @@ -80,7 +80,7 @@ org.jetbrains.kotlin kotlin-maven-allopen - 1.8.10 + 1.9.20 diff --git a/adoptium-marketplace-server/pom.xml b/adoptium-marketplace-server/pom.xml index 4ced1df5..8c14baa2 100644 --- a/adoptium-marketplace-server/pom.xml +++ b/adoptium-marketplace-server/pom.xml @@ -93,7 +93,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.1.0 + 3.3.2 org.apache.maven.plugins @@ -162,7 +162,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.21.0 + 3.21.2 ${jdk.version} @@ -260,7 +260,7 @@ org.codehaus.mojo license-maven-plugin - 2.2.0 + 2.3.0 download-licenses @@ -297,7 +297,7 @@ org.pitest pitest-maven - 1.15.2 + 1.15.3 org.apache.maven.plugins @@ -521,7 +521,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.21.0 + 3.21.2 ${jdk.version} diff --git a/adoptium-marketplace-staging-checker/pom.xml b/adoptium-marketplace-staging-checker/pom.xml index 43234a45..3b1c14a7 100644 --- a/adoptium-marketplace-staging-checker/pom.xml +++ b/adoptium-marketplace-staging-checker/pom.xml @@ -15,7 +15,7 @@ net.adoptium.marketplace.Main uber-jar -jar-with-dependencies - 1.9.20-RC2 + 1.9.20 diff --git a/adoptium-marketplace-utils/pom.xml b/adoptium-marketplace-utils/pom.xml index 03063df3..cb537148 100644 --- a/adoptium-marketplace-utils/pom.xml +++ b/adoptium-marketplace-utils/pom.xml @@ -89,7 +89,7 @@ org.jetbrains.kotlin kotlin-maven-allopen - 1.8.10 + 1.9.20 diff --git a/adoptium-marketplace-utils/src/test/kotlin/ExtractAdoptiumReleases.kt b/adoptium-marketplace-utils/src/test/kotlin/ExtractAdoptiumReleases.kt index 351a6858..2a6aa723 100644 --- a/adoptium-marketplace-utils/src/test/kotlin/ExtractAdoptiumReleases.kt +++ b/adoptium-marketplace-utils/src/test/kotlin/ExtractAdoptiumReleases.kt @@ -1,15 +1,6 @@ -import com.fasterxml.jackson.module.kotlin.readValue -import net.adoptium.api.v3.JsonMapper import net.adoptium.api.v3.models.Release -import net.adoptium.api.v3.parser.VersionParser -import net.adoptium.marketplace.client.MarketplaceMapper import net.adoptium.marketplace.schema.* -import org.eclipse.jetty.client.HttpClient import org.junit.jupiter.api.Test -import java.io.File -import java.io.FileWriter -import java.nio.file.Path -import java.nio.file.Paths import java.util.* class ExtractAdoptiumReleases { @@ -24,13 +15,43 @@ class ExtractAdoptiumReleases { ExtractReleases().buildRepo( VERSIONS, { version -> "https://api.adoptium.net/v3/assets/feature_releases/${version}/ga?page_size=50&vendor=eclipse" }, - { release -> toMarketplaceRelease(release, toMarketplaceBinaries(release)) }, + this::convertToMarketplaceSchema, "/tmp/adoptiumRepo", true ) } - private fun toMarketplaceRelease(release: Release, binaries: List): net.adoptium.marketplace.schema.Release { + private fun convertToMarketplaceSchema( + releases: List + ): List { + val marketplaceReleases = releases + .map { release -> + ReleaseList(listOf(toMarketplaceRelease(release, toMarketplaceBinaries(release)))) + } + .toList() + return mergeSimilarReleases(marketplaceReleases) + } + + private fun mergeSimilarReleases(marketplaceReleases: List): List { + // This can happen as Adoptium versions and OpenJDK versions are not 1:1, Adoptium can create multiple releases + // with different "Adoptium build number" that map to the same OpenJDK version. These releases need to be merged together + // as the marketplace is based on OpenJDK version + return marketplaceReleases + .flatMap { release -> + release.releases + } + .groupBy { Triple(it.openjdkVersionData, it.releaseLink, it.releaseName) } + .map { + ReleaseList(it.value) + } + .toList() + } + + + private fun toMarketplaceRelease( + release: Release, + binaries: List + ): net.adoptium.marketplace.schema.Release { return Release( release.release_link, release.release_name, @@ -92,14 +113,15 @@ class ExtractAdoptiumReleases { binary.`package`.signature_link ), if (binary.installer != null) { - listOf(Installer( - binary.installer!!.name, - binary.installer!!.link, - binary.installer!!.checksum, - binary.installer!!.checksum_link, - binary.installer!!.signature_link, - null - ) + listOf( + Installer( + binary.installer!!.name, + binary.installer!!.link, + binary.installer!!.checksum, + binary.installer!!.checksum_link, + binary.installer!!.signature_link, + null + ) ) } else null, Date.from(binary.updated_at.dateTime.toInstant()), diff --git a/adoptium-marketplace-utils/src/test/kotlin/ExtractIbmReleases.kt b/adoptium-marketplace-utils/src/test/kotlin/ExtractIbmReleases.kt index fd125737..dbfdbfba 100644 --- a/adoptium-marketplace-utils/src/test/kotlin/ExtractIbmReleases.kt +++ b/adoptium-marketplace-utils/src/test/kotlin/ExtractIbmReleases.kt @@ -1,18 +1,5 @@ -import com.fasterxml.jackson.module.kotlin.readValue import net.adoptium.api.v3.models.Release -import net.adoptium.marketplace.schema.Architecture -import net.adoptium.marketplace.schema.Binary -import net.adoptium.marketplace.schema.CLib -import net.adoptium.marketplace.schema.Distribution -import net.adoptium.marketplace.schema.ImageType -import net.adoptium.marketplace.schema.Installer -import net.adoptium.marketplace.schema.JvmImpl -import net.adoptium.marketplace.schema.OpenjdkVersionData -import net.adoptium.marketplace.schema.OperatingSystem -import net.adoptium.marketplace.schema.Package -import net.adoptium.marketplace.schema.ReleaseList -import net.adoptium.marketplace.schema.SourcePackage -import net.adoptium.marketplace.schema.Vendor +import net.adoptium.marketplace.schema.* import org.junit.jupiter.api.Test import java.util.* @@ -28,13 +15,26 @@ class ExtractIbmReleases { ExtractReleases().buildRepo( VERSIONS, { version -> "https://ibm.com/semeru-runtimes/api/v3/assets/feature_releases/${version}/ga?vendor=ibm_ce&page_size=100" }, - { release -> toMarketplaceRelease(release, toMarketplaceBinaries(release)) }, + this::convertToMarketplaceSchema, "/tmp/ibmRepo", false ) } - private fun toMarketplaceRelease(release: Release, binaries: List): net.adoptium.marketplace.schema.Release { + private fun convertToMarketplaceSchema( + releases: List + ): List { + return releases + .map { release -> + ReleaseList(listOf(toMarketplaceRelease(release, toMarketplaceBinaries(release)))) + } + .toList() + } + + private fun toMarketplaceRelease( + release: Release, + binaries: List + ): net.adoptium.marketplace.schema.Release { return net.adoptium.marketplace.schema.Release( release.release_link, release.release_name, @@ -86,14 +86,15 @@ class ExtractIbmReleases { binary.`package`.signature_link ), if (binary.installer != null) { - listOf(Installer( - binary.installer!!.name, - binary.installer!!.link, - binary.installer!!.checksum, - binary.installer!!.checksum_link, - binary.installer!!.signature_link, - null - ) + listOf( + Installer( + binary.installer!!.name, + binary.installer!!.link, + binary.installer!!.checksum, + binary.installer!!.checksum_link, + binary.installer!!.signature_link, + null + ) ) } else null, Date.from(binary.updated_at.dateTime.toInstant()), diff --git a/adoptium-marketplace-utils/src/test/kotlin/ExtractReleases.kt b/adoptium-marketplace-utils/src/test/kotlin/ExtractReleases.kt index 94744314..e5580fc6 100644 --- a/adoptium-marketplace-utils/src/test/kotlin/ExtractReleases.kt +++ b/adoptium-marketplace-utils/src/test/kotlin/ExtractReleases.kt @@ -6,6 +6,7 @@ import net.adoptium.marketplace.client.MarketplaceMapper import net.adoptium.marketplace.schema.IndexFile import net.adoptium.marketplace.schema.ReleaseList import org.eclipse.jetty.client.HttpClient +import org.slf4j.LoggerFactory import java.io.File import java.io.FileWriter import java.nio.file.Path @@ -13,12 +14,18 @@ import java.nio.file.Paths class ExtractReleases { + companion object { + @JvmStatic + private val LOGGER = LoggerFactory.getLogger(this::class.java) + } + fun buildRepo( versions: List, apiUrl: (Int) -> String, - dataMapper: (releases: Release) -> net.adoptium.marketplace.schema.Release, + convertToMarketplaceSchema:(releases: List) -> List, outputDir: String, - signAssets: Boolean) { + signAssets: Boolean + ) { val httpClient = HttpClient() httpClient.isFollowRedirects = true httpClient.start() @@ -40,7 +47,7 @@ class ExtractReleases { val releases = getAdoptiumReleases(apiUrl, httpClient, version) // Represent Adoptium releases in Marketplace schema - val marketplaceReleases = convertToMarketplaceSchema(releases, dataMapper) + val marketplaceReleases = convertToMarketplaceSchema(releases) // Create index file i.e './8/index.json val indexFile = IndexFile( @@ -55,18 +62,26 @@ class ExtractReleases { } val indexfw = FileWriter(file) indexfw.use { - it.write(MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(indexFile)) + it.write( + MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter() + .writeValueAsString(indexFile) + ) } // Write all releases to file marketplaceReleases .forEach { release -> // write to file, i.e ./8/jdk8u302_b08.json - val fos = FileWriter(Paths.get(versionDir.absolutePath, toFileName(release.releases.first())).toFile()) + val fos = FileWriter( + Paths.get(versionDir.absolutePath, toFileName(release.releases.first())).toFile() + ) // Serialize object to file fos.use { - it.write(MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(release)) + it.write( + MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter() + .writeValueAsString(release) + ) } } } @@ -101,27 +116,23 @@ class ExtractReleases { val indexfw = FileWriter(Paths.get(dir.toFile().absolutePath, "index.json").toFile()) indexfw.use { - it.write(MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(indexFile)) + it.write( + MarketplaceMapper.repositoryObjectMapper.writerWithDefaultPrettyPrinter() + .writeValueAsString(indexFile) + ) } } - private fun convertToMarketplaceSchema(releases: List, dataMapper: (releases: Release) -> net.adoptium.marketplace.schema.Release): List { - val marketplaceReleases = releases - .map { release -> - ReleaseList(listOf(dataMapper(release))) - } - .toList() - return marketplaceReleases - } - private fun filterValidVersions(release: Release): Boolean { val validVersion = when (release.version_data.major) { 11 -> { VersionParser.parse("11.0.14.1+1") } + 17 -> { VersionParser.parse("17.0.2+8") } + else -> { VersionParser.parse("jdk8u322-b06") } @@ -140,7 +151,7 @@ class ExtractReleases { .map { release -> val filteredBinaries = release.binaries.filter { it.image_type == net.adoptium.api.v3.models.ImageType.jdk || - it.image_type == net.adoptium.api.v3.models.ImageType.jre + it.image_type == net.adoptium.api.v3.models.ImageType.jre } Release(release, filteredBinaries.toTypedArray()) diff --git a/api.adoptium.net b/api.adoptium.net index 24a736dd..52b895f9 160000 --- a/api.adoptium.net +++ b/api.adoptium.net @@ -1 +1 @@ -Subproject commit 24a736dde8cdda212ac66e17a1f49dc1d134b41d +Subproject commit 52b895f926f805b027cc3041b3ec0137dc1d1f6d diff --git a/pom.xml b/pom.xml index 5de91c82..0ca38b14 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 17 3.5.0 0.8.8 - 1.9.20-RC2 + 1.9.20 3.0.1-SNAPSHOT @@ -97,7 +97,7 @@ com.microsoft.azure applicationinsights-runtime-attach - 3.4.17 + 3.4.18 io.opentelemetry @@ -118,7 +118,7 @@ smallrye-open-api-maven-plugin io.smallrye - 3.6.2 + 3.7.0 org.jetbrains.kotlin