Updated kotlin, fixed deprecated methods, updated libraries
parent
0b3c6f59d3
commit
83766dd1b4
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
|
||||
import dorkbox.gradle.kotlin
|
||||
import java.time.Instant
|
||||
|
||||
///////////////////////////////
|
||||
|
@ -26,12 +27,12 @@ import java.time.Instant
|
|||
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS // always show the stacktrace!
|
||||
|
||||
plugins {
|
||||
id("com.dorkbox.GradleUtils") version "2.6"
|
||||
id("com.dorkbox.Licensing") version "2.6.1"
|
||||
id("com.dorkbox.GradleUtils") version "2.8"
|
||||
id("com.dorkbox.Licensing") version "2.7"
|
||||
id("com.dorkbox.VersionUpdate") version "2.3"
|
||||
id("com.dorkbox.GradlePublish") version "1.11"
|
||||
|
||||
kotlin("jvm") version "1.4.32"
|
||||
kotlin("jvm") version "1.5.0"
|
||||
}
|
||||
|
||||
object Extras {
|
||||
|
@ -74,18 +75,22 @@ licensing {
|
|||
author(Extras.vendor)
|
||||
|
||||
extra("ZT Process Executor", License.APACHE_2) {
|
||||
it.url("https://github.com/zeroturnaround/zt-exec")
|
||||
it.copyright(2014)
|
||||
it.author("ZeroTurnaround LLC")
|
||||
url("https://github.com/zeroturnaround/zt-exec")
|
||||
copyright(2014)
|
||||
author("ZeroTurnaround LLC")
|
||||
}
|
||||
extra("Apache Commons Exec", License.APACHE_2) {
|
||||
it.url("https://commons.apache.org/proper/commons-exec/")
|
||||
it.copyright(2014)
|
||||
it.author("The Apache Software Foundation")
|
||||
url("https://commons.apache.org/proper/commons-exec/")
|
||||
copyright(2014)
|
||||
author("The Apache Software Foundation")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.test {
|
||||
kotlin.include("**/*.java", "**/*.kt") // we have some java we depend on for unit tests
|
||||
}
|
||||
|
||||
// TODO::::: how to mark this package as "sealed" in the manifest?
|
||||
|
||||
tasks.jar.get().apply {
|
||||
|
@ -113,7 +118,7 @@ dependencies {
|
|||
compileOnly("ch.qos.logback:logback-classic:1.3.0-alpha4") // ONLY used to fixup the SSHJ logger (in LogHelper)
|
||||
|
||||
// NOTE: JSCH is no longer maintained.
|
||||
// The fork from https://github.com/mwiede/jsch fixes many issues, but STILL cannot connect to an ubutnu 18.04 instance
|
||||
// The fork from https://github.com/mwiede/jsch fixes many issues, but STILL cannot connect to an ubuntu 18.04 instance
|
||||
// implementation("com.jcraft:jsch:0.1.55")
|
||||
// NOTE: The SSHJ implementation works and is well documented. It is also used by Intellij 2019.2+, so it is also well tested and used
|
||||
// https://github.com/hierynomus/sshj
|
||||
|
|
|
@ -542,7 +542,7 @@ class DeferredProcessResult internal constructor(private val process: Process,
|
|||
}
|
||||
|
||||
private fun getUnitsAsString(timeout: Long, timeUnit: TimeUnit): String {
|
||||
var result = timeUnit.toString().toLowerCase()
|
||||
var result = timeUnit.toString().lowercase()
|
||||
|
||||
if (timeout == 1L) {
|
||||
// fix plurality
|
||||
|
|
|
@ -104,7 +104,7 @@ open class Executor {
|
|||
|
||||
init {
|
||||
// cannot use any dependencies!
|
||||
val osName = System.getProperty("os.name").toLowerCase()
|
||||
val osName = System.getProperty("os.name").lowercase()
|
||||
IS_OS_WINDOWS = osName.startsWith("win")
|
||||
IS_OS_MAC = osName.startsWith("mac") || osName.startsWith("darwin")
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ import kotlinx.coroutines.channels.Channel
|
|||
// This IS NOT bi-directional waiting. The method names to not reflect this, however there is no possibility of race conditions w.r.t. waiting
|
||||
// https://stackoverflow.com/questions/55421710/how-to-suspend-kotlin-coroutine-until-notified
|
||||
// https://kotlinlang.org/docs/reference/coroutines/channels.html
|
||||
inline class SuspendNotifier(private val channel: Channel<Unit> = Channel(2)) {
|
||||
@JvmInline
|
||||
value class SuspendNotifier(private val channel: Channel<Unit> = Channel(2)) {
|
||||
// "receive' suspends until another coroutine invokes "send"
|
||||
// and
|
||||
// "send" WILL NOT suspend. If there nothing waiting, then nothing happens
|
||||
|
|
|
@ -34,8 +34,8 @@ import java.nio.charset.Charset
|
|||
*/
|
||||
open class AsyncProcessOutput(private val channel: Channel<Byte>, private val processResult: SyncProcessResult?) {
|
||||
companion object {
|
||||
private val NEW_LINE_WIN = "\r".toCharArray().first().toInt()
|
||||
private val NEW_LINE_NIX = "\n".toCharArray().first().toInt()
|
||||
private val NEW_LINE_WIN = "\r".toCharArray().first().code
|
||||
private val NEW_LINE_NIX = "\n".toCharArray().first().code
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
|
|
|
@ -73,7 +73,8 @@ interface IOStream {
|
|||
|
||||
|
||||
|
||||
inline class PumpedOutputStream(private val out: OutputStream) : IOStream {
|
||||
@JvmInline
|
||||
value class PumpedOutputStream(private val out: OutputStream) : IOStream {
|
||||
override suspend fun pump(length: Int, inputStream: InputStream) {
|
||||
(0 until length.coerceAtMost(PumpStreamHandler.DEFAULT_SIZE)).forEach { _ ->
|
||||
out.write(inputStream.read())
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2021 dorkbox, llc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package dorkbox
|
||||
|
||||
import dorkbox.executor.Executor
|
||||
import org.junit.Test
|
||||
|
||||
class TestShell {
|
||||
@Test
|
||||
fun testPing() {
|
||||
println(Executor().command("ping 1.1.1.1").enableRead().startAsShellBlocking().output.utf8())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue