Skip to content

Commit

Permalink
Update Gradle versions plugin to 0.45.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Feb 16, 2023
1 parent d597235 commit c15c4a6
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.github.benmanes.gradle.versions.reporter.result.Dependency
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.MissingFieldException
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.SetSerializer
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
import kotlinx.serialization.descriptors.element
Expand All @@ -32,8 +31,6 @@ import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure
import java.util.SortedSet

@ExperimentalSerializationApi
@Serializer(forClass = DependenciesGroup::class)
class DependenciesGroupSerializer<E : Dependency>(
private val elementSerializer: KSerializer<E>
) : KSerializer<DependenciesGroup<E>> {
Expand Down Expand Up @@ -63,9 +60,12 @@ class DependenciesGroupSerializer<E : Dependency>(
.map { it.first }
.toList()
.takeIf { it.isNotEmpty() }
?.also { throw MissingFieldException(it, descriptor.serialName) }
?.also {
@OptIn(ExperimentalSerializationApi::class)
throw MissingFieldException(it, descriptor.serialName)
}

DependenciesGroup(count!!, dependencies)
DependenciesGroup(count!!, dependencies!!.toMutableSet())
}

override fun serialize(encoder: Encoder, value: DependenciesGroup<E>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.github.benmanes.gradle.versions.reporter.result.DependencyLatest
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.MissingFieldException
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.nullable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
Expand All @@ -31,14 +30,14 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure

@ExperimentalSerializationApi
@Serializer(forClass = DependencyLatest::class)
//@ExperimentalSerializationApi
object DependencyLatestSerializer : KSerializer<DependencyLatest> {
override val descriptor = buildClassSerialDescriptor("com.github.benmanes.gradle.versions.reporter.result.DependencyLatest") {
element<String>("group")
element<String>("name")
element<String>("version")
element<String?>("group")
element<String?>("name")
element<String?>("version")
element<String?>("projectUrl")
element<String?>("userReason")
element<String>("latest")
}

Expand All @@ -47,42 +46,47 @@ object DependencyLatestSerializer : KSerializer<DependencyLatest> {
var name: String? = null
var version: String? = null
var projectUrl: String? = null
var userReason: String? = null
var latest: String? = null

while (true) {
@OptIn(ExperimentalSerializationApi::class)
when (val index = decodeElementIndex(descriptor)) {
DECODE_DONE -> break
0 -> group = decodeStringElement(descriptor, index)
1 -> name = decodeStringElement(descriptor, index)
2 -> version = decodeStringElement(descriptor, index)
0 -> group = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
1 -> name = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
2 -> version = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
3 -> projectUrl = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
4 -> latest = decodeStringElement(descriptor, index)
4 -> userReason = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
5 -> latest = decodeStringElement(descriptor, index)
else -> error("Unexpected index $index")
}
}

listOf(
"group" to group,
"name" to name,
"version" to version,
"latest" to latest
)
.filter { it.second == null }
.map { it.first }
.toList()
.takeIf { it.isNotEmpty() }
?.also { throw MissingFieldException(it, descriptor.serialName) }
?.also {
@OptIn(ExperimentalSerializationApi::class)
throw MissingFieldException(it, descriptor.serialName)
}

DependencyLatest(group, name, version, projectUrl, latest)
DependencyLatest(group, name, version, projectUrl, userReason, latest!!)
}

override fun serialize(encoder: Encoder, value: DependencyLatest) {
@OptIn(ExperimentalSerializationApi::class)
encoder.encodeStructure(descriptor) {
encodeStringElement(descriptor, 0, value.group)
encodeStringElement(descriptor, 1, value.name)
encodeStringElement(descriptor, 2, value.version)
encodeNullableSerializableElement(descriptor, 0, String.serializer(), value.group)
encodeNullableSerializableElement(descriptor, 1, String.serializer(), value.name)
encodeNullableSerializableElement(descriptor, 2, String.serializer(), value.version)
encodeNullableSerializableElement(descriptor, 3, String.serializer(), value.projectUrl)
encodeStringElement(descriptor, 4, value.latest)
encodeNullableSerializableElement(descriptor, 4, String.serializer(), value.userReason)
encodeStringElement(descriptor, 5, value.latest)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.github.benmanes.gradle.versions.reporter.result.VersionAvailable
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.MissingFieldException
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.nullable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
Expand All @@ -32,14 +31,13 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure

@ExperimentalSerializationApi
@Serializer(forClass = DependencyOutdated::class)
object DependencyOutdatedSerializer : KSerializer<DependencyOutdated> {
override val descriptor = buildClassSerialDescriptor("com.github.benmanes.gradle.versions.reporter.result.DependencyOutdated") {
element<String>("group")
element<String>("name")
element<String>("version")
element<String?>("group")
element<String?>("name")
element<String?>("version")
element<String?>("projectUrl")
element<String?>("userReason")
element("available", VersionAvailableSerializer.descriptor)
}

Expand All @@ -48,42 +46,47 @@ object DependencyOutdatedSerializer : KSerializer<DependencyOutdated> {
var name: String? = null
var version: String? = null
var projectUrl: String? = null
var userReason: String? = null
var available: VersionAvailable? = null

while (true) {
@OptIn(ExperimentalSerializationApi::class)
when (val index = decodeElementIndex(descriptor)) {
DECODE_DONE -> break
0 -> group = decodeStringElement(descriptor, index)
1 -> name = decodeStringElement(descriptor, index)
2 -> version = decodeStringElement(descriptor, index)
0 -> group = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
1 -> name = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
2 -> version = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
3 -> projectUrl = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
4 -> available = decodeSerializableElement(descriptor, index, VersionAvailableSerializer)
4 -> userReason = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
5 -> available = decodeSerializableElement(descriptor, index, VersionAvailableSerializer)
else -> error("Unexpected index $index")
}
}

listOf(
"group" to group,
"name" to name,
"version" to version,
"available" to available
)
.filter { it.second == null }
.map { it.first }
.toList()
.takeIf { it.isNotEmpty() }
?.also { throw MissingFieldException(it, descriptor.serialName) }
?.also {
@OptIn(ExperimentalSerializationApi::class)
throw MissingFieldException(it, descriptor.serialName)
}

DependencyOutdated(group, name, version, projectUrl, available)
DependencyOutdated(group, name, version, projectUrl, userReason, available!!)
}

override fun serialize(encoder: Encoder, value: DependencyOutdated) {
@OptIn(ExperimentalSerializationApi::class)
encoder.encodeStructure(descriptor) {
encodeStringElement(descriptor, 0, value.group)
encodeStringElement(descriptor, 1, value.name)
encodeStringElement(descriptor, 2, value.version)
encodeNullableSerializableElement(descriptor, 0, String.serializer(), value.group)
encodeNullableSerializableElement(descriptor, 1, String.serializer(), value.name)
encodeNullableSerializableElement(descriptor, 2, String.serializer(), value.version)
encodeNullableSerializableElement(descriptor, 3, String.serializer(), value.projectUrl)
encodeSerializableElement(descriptor, 4, VersionAvailableSerializer, value.available)
encodeNullableSerializableElement(descriptor, 4, String.serializer(), value.userReason)
encodeSerializableElement(descriptor, 5, VersionAvailableSerializer, value.available)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package net.kautler.dao.result
import com.github.benmanes.gradle.versions.reporter.result.Dependency
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.MissingFieldException
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.nullable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
Expand All @@ -31,53 +29,46 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure

@ExperimentalSerializationApi
@Serializer(forClass = Dependency::class)
object DependencySerializer : KSerializer<Dependency> {
override val descriptor = buildClassSerialDescriptor("com.github.benmanes.gradle.versions.reporter.result.Dependency") {
element<String>("group")
element<String>("name")
element<String>("version")
element<String?>("group")
element<String?>("name")
element<String?>("version")
element<String?>("projectUrl")
element<String?>("userReason")
}

override fun deserialize(decoder: Decoder) = decoder.decodeStructure(descriptor) {
var group: String? = null
var name: String? = null
var version: String? = null
var projectUrl: String? = null
var userReason: String? = null

while (true) {
@OptIn(ExperimentalSerializationApi::class)
when (val index = decodeElementIndex(descriptor)) {
DECODE_DONE -> break
0 -> group = decodeStringElement(descriptor, index)
1 -> name = decodeStringElement(descriptor, index)
2 -> version = decodeStringElement(descriptor, index)
0 -> group = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
1 -> name = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
2 -> version = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
3 -> projectUrl = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
4 -> userReason = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
else -> error("Unexpected index $index")
}
}

listOf(
"group" to group,
"name" to name,
"version" to version
)
.filter { it.second == null }
.map { it.first }
.toList()
.takeIf { it.isNotEmpty() }
?.also { throw MissingFieldException(it, descriptor.serialName) }

Dependency(group, name, version, projectUrl)
Dependency(group, name, version, projectUrl, userReason)
}

override fun serialize(encoder: Encoder, value: Dependency) {
@OptIn(ExperimentalSerializationApi::class)
encoder.encodeStructure(descriptor) {
encodeStringElement(descriptor, 0, value.group)
encodeStringElement(descriptor, 1, value.name)
encodeStringElement(descriptor, 2, value.version)
encodeNullableSerializableElement(descriptor, 0, String.serializer(), value.group)
encodeNullableSerializableElement(descriptor, 1, String.serializer(), value.name)
encodeNullableSerializableElement(descriptor, 2, String.serializer(), value.version)
encodeNullableSerializableElement(descriptor, 3, String.serializer(), value.projectUrl)
encodeNullableSerializableElement(descriptor, 4, String.serializer(), value.userReason)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.github.benmanes.gradle.versions.reporter.result.DependencyUnresolved
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.MissingFieldException
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.nullable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
Expand All @@ -31,14 +30,13 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure

@ExperimentalSerializationApi
@Serializer(forClass = DependencyUnresolved::class)
object DependencyUnresolvedSerializer : KSerializer<DependencyUnresolved> {
override val descriptor = buildClassSerialDescriptor("com.github.benmanes.gradle.versions.reporter.result.DependencyUnresolved") {
element<String>("group")
element<String>("name")
element<String>("version")
element<String?>("group")
element<String?>("name")
element<String?>("version")
element<String?>("projectUrl")
element<String?>("userReason")
element<String>("reason")
}

Expand All @@ -47,42 +45,47 @@ object DependencyUnresolvedSerializer : KSerializer<DependencyUnresolved> {
var name: String? = null
var version: String? = null
var projectUrl: String? = null
var userReason: String? = null
var reason: String? = null

while (true) {
@OptIn(ExperimentalSerializationApi::class)
when (val index = decodeElementIndex(descriptor)) {
DECODE_DONE -> break
0 -> group = decodeStringElement(descriptor, index)
1 -> name = decodeStringElement(descriptor, index)
2 -> version = decodeStringElement(descriptor, index)
0 -> group = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
1 -> name = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
2 -> version = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
3 -> projectUrl = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
4 -> reason = decodeStringElement(descriptor, index)
4 -> userReason = decodeNullableSerializableElement(descriptor, index, String.serializer().nullable)
5 -> reason = decodeStringElement(descriptor, index)
else -> error("Unexpected index $index")
}
}

listOf(
"group" to group,
"name" to name,
"version" to version,
"reason" to reason
)
.filter { it.second == null }
.map { it.first }
.toList()
.takeIf { it.isNotEmpty() }
?.also { throw MissingFieldException(it, descriptor.serialName) }
?.also {
@OptIn(ExperimentalSerializationApi::class)
throw MissingFieldException(it, descriptor.serialName)
}

DependencyUnresolved(group, name, version, projectUrl, reason)
DependencyUnresolved(group, name, version, projectUrl, userReason, reason!!)
}

override fun serialize(encoder: Encoder, value: DependencyUnresolved) {
@OptIn(ExperimentalSerializationApi::class)
encoder.encodeStructure(descriptor) {
encodeStringElement(descriptor, 0, value.group)
encodeStringElement(descriptor, 1, value.name)
encodeStringElement(descriptor, 2, value.version)
encodeNullableSerializableElement(descriptor, 0, String.serializer(), value.group)
encodeNullableSerializableElement(descriptor, 1, String.serializer(), value.name)
encodeNullableSerializableElement(descriptor, 2, String.serializer(), value.version)
encodeNullableSerializableElement(descriptor, 3, String.serializer(), value.projectUrl)
encodeStringElement(descriptor, 4, value.reason)
encodeNullableSerializableElement(descriptor, 4, String.serializer(), value.userReason)
encodeStringElement(descriptor, 5, value.reason)
}
}
}
Loading

0 comments on commit c15c4a6

Please sign in to comment.