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

Update dependencies and linting changes #264

Merged
Merged
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> a libp2p implementation for the JVM, written in Kotlin 🔥

**⚠️ This is heavy work in progress! ⚠**
**⚠️ This is heavy work in progress! ⚠**

## Roadmap

Expand Down Expand Up @@ -60,9 +60,8 @@ etc. and other subsystems or concepts that are internal to implementations and
do not impact the ability to hold communications with other libp2p processes.

## Adding as a dependency to your project:
![Maven version](https://img.shields.io/maven-metadata/v?label=jvm-libp2p-minimal&metadataUrl=https%3A%2F%2Fdl.cloudsmith.io%2Fpublic%2Flibp2p%2Fjvm-libp2p%2Fmaven%2Fio%2Flibp2p%2Fjvm-libp2p-minimal%2Fmaven-metadata.xml)
[![Latest version of 'jvm-libp2p-minimal' @ Cloudsmith](https://api-prd.cloudsmith.io/v1/badges/version/libp2p/jvm-libp2p/maven/jvm-libp2p-minimal/latest/a=noarch;xg=io.libp2p/?render=true&show_latest=true)](https://cloudsmith.io/~libp2p/repos/jvm-libp2p/packages/detail/maven/jvm-libp2p-minimal/latest/a=noarch;xg=io.libp2p/)

[![Hosted By: Cloudsmith](https://img.shields.io/badge/OSS%20hosting%20by-cloudsmith-blue?logo=cloudsmith&style=flat-square)](https://cloudsmith.com)
Hosting of artefacts is graciously provided by [Cloudsmith](https://cloudsmith.com).

### Using Gradle
Expand Down
91 changes: 40 additions & 51 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.nio.file.Files
import java.nio.file.Paths

// To publish the release artifact to CloudSmith repo run the following :
// ./gradlew publish -PcloudsmithUser=<user> -PcloudsmithApiKey=<api-key>
Expand All @@ -13,92 +10,84 @@ version = "develop"
description = "a minimal implementation of libp2p for the jvm"

plugins {
kotlin("jvm").version("1.6.10")
kotlin("jvm").version("1.6.21")

id("com.github.ben-manes.versions").version("0.44.0")
id("com.google.protobuf").version("0.9.1")
id("com.google.protobuf").version("0.9.2")
id("idea")
id("io.gitlab.arturbosch.detekt").version("1.20.0-RC1")
id("io.gitlab.arturbosch.detekt").version("1.22.0")
id("java")
id("maven-publish")
id("org.jetbrains.dokka").version("1.6.10")
id("org.jmailen.kotlinter").version("3.8.0")
id("org.jetbrains.dokka").version("1.7.20")
id("org.jmailen.kotlinter").version("3.10.0")
id("java-test-fixtures")
id("me.champeau.jmh").version("0.6.8")
}

repositories {
mavenCentral()
maven("https://artifacts.consensys.net/public/maven/maven/")
}


val guavaVersion = "31.1-jre"
val bouncyCastleVersion = "1.70"
val log4j2Version = "2.19.0"

sourceSets.create("jmh") {
compileClasspath += sourceSets["main"].runtimeClasspath
compileClasspath += sourceSets["testFixtures"].runtimeClasspath
runtimeClasspath += sourceSets["main"].runtimeClasspath
runtimeClasspath += sourceSets["testFixtures"].runtimeClasspath
}
val junitVersion = "5.9.2"
val mockitoVersion = "5.1.1"
val jmhVersion = "1.36"

dependencies {
api("io.netty:netty-all:4.1.69.Final")
api("com.google.protobuf:protobuf-java:3.21.9")
api("io.netty:netty-all:4.1.87.Final")
api("com.google.protobuf:protobuf-java:3.21.12")

implementation(kotlin("stdlib-jdk8"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe no need to revert this lib back to stdlib-jdk8 as we switched to Java-11 target

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I read from Kotlin 1.8 stdlib-jdk8 is merged into kotlin-stdlib . Otherwise, it is preferred to use stdlib-jdk8 to make use of the jdk8 extensions.

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("tech.pegasys:noise-java:22.1.0")

implementation("com.google.guava:guava:31.1-jre")
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("com.google.guava:guava:$guavaVersion")
implementation("org.bouncycastle:bcprov-jdk15on:$bouncyCastleVersion")
implementation("org.bouncycastle:bcpkix-jdk15on:$bouncyCastleVersion")
implementation("commons-codec:commons-codec:1.15")

implementation("org.apache.logging.log4j:log4j-api:${log4j2Version}")
implementation("org.apache.logging.log4j:log4j-core:${log4j2Version}")
implementation("org.apache.logging.log4j:log4j-api:$log4j2Version")
implementation("org.apache.logging.log4j:log4j-core:$log4j2Version")
implementation("javax.xml.bind:jaxb-api:2.3.1")

testFixturesImplementation("org.apache.logging.log4j:log4j-api:${log4j2Version}")
testFixturesImplementation("com.google.guava:guava:31.0.1-jre")
testFixturesImplementation("org.apache.logging.log4j:log4j-api:$log4j2Version")
testFixturesImplementation("com.google.guava:guava:$guavaVersion")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.1")
testImplementation("io.mockk:mockk:1.12.2")
testRuntimeOnly("org.mockito:mockito-core:4.8.1")
testImplementation("org.mockito:mockito-junit-jupiter:4.8.1")
testImplementation("org.assertj:assertj-core:3.23.1")
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("io.mockk:mockk:1.13.3")
testRuntimeOnly("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")
testImplementation("org.assertj:assertj-core:3.24.2")

"jmhImplementation"("org.openjdk.jmh:jmh-core:1.35")
"jmhAnnotationProcessor"("org.openjdk.jmh:jmh-generator-annprocess:1.35")
}

task<JavaExec>("jmh") {
mainClass.set("org.openjdk.jmh.Main")
classpath = sourceSets["jmh"].compileClasspath + sourceSets["jmh"].runtimeClasspath
jmhImplementation("org.openjdk.jmh:jmh-core:$jmhVersion")
jmhAnnotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:$jmhVersion")
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.21.9"
artifact = "com.google.protobuf:protoc:3.21.12"
}

tasks.get("clean").doFirst({ delete(generatedFilesBaseDir) })
tasks["clean"].doFirst { delete(generatedFilesBaseDir) }

idea {
module {
sourceDirs.add(file("${generatedFilesBaseDir}/main/java"))
sourceDirs.add(file("$generatedFilesBaseDir/main/java"))
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "11"
kotlinOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
}
Expand All @@ -111,7 +100,7 @@ tasks.withType<Copy> {
tasks.test {
description = "Runs the unit tests."

useJUnitPlatform{
useJUnitPlatform {
excludeTags("interop")
}

Expand All @@ -130,19 +119,19 @@ tasks.test {
}

kotlinter {
disabledRules = arrayOf("no-wildcard-imports")
disabledRules = arrayOf("no-wildcard-imports", "enum-entry-name-case")
}

val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("dokka"))
dokkaSourceSets {
configureEach {
jdkVersion.set(8)
jdkVersion.set(11)
reportUndocumented.set(false)
externalDocumentationLink {
url.set(URL("https://netty.io/4.1/api/"))
Expand Down Expand Up @@ -192,4 +181,4 @@ compileKotlin.kotlinOptions {
detekt {
config = files("$projectDir/detekt/config.yml")
buildUponDefaultConfig = true
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions 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
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/libp2p/etc/types/UvarintTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UvarintTest {
fun testDecodeTooManyBytes() {
// Helper function for creating uvarint buffer.
fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) {
pos ->
pos ->
ints[pos].toByte()
}

Expand Down