diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 503cd6e..ed44674 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -30,7 +30,6 @@ dependencies { compileOnly("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") implementation("org.apache.maven:maven-model:latest.release") implementation("org.apache.maven:maven-model-builder:latest.release") - implementation("com.squareup.okio:okio:latest.release") compatTestImplementation(embeddedKotlin("stdlib-jdk8")) compatTestImplementation(embeddedKotlin("test-junit5")) diff --git a/plugin/gradle/dependency-locks/compileClasspath.lockfile b/plugin/gradle/dependency-locks/compileClasspath.lockfile index 4dba989..9505418 100644 --- a/plugin/gradle/dependency-locks/compileClasspath.lockfile +++ b/plugin/gradle/dependency-locks/compileClasspath.lockfile @@ -1,7 +1,6 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.squareup.okio:okio:2.2.2 org.apache.commons:commons-lang3:3.8.1 org.apache.maven:maven-artifact:3.6.1 org.apache.maven:maven-builder-support:3.6.1 diff --git a/plugin/gradle/dependency-locks/runtimeClasspath.lockfile b/plugin/gradle/dependency-locks/runtimeClasspath.lockfile index 7351deb..771fe58 100644 --- a/plugin/gradle/dependency-locks/runtimeClasspath.lockfile +++ b/plugin/gradle/dependency-locks/runtimeClasspath.lockfile @@ -1,7 +1,6 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.squareup.okio:okio:2.2.2 org.apache.commons:commons-lang3:3.8.1 org.apache.maven:maven-artifact:3.6.1 org.apache.maven:maven-builder-support:3.6.1 @@ -10,6 +9,3 @@ org.apache.maven:maven-model:3.6.1 org.codehaus.plexus:plexus-component-annotations:1.7.1 org.codehaus.plexus:plexus-interpolation:1.25 org.codehaus.plexus:plexus-utils:3.2.0 -org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60 -org.jetbrains.kotlin:kotlin-stdlib:1.2.60 -org.jetbrains:annotations:13.0 diff --git a/plugin/gradle/dependency-locks/testCompileClasspath.lockfile b/plugin/gradle/dependency-locks/testCompileClasspath.lockfile index 98e2984..b250c16 100644 --- a/plugin/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/plugin/gradle/dependency-locks/testCompileClasspath.lockfile @@ -1,7 +1,6 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.squareup.okio:okio:2.2.2 org.apache.commons:commons-lang3:3.8.1 org.apache.maven:maven-artifact:3.6.1 org.apache.maven:maven-builder-support:3.6.1 diff --git a/plugin/gradle/dependency-locks/testRuntimeClasspath.lockfile b/plugin/gradle/dependency-locks/testRuntimeClasspath.lockfile index 98e2984..b250c16 100644 --- a/plugin/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/plugin/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -1,7 +1,6 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.squareup.okio:okio:2.2.2 org.apache.commons:commons-lang3:3.8.1 org.apache.maven:maven-artifact:3.6.1 org.apache.maven:maven-builder-support:3.6.1 diff --git a/plugin/src/main/kotlin/org/nixos/gradle2nix/DependencyResolver.kt b/plugin/src/main/kotlin/org/nixos/gradle2nix/DependencyResolver.kt index 37498c0..654dd9b 100644 --- a/plugin/src/main/kotlin/org/nixos/gradle2nix/DependencyResolver.kt +++ b/plugin/src/main/kotlin/org/nixos/gradle2nix/DependencyResolver.kt @@ -1,6 +1,5 @@ package org.nixos.gradle2nix -import okio.* import org.apache.maven.model.Parent import org.apache.maven.model.Repository import org.apache.maven.model.building.DefaultModelBuilderFactory @@ -21,6 +20,7 @@ import org.gradle.maven.MavenPomArtifact import java.io.File import java.io.InputStream import java.net.URI +import java.security.MessageDigest internal class DependencyResolver( private val configurations: ConfigurationContainer, @@ -153,11 +153,14 @@ private class MavenPomResolver( override fun addRepository(repository: Repository, replace: Boolean) {} } -private fun sha256(file: File): String { - val hashSource = HashingSource.sha256(file.source()) - val hash: ByteString = hashSource.buffer().use { source -> - source.readAll(blackholeSink()) - hashSource.hash - } - return hash.base64() +private val HEX = "0123456789ABCDEF" + +private fun sha256(file: File): String = buildString { + MessageDigest.getInstance("SHA-256").digest(file.readBytes()) + .asSequence() + .map { it.toInt() } + .forEach { + append(HEX[it shr 4 and 0x0f]) + append(HEX[it and 0x0f]) + } } diff --git a/plugin/src/main/kotlin/org/nixos/gradle2nix/Gradle2NixPlugin.kt b/plugin/src/main/kotlin/org/nixos/gradle2nix/Gradle2NixPlugin.kt index ad90491..d4c12da 100644 --- a/plugin/src/main/kotlin/org/nixos/gradle2nix/Gradle2NixPlugin.kt +++ b/plugin/src/main/kotlin/org/nixos/gradle2nix/Gradle2NixPlugin.kt @@ -1,7 +1,5 @@ package org.nixos.gradle2nix -import okio.buffer -import okio.source import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.dsl.RepositoryHandler @@ -140,9 +138,7 @@ private fun Project.projectDependencies(explicitConfigurations: List): D private fun fetchDistSha256(url: String): String { return URL("$url.sha256").openConnection().run { connect() - getInputStream().source().buffer().use { source -> - source.readUtf8() - } + getInputStream().reader().use { it.readText() } } }