Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade moshi #883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.dokka) apply false
alias(libs.plugins.ktlint) apply false
alias(libs.plugins.plugin.publish) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.versions)
id 'java-gradle-plugin'
id 'java-library'
Expand Down
9 changes: 9 additions & 0 deletions gradle-versions-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.dokka)
alias(libs.plugins.ktlint)
alias(libs.plugins.plugin.publish)
alias(libs.plugins.ksp)
alias(libs.plugins.versions)
id 'maven-publish' // For publishing the plugin to mavenLocal()
id 'java-gradle-plugin'
Expand All @@ -26,6 +27,13 @@ tasks.register('createClasspathManifest') {
}
}

ktlint {
ignoreFailures = true
filter {
exclude("**/build/generated/**")
}
}

dependencies {
compileOnly gradleApi()

Expand All @@ -34,6 +42,7 @@ dependencies {
implementation libs.kotlin.stdlib
implementation libs.okhttp
implementation libs.moshi
ksp libs.moshi.codegen

testRuntimeOnly files(createClasspathManifest)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.benmanes.gradle.versions.reporter

import com.github.benmanes.gradle.versions.reporter.result.Result
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.gradle.api.Project
import java.io.OutputStream

Expand Down Expand Up @@ -34,7 +33,6 @@ class JsonReporter(
companion object {
private val moshi =
Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

/**
* A group of dependencies.
*
* @property count The number of dependencies in this group.
* @property dependencies The dependencies that belong to this group.
*/
@JsonClass(generateAdapter = true)
data class DependenciesGroup<T : Dependency>(
val count: Int,
val dependencies: MutableSet<T> = mutableSetOf(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

/**
* A project's dependency.
*/
@JsonClass(generateAdapter = true)
open class Dependency
@JvmOverloads
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class DependencyLatest(
override val group: String? = null,
override val name: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class DependencyOutdated(
override val group: String? = null,
override val name: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class DependencyUnresolved(
override val group: String? = null,
override val name: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.github.benmanes.gradle.versions.updates.gradle.GradleUpdateResults
import com.squareup.moshi.JsonClass

/**
* The result of a dependency update analysis.
Expand All @@ -14,6 +15,7 @@ import com.github.benmanes.gradle.versions.updates.gradle.GradleUpdateResults
* @property unresolved The unresolvable dependencies.
* @property gradle Gradle release channels and respective update availability.
*/
@JsonClass(generateAdapter = true)
class Result(
val count: Int,
val current: DependenciesGroup<Dependency>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.benmanes.gradle.versions.reporter.result

import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
class VersionAvailable
@JvmOverloads
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.benmanes.gradle.versions.updates.gradle

import com.squareup.moshi.JsonClass
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.Request
import org.gradle.util.GradleVersion
Expand Down Expand Up @@ -66,18 +66,20 @@ class GradleUpdateChecker(
* Class representing an available release. Holds the release version in the
* form of a [GradleVersion].
*/
class Available(val gradleVersion: GradleVersion) : ReleaseStatus()
@JsonClass(generateAdapter = true)
data class Available(val gradleVersion: GradleVersion) : ReleaseStatus()

/**
* Class representing a release channel without any releases. This may be the case with
* pre-release channels after an update has been released to general availability.
*/
object Unavailable : ReleaseStatus()
data object Unavailable : ReleaseStatus()

/**
* Class representing a failure during update checking.
*/
class Failure(val reason: String) : ReleaseStatus()
@JsonClass(generateAdapter = true)
data class Failure(val reason: String) : ReleaseStatus()
}

companion object {
Expand All @@ -94,12 +96,12 @@ class GradleUpdateChecker(
.build()
private val moshi =
Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()

/** Represents the XML from [gradleVersionsApiBaseUrl] */
private class VersionSite {
var version: String? = null
@JsonClass(generateAdapter = true)
internal class VersionSite {
val version: String? = null
}

private fun fetch(gradleVersionsApiBaseUrl: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.benmanes.gradle.versions.updates.gradle

import com.github.benmanes.gradle.versions.updates.gradle.GradleUpdateChecker.ReleaseStatus
import com.squareup.moshi.JsonClass
import org.gradle.util.GradleVersion

/**
* Holder class for gradle update results of a specific release channel (or the running version).
* Used for reporting & serialization to JSON/XML.
*/
@JsonClass(generateAdapter = true)
class GradleUpdateResult(
enabled: Boolean = false,
running: ReleaseStatus.Available? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.github.benmanes.gradle.versions.updates.gradle

import com.squareup.moshi.JsonClass

/**
* Wrapper holder class for gradle update results of all release channel (including the running
* version). Used for reporting & serialization to JSON/XML
*/
@JsonClass(generateAdapter = true)
class GradleUpdateResults(
val enabled: Boolean = false,
val running: GradleUpdateResult,
Expand Down
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[versions]
kotlin = "2.0.0"
moshi = "1.15.1"

[plugins]
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.1" }
ksp = { id = "com.google.devtools.ksp", version = "2.0.0-1.0.23" }
plugin-publish = { id = "com.gradle.plugin-publish", version = "1.2.1" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }

[libraries]
kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
moshi = { module = "com.squareup.moshi:moshi-kotlin", version = "1.12.0" }
moshi = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" }
spock = { module = "org.spockframework:spock-junit4", version = "2.4-M1-groovy-3.0" }
Loading