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

Bump outdated deps #119

Merged
merged 32 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
de47374
Bump Kotlin to latest
lealobanov Oct 10, 2024
016aca2
Bump Kotlin to latest
lealobanov Oct 10, 2024
06f8682
Bump Kotlin to latest
lealobanov Oct 10, 2024
63382da
Updating deprecated DSL
lealobanov Oct 10, 2024
2d058b1
Updating deprecated DSL
lealobanov Oct 10, 2024
15b2663
Updating deprecated DSL
lealobanov Oct 10, 2024
266f6af
Updating deprecated DSL
lealobanov Oct 10, 2024
a75c4db
Updating deprecated DSL
lealobanov Oct 10, 2024
1163a7b
Updating deprecated DSL
lealobanov Oct 10, 2024
14fa086
Updating deprecated DSL
lealobanov Oct 10, 2024
8efa110
Updating deprecated DSL
lealobanov Oct 10, 2024
8f9ca9e
Bump remaining deps
lealobanov Oct 11, 2024
10823ed
Bump remaining deps
lealobanov Oct 11, 2024
c1aeb8a
Debugging Kotlin issues
lealobanov Oct 11, 2024
47babf5
Debugging Kotlin issues
lealobanov Oct 11, 2024
d76b5ef
Debugging Kotlin issues
lealobanov Oct 11, 2024
9ceda20
Lint
lealobanov Oct 12, 2024
fd60e23
Lint
lealobanov Oct 12, 2024
0ab4de3
Lint
lealobanov Oct 12, 2024
27d4fc1
Lint
lealobanov Oct 12, 2024
cb97b64
Lint
lealobanov Oct 12, 2024
cdbf05c
Lint
lealobanov Oct 12, 2024
02f3df0
Lint
lealobanov Oct 12, 2024
95c53b6
Lint
lealobanov Oct 13, 2024
feb8b85
Lint
lealobanov Oct 13, 2024
e7933b5
Re-enable dokka
lealobanov Oct 13, 2024
69cec7d
Remove unused ktlint disabled config
lealobanov Oct 13, 2024
45c2b92
Update deps
lealobanov Oct 13, 2024
a95aef9
Update deps
lealobanov Oct 13, 2024
548e49b
Update deprecated coroutines methods
lealobanov Oct 13, 2024
a8329ee
Debugging failing coroutines tests
lealobanov Oct 13, 2024
efee6c3
Fix tests
lealobanov Oct 14, 2024
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
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ ktlint_standard_multiline-expression-wrapping= disabled
ktlint_standard_string-template-indent= disabled
ktlint_standard_enum-entry-name-case = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_spacing-between-declarations-with-annotations = disabled
ktlint_standard_if-else-wrapping = disabled
ktlint_standard_argument-list-wrapping = disabled
ktlint_standard_value-argument-comment = disabled
ktlint_standard_modifier-list-spacing = disabled
ktlint_standard_annotation-spacing = disabled

# Defines the imports layout. The layout can be composed by the following symbols:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-examples-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v2
with:
java-version: '21'
java-version: '21.0.1'
java-package: jdk
distribution: 'adopt'
distribution: 'temurin'
architecture: 'x64'

- name: Install flow emulator
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-sdk-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v2
with:
java-version: '21'
java-version: '21.0.1'
java-package: jdk
distribution: 'adopt'
distribution: 'temurin'
architecture: 'x64'

- name: Install flow emulator
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
Expand Down
32 changes: 20 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// Configuration variables
Expand All @@ -11,9 +12,9 @@ fun getProp(name: String, defaultValue: String? = null): String? {
}

plugins {
kotlin("jvm") version "1.9.22" apply false
kotlin("jvm") version "2.0.21" apply false
id("org.jetbrains.dokka") version "1.9.10" apply false
id("org.jmailen.kotlinter") version "4.2.0" apply false
id("org.jmailen.kotlinter") version "4.4.1" apply false
id("kotlinx-serialization") version "1.8.0" apply false
id("com.vanniktech.maven.publish") version "0.28.0" apply false
}
Expand All @@ -24,7 +25,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21")
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove Redundant buildscript Block

Since the Kotlin Gradle plugin is already specified in the plugins block with the updated version, the buildscript block containing the classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21") dependency is redundant. Removing it can simplify your build script.

Apply this diff to remove the redundant buildscript block:

 buildscript {
     repositories {
         google()
         mavenCentral()
     }
     dependencies {
-        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21")
     }
 }

Committable suggestion was skipped due to low confidence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lealobanov, sure, please let me know if you have any questions or need further assistance.

}
}

Expand All @@ -51,23 +52,30 @@ subprojects {
else -> defaultVersion
}

val intTestImplementation: Configuration by configurations.creating {
extendsFrom(configurations["implementation"])
}

val intTestRuntimeOnly: Configuration by configurations.creating {
extendsFrom(configurations["runtimeOnly"])
}

Comment on lines +55 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Integrate New Integration Test Configurations

You've added intTestImplementation and intTestRuntimeOnly configurations extending from implementation and runtimeOnly. Ensure that these configurations are properly utilized by defining the corresponding source sets and tasks for integration tests. This will enable the project to compile and run integration tests separately from unit tests.

Consider adding the following to define the integration test source set and tasks:

sourceSets {
    val intTest by creating {
        compileClasspath += sourceSets.main.get().output + configurations.intTestImplementation
        runtimeClasspath += output + compileClasspath + configurations.intTestRuntimeOnly
    }
}

tasks.register<Test>("intTest") {
    description = "Runs the integration tests."
    group = "verification"
    testClassesDirs = sourceSets["intTest"].output.classesDirs
    classpath = sourceSets["intTest"].runtimeClasspath
    shouldRunAfter("test")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
freeCompilerArgs = listOf("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
}
}

dependencies {
"api"("org.jetbrains.kotlin:kotlin-reflect:1.9.22")
"dokkaHtmlPlugin"("org.jetbrains.dokka:kotlin-as-java-plugin:1.9.10")
"api"("org.jetbrains.kotlin:kotlin-reflect:2.0.21")
//dokkaHtmlPlugin"("org.jetbrains.dokka:kotlin-as-java-plugin:2.0.0-Beta")
}

tasks.named<KotlinCompile>("compileTestKotlin") {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
freeCompilerArgs = listOf("-Xjvm-default=all", "-opt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview")
allWarningsAsErrors = false
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
}
}

Expand Down
43 changes: 20 additions & 23 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
java
Expand All @@ -19,9 +20,9 @@ tasks.withType<JavaCompile> {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
freeCompilerArgs = listOf("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
}
}

