Skip to content

Commit

Permalink
upgrade moshi
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows committed Jul 30, 2024
1 parent e0ed52e commit 2785736
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 13 deletions.
7 changes: 1 addition & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'org.jetbrains.dokka' version '1.8.10' apply false
id 'org.jlleitschuh.gradle.ktlint' version '12.1.1' apply false
id 'com.gradle.plugin-publish' version '0.21.0' apply false
id 'com.google.devtools.ksp' version '2.0.0-1.0.23' apply false
id 'java-gradle-plugin'
id 'java-library'
id 'groovy'
Expand All @@ -17,12 +18,6 @@ allprojects {
preferProjectModules()

enableDependencyVerification()

eachDependency { details ->
if (details.requested.group == "org.jetbrains.kotlin") {
details.useVersion("2.0.0")
}
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions gradle-versions-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.jetbrains.dokka'
id 'org.jlleitschuh.gradle.ktlint'
id 'com.gradle.plugin-publish'
id 'com.google.devtools.ksp'
id 'maven-publish' // For publishing the plugin to mavenLocal()
id 'java-gradle-plugin'
id 'java-library'
Expand All @@ -25,14 +26,21 @@ tasks.register('createClasspathManifest') {
}
}

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

dependencies {
compileOnly gradleApi()

implementation localGroovy()
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.0'
implementation 'org.jetbrains.kotlin:kotlin-reflect:2.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.12.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.15.1'
ksp 'com.squareup.moshi:moshi-kotlin-codegen:1.15.1'

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 @@ -61,22 +61,26 @@ class GradleUpdateChecker(
/**
* Abstract class representing the possible states of a release channel after an update check.
*/
@JsonClass(generateAdapter = true)
sealed class ReleaseStatus {
/**
* Class representing an available release. Holds the release version in the
* form of a [GradleVersion].
*/
@JsonClass(generateAdapter = true)
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.
*/
@JsonClass(generateAdapter = true)
object Unavailable : ReleaseStatus()

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

Expand All @@ -94,11 +98,11 @@ class GradleUpdateChecker(
.build()
private val moshi =
Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()

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

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

0 comments on commit 2785736

Please sign in to comment.