Skip to content

Commit

Permalink
updated to gradle 8.7 and removed Epirus
Browse files Browse the repository at this point in the history
Signed-off-by: Nischal Sharma <[email protected]>
  • Loading branch information
NickSneo committed Oct 3, 2024
1 parent a41613a commit f8994ad
Show file tree
Hide file tree
Showing 81 changed files with 619 additions and 375 deletions.
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,3 @@ docs/build
**/.project
**/.settings
**/bin

gradle/bintray
gradle/jacoco
gradle/java
gradle/javadoc
gradle/publish
gradle/repositories
gradle/spotless
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:4.0.0'
}
}

plugins {
id 'de.undercouch.download' version '4.1.1'
id 'com.diffplug.gradle.spotless' version '4.5.1'
id 'io.codearte.nexus-staging' version '0.22.0'
id 'de.undercouch.download' version '4.1.2'
id 'com.diffplug.spotless' version '6.25.0'
id 'io.codearte.nexus-staging' version '0.30.0'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
}

Expand All @@ -34,7 +33,6 @@ subprojects {

apply {
[
'bintray',
'publish',
'jacoco',
'java',
Expand Down Expand Up @@ -113,4 +111,8 @@ subprojects {
}

sourceCompatibility = 17

tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
}
}
10 changes: 8 additions & 2 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ dependencies {
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:${versions.jackson}"
}

// To publish in mavenLocal()
// tasks.withType(Sign)*.enabled = false
tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
}

tasks.named("spotlessKotlin") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("spotlessJava"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import javax.ws.rs.core.MediaType
* Client API exception containing error data.
*/
class ClientException internal constructor(
val error: ErrorResponse?
val error: ErrorResponse?,
) : RuntimeException(error?.title) {
companion object {

Expand All @@ -34,8 +34,8 @@ class ClientException internal constructor(
ErrorResponse(
title = exception.response.statusInfo.reasonPhrase,
requestUrl = exception.response.location?.toString(),
responseStatus = exception.response.status
)
responseStatus = exception.response.status,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import javax.ws.rs.sse.SseEventSource
*/
internal class ClientInvocationHandler(
private val target: WebTarget,
private val client: Any
private val client: Any,
) : InvocationHandler {

override fun invoke(proxy: Any, method: Method, args: Array<out Any>?): Any? {
Expand Down Expand Up @@ -71,7 +71,7 @@ internal class ClientInvocationHandler(
Proxy.newProxyInstance(
method.returnType.classLoader,
arrayOf(method.returnType),
ClientInvocationHandler(target, it)
ClientInvocationHandler(target, it),
)
} else {
it
Expand All @@ -91,7 +91,7 @@ internal class ClientInvocationHandler(
} else {
logger.error {
"Unexpected exception while invoking method $method: " +
(error.message ?: error::class.java.canonicalName)
(error.message ?: error::class.java.canonicalName)
}
error.targetException
}
Expand All @@ -101,7 +101,7 @@ internal class ClientInvocationHandler(
private fun handleClientError(error: ClientErrorException, method: Method): RuntimeException {
logger.error {
"Client exception while invoking method $method: " +
(error.message ?: error.response.statusInfo.reasonPhrase)
(error.message ?: error.response.statusInfo.reasonPhrase)
}
return ClientException.of(error)
}
Expand All @@ -115,9 +115,9 @@ internal class ClientInvocationHandler(
}

private fun Method.isEvent() = name == "onEvent" &&
parameterTypes.size == 1 &&
parameterTypes[0] == Consumer::class.java &&
returnType == CompletableFuture::class.java
parameterTypes.size == 1 &&
parameterTypes[0] == Consumer::class.java &&
returnType == CompletableFuture::class.java

private val Any.typeArguments: List<Class<*>>
get() {
Expand All @@ -128,13 +128,13 @@ internal class ClientInvocationHandler(
private class SseEventSourceResult<T>(
private val source: SseEventSource,
onEvent: Consumer<T>,
eventType: Class<T>
eventType: Class<T>,
) : CompletableFuture<Void>() {
init {
source.register(
{ onEvent.accept(it.readData(eventType)) },
{ completeExceptionally(it) },
{ complete(null) }
{ complete(null) },
)
whenComplete { _, _ ->
// Close the source gracefully by client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import java.util.logging.Logger
import javax.ws.rs.client.Client
import javax.ws.rs.client.ClientBuilder

class ClientService @JvmOverloads constructor (
class ClientService @JvmOverloads constructor(
val uri: String,
readTimeout: Int = DEFAULT_READ_TIMEOUT,
connectTimeout: Int = DEFAULT_CONNECT_TIMEOUT
connectTimeout: Int = DEFAULT_CONNECT_TIMEOUT,
) : AutoCloseable {

private val mapper = jacksonObjectMapper()
Expand Down
10 changes: 8 additions & 2 deletions codegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,11 @@ task copyIntegrationTestResources(type: Copy) {

integrationTest.dependsOn copyIntegrationTestResources, publishToMavenLocal

// To publish in mavenLocal()
// tasks.withType(Sign)*.enabled = false
tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
}

tasks.named("spotlessKotlin") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("spotlessJava"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ class GenerationTest {
"src",
"test",
"resources",
"contracts").toFile()
"contracts",
).toFile()

val generatorConfiguration = GeneratorConfiguration(
projectName = "testProject",
packageName = "com.test",
outputDir = tempFolder.canonicalPath,
contracts = loadContractConfigurations(listOf(contractsFolder)),
contextPath = "test"
contextPath = "test",
)
assertDoesNotThrow {
OpenApiGenerator(generatorConfiguration).generate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package org.web3j.openapi.codegen
import org.web3j.openapi.codegen.config.GeneratorConfiguration

abstract class AbstractGenerator(
val configuration: GeneratorConfiguration
val configuration: GeneratorConfiguration,
) {
protected val packageDir = configuration.packageName.split(".").joinToString("/")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.web3j.openapi.codegen.coregen.CoreGenerator
import org.web3j.openapi.codegen.servergen.ServerGenerator

class OpenApiGenerator(
private val configuration: GeneratorConfiguration
private val configuration: GeneratorConfiguration,
) {
fun generate() {
println("Generating Web3j-OpenAPI project ... Files written to ${configuration.outputDir}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ package org.web3j.openapi.codegen.common

class ContractResources(
val functionResources: List<FunctionResource>,
val eventResources: List<EventResource>
val eventResources: List<EventResource>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ data class EventResource(
val returnType: String = "",
val path: String = "",
val capitalizedName: String,
val decapitalizedName: String = capitalizedName.decapitalize()
val decapitalizedName: String = capitalizedName.decapitalize(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ data class FunctionResource(
val returnType: String,
val mediaType: String = "",
val path: String = "",
val operationTag: String = ""
val operationTag: String = "",
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ package org.web3j.openapi.codegen.common

data class ParameterDefinition(
val name: String,
val type: String
val type: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ package org.web3j.openapi.codegen.common
data class Tag(
val name: String,
val description: String,
var lastCharacter: String = ","
var lastCharacter: String = ",",
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ import java.io.File

data class ContractConfiguration(
val abiFile: File,
val contractDetails: ContractDetails
val contractDetails: ContractDetails,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.web3j.protocol.core.methods.response.AbiDefinition

data class ContractDetails(
val contractName: String,
var abiDefinitions: List<AbiDefinition>
var abiDefinitions: List<AbiDefinition>,
) {
init {
abiDefinitions.filter { it.isPayable }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class GeneratorConfiguration @JvmOverloads constructor(
val contextPath: String,
val version: String = VersionProvider.versionName,
val sanitizedProjectName: String = sanitizeName(projectName),
val withImplementations: Boolean = true
val withImplementations: Boolean = true,
) {
val rootProjectName = sanitizedProjectName.toLowerCase().replace(' ', '-')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object VersionProvider {
fun getVersion(): Array<String> {
return arrayOf(
"Version: $versionName",
"Build timestamp: ${buildTimestamp.let { timeFormatter.format(it) }}"
"Build timestamp: ${buildTimestamp.let { timeFormatter.format(it) }}",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import java.io.FileNotFoundException
import java.nio.file.Paths

class CoreGenerator(
configuration: GeneratorConfiguration
configuration: GeneratorConfiguration,
) : AbstractGenerator(
configuration
configuration,
) {
init {
context["contractsConfiguration"] = configuration.contracts
Expand All @@ -50,9 +50,9 @@ class CoreGenerator(
configuration.packageName,
folderPath = Paths.get(
folderPath,
it.contractDetails.lowerCaseContractName
it.contractDetails.lowerCaseContractName,
).toString(),
contractDetails = it.contractDetails
contractDetails = it.contractDetails,
).generate()
}
}
Expand All @@ -63,14 +63,14 @@ class CoreGenerator(
tags.add(
Tag(
"${it.contractDetails.capitalizedContractName} Methods",
"List ${it.contractDetails.capitalizedContractName} method's calls"
)
"List ${it.contractDetails.capitalizedContractName} method's calls",
),
)
tags.add(
Tag(
"${it.contractDetails.capitalizedContractName} Events",
"List ${it.contractDetails.capitalizedContractName} event's calls"
)
"List ${it.contractDetails.capitalizedContractName} event's calls",
),
)
}
return tags.also {
Expand All @@ -89,13 +89,13 @@ class CoreGenerator(
context = context,
outputDir = folderPath,
template = mustacheTemplate("core/src/ContractsApi.mustache"),
name = "${configuration.sanitizedProjectName.capitalize()}Api.kt"
name = "${configuration.sanitizedProjectName.capitalize()}Api.kt",
)
generateFromTemplate(
context = context,
outputDir = folderPath,
template = mustacheTemplate("core/src/GeneratedContractsResource.mustache"),
name = "${configuration.sanitizedProjectName.capitalize()}Resource.kt"
name = "${configuration.sanitizedProjectName.capitalize()}Resource.kt",
)
}

Expand Down
Loading

0 comments on commit f8994ad

Please sign in to comment.