Skip to content

Commit

Permalink
Merge pull request #88 from adoptium/main
Browse files Browse the repository at this point in the history
merge main into production
  • Loading branch information
karianna authored Nov 6, 2023
2 parents 6c874d7 + 1d5c4fc commit c229ad7
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 72 deletions.
2 changes: 1 addition & 1 deletion adoptium-marketplace-server/adoptium-repo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>1.8.10</version>
<version>1.9.20</version>
</dependency>
</dependencies>
<configuration>
Expand Down
10 changes: 5 additions & 5 deletions adoptium-marketplace-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -162,7 +162,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.21.0</version>
<version>3.21.2</version>
<configuration>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
Expand Down Expand Up @@ -260,7 +260,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<executions>
<execution>
<id>download-licenses</id>
Expand Down Expand Up @@ -297,7 +297,7 @@
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.15.2</version>
<version>1.15.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -521,7 +521,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.21.0</version>
<version>3.21.2</version>
<configuration>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion adoptium-marketplace-staging-checker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<main.class>net.adoptium.marketplace.Main</main.class>
<quarkus.package.type>uber-jar</quarkus.package.type>
<quarkus.package.runner-suffix>-jar-with-dependencies</quarkus.package.runner-suffix>
<kotlin.version>1.9.20-RC2</kotlin.version>
<kotlin.version>1.9.20</kotlin.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion adoptium-marketplace-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>1.8.10</version>
<version>1.9.20</version>
</dependency>
</dependencies>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<Binary>): net.adoptium.marketplace.schema.Release {
private fun convertToMarketplaceSchema(
releases: List<Release>
): List<ReleaseList> {
val marketplaceReleases = releases
.map { release ->
ReleaseList(listOf(toMarketplaceRelease(release, toMarketplaceBinaries(release))))
}
.toList()
return mergeSimilarReleases(marketplaceReleases)
}

private fun mergeSimilarReleases(marketplaceReleases: List<ReleaseList>): List<ReleaseList> {
// 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<Binary>
): net.adoptium.marketplace.schema.Release {
return Release(
release.release_link,
release.release_name,
Expand Down Expand Up @@ -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()),
Expand Down
49 changes: 25 additions & 24 deletions adoptium-marketplace-utils/src/test/kotlin/ExtractIbmReleases.kt
Original file line number Diff line number Diff line change
@@ -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.*

Expand All @@ -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<Binary>): net.adoptium.marketplace.schema.Release {
private fun convertToMarketplaceSchema(
releases: List<Release>
): List<ReleaseList> {
return releases
.map { release ->
ReleaseList(listOf(toMarketplaceRelease(release, toMarketplaceBinaries(release))))
}
.toList()
}

private fun toMarketplaceRelease(
release: Release,
binaries: List<Binary>
): net.adoptium.marketplace.schema.Release {
return net.adoptium.marketplace.schema.Release(
release.release_link,
release.release_name,
Expand Down Expand Up @@ -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()),
Expand Down
45 changes: 28 additions & 17 deletions adoptium-marketplace-utils/src/test/kotlin/ExtractReleases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ 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
import java.nio.file.Paths

class ExtractReleases {

companion object {
@JvmStatic
private val LOGGER = LoggerFactory.getLogger(this::class.java)
}

fun buildRepo(
versions: List<Int>,
apiUrl: (Int) -> String,
dataMapper: (releases: Release) -> net.adoptium.marketplace.schema.Release,
convertToMarketplaceSchema:(releases: List<Release>) -> List<ReleaseList>,
outputDir: String,
signAssets: Boolean) {
signAssets: Boolean
) {
val httpClient = HttpClient()
httpClient.isFollowRedirects = true
httpClient.start()
Expand All @@ -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(
Expand All @@ -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)
)
}
}
}
Expand Down Expand Up @@ -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<Release>, dataMapper: (releases: Release) -> net.adoptium.marketplace.schema.Release): List<ReleaseList> {
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")
}
Expand All @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>
<quarkus.version>3.5.0</quarkus.version>
<jacoco.version>0.8.8</jacoco.version>
<kotlin.version>1.9.20-RC2</kotlin.version>
<kotlin.version>1.9.20</kotlin.version>
<adoptiumVersion>3.0.1-SNAPSHOT</adoptiumVersion>
</properties>

Expand Down Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-runtime-attach</artifactId>
<version>3.4.17</version>
<version>3.4.18</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
Expand All @@ -118,7 +118,7 @@
<plugin>
<artifactId>smallrye-open-api-maven-plugin</artifactId>
<groupId>io.smallrye</groupId>
<version>3.6.2</version>
<version>3.7.0</version>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down

0 comments on commit c229ad7

Please sign in to comment.