Expand All @@ -34,37 +35,33 @@ repositories {

dependencies {
implementation(project(":sdk"))
testFixturesImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
testFixturesImplementation("org.mockito:mockito-core:3.12.4")
testFixturesImplementation("org.mockito:mockito-inline:3.11.2")

testImplementation("org.junit.jupiter:junit-jupiter:5.11.2")
testImplementation("org.mockito:mockito-core:5.14.1")
testImplementation("org.mockito:mockito-inline:5.2.0")

testFixturesImplementation(project(":sdk"))
testFixturesImplementation("org.junit.jupiter:junit-jupiter:5.11.2")
testFixturesImplementation("org.mockito:mockito-core:5.14.1")
testFixturesImplementation("org.mockito:mockito-inline:5.2.0")

intTestImplementation("org.junit.jupiter:junit-jupiter:5.11.2")
intTestImplementation("org.assertj:assertj-core:3.26.3")
intTestRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.test {
// Use junit platform for unit tests.
useJUnitPlatform()
}

sourceSets {
create("intTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
kotlin.srcDirs("src/intTest", "src/testFixtures")
compileClasspath += sourceSets["main"].output + sourceSets["testFixtures"].output
runtimeClasspath += sourceSets["main"].output + sourceSets["testFixtures"].output
kotlin.srcDirs("src/intTest/kotlin")
}
}

val intTestImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
val intTestRuntimeOnly by configurations.getting

configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())

dependencies {
intTestImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
intTestImplementation("org.assertj:assertj-core:3.25.1")
intTestRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

val integrationTest = task<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ object FlowTestUtil {
val contractList = contracts.toList()
val contractArgs = contractList
.mapIndexed { i, c ->
c.args.entries.sortedBy { it.key }
c.args.entries
.sortedBy { it.key }
.joinToString(separator = "") { ", contract${i}_${it.key}: ${it.value.type}" }
}
.joinToString(separator = "")
}.joinToString(separator = "")
val contractAddArgs = contractList
.mapIndexed { i, c ->
c.args.entries.sortedBy { it.key }
c.args.entries
.sortedBy { it.key }
.joinToString(separator = "") { ", ${it.key}: contract${i}_${it.key}" }
}
.toList()
}.toList()
val contractAdds = List(contractList.size) { i ->
"""
signer.contracts.add(
Expand Down Expand Up @@ -84,22 +84,23 @@ object FlowTestUtil {
balance: BigDecimal = BigDecimal(0.01)
): FlowAccessApi.AccessApiCallResponse<FlowAddress> {
val loadedScript = String(loadScript("cadence/test_utils_create_account.cdc"), StandardCharsets.UTF_8)
val transactionResult = api.simpleFlowTransaction(
address = serviceAccount.flowAddress,
signer = serviceAccount.signer,
keyIndex = serviceAccount.keyIndex
) {
script {
loadedScript
}
gasLimit(5000)
arguments {
arg { ufix64(balance) }
arg { string(publicKey) }
arg { uint8(signAlgo.index) }
arg { uint8(hashAlgo.index) }
}
}.sendAndWaitForSeal()
val transactionResult = api
.simpleFlowTransaction(
address = serviceAccount.flowAddress,
signer = serviceAccount.signer,
keyIndex = serviceAccount.keyIndex
) {
script {
loadedScript
}
gasLimit(5000)
arguments {
arg { ufix64(balance) }
arg { string(publicKey) }
arg { uint8(signAlgo.index) }
arg { uint8(hashAlgo.index) }
}
}.sendAndWaitForSeal()

return when (transactionResult) {
is FlowAccessApi.AccessApiCallResponse.Success -> {
Expand All @@ -114,6 +115,7 @@ object FlowTestUtil {

FlowAccessApi.AccessApiCallResponse.Success(FlowAddress(address))
}

is FlowAccessApi.AccessApiCallResponse.Error -> FlowAccessApi.AccessApiCallResponse.Error("Failed to create account: ${transactionResult.message}", transactionResult.throwable)
}
}
Expand Down Expand Up @@ -202,8 +204,7 @@ object FlowTestUtil {
(
listOf("${System.getProperty("user.home")}/.local/bin", "/usr/local/bin", "/usr/bin", "/bin")
+ (System.getenv()["PATH"]?.split(File.pathSeparator) ?: emptyList())
)
.map { File(it, "flow") }
).map { File(it, "flow") }
.find { it.exists() }
?: throw IOException("flow command not found")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
Copy link
Collaborator Author

@lealobanov lealobanov Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downgraded to 8.8 as 8.9 is not officially supported by Kotlin 2.0 (or versions <2)

networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
13 changes: 7 additions & 6 deletions java-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
application
kotlin("jvm") version "1.9.22"
kotlin("jvm") version "2.0.21"
}

// Helper function to get properties
Expand All @@ -19,9 +20,9 @@ tasks.withType<JavaCompile> {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
freeCompilerArgs = listOf("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
}
}

Expand All @@ -41,8 +42,8 @@ dependencies {

testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.2")
}

application {
Expand Down
14 changes: 6 additions & 8 deletions kotlin-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -19,9 +20,9 @@ tasks.withType<JavaCompile> {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
freeCompilerArgs = listOf("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
}
}

Expand All @@ -33,22 +34,19 @@ repositories {
}

dependencies {
// Use JUnit Jupiter Engine for testing.
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.2")

implementation(project(":sdk"))
implementation(project(":common"))
testImplementation(testFixtures(project(":common")))
}

application {
// Define the main class for the application.
mainClass.set("org.onflow.examples.kotlin.AccessAPIConnector")
}

tasks.test {
// Use junit platform for unit tests.
useJUnitPlatform()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ object ExamplesUtils {
return resource.use { it.readAllBytes() }
}

fun loadScriptContent(path: String): String {
return String(loadScript(path), StandardCharsets.UTF_8)
}
fun loadScriptContent(path: String): String =
String(loadScript(path), StandardCharsets.UTF_8)

fun ByteArray.toHexString() = joinToString("") { "%02x".format(it) }

fun ByteArray.toUnsignedByteArray(): ByteArray {
return this.map { (it.toInt() and 0xFF).toByte() }.toByteArray()
}
fun ByteArray.toUnsignedByteArray(): ByteArray =
this.map { (it.toInt() and 0xFF).toByte() }.toByteArray()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ internal class DeployContractExample(
val payerAccountKey = connector.getAccountKey(payerAddress, 0)
val signer = Crypto.getSigner(privateKey, payerAccountKey.hashAlgo)

val contractCode = ExamplesUtils.loadScriptContent(scriptName)
val contractCode = ExamplesUtils
.loadScriptContent(scriptName)
.replace("\"", "\\\"") // Escape double quotes
.replace("\n", "\\n") // Escape newlines

Expand Down
Loading
Loading