Skip to content

Commit a3709f0

Browse files
authored
Shell 0.6.0 (#5)
* Updated Gradle * Updated build.gradle.kts to the latest Kotlin and latest libs * Added alias slash as an alias for resolve() * Updated the way how the artifacts are published by Gradle to MavenCentral (external plugin)
1 parent c6d7f9e commit a3709f0

File tree

4 files changed

+69
-134
lines changed

4 files changed

+69
-134
lines changed

build.gradle.kts

Lines changed: 54 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,28 @@
1-
val kotlinVersion: String = "1.7.21"
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
val kotlinVersion: String = "2.1.21"
24

35
plugins {
4-
kotlin("jvm") version "1.7.21"
5-
id("com.adarshr.test-logger") version "3.2.0"
66
`maven-publish`
7-
signing
7+
kotlin("jvm") version "2.1.21"
8+
id("com.adarshr.test-logger") version "4.0.0"
9+
id("com.vanniktech.maven.publish") version "0.33.0"
810
}
911

1012
repositories {
1113
mavenCentral()
1214
}
1315

1416
group = "io.github.kscripting"
15-
version = "0.5.2"
16-
17-
sourceSets {
18-
create("integration") {
19-
// test { //With that idea can understand that 'integration' is test source set and do not complain about test
20-
// names starting with upper case, but it doesn't compile correctly with it
21-
java.srcDir("$projectDir/src/integration/kotlin")
22-
resources.srcDir("$projectDir/src/integration/resources")
23-
compileClasspath += main.get().output + test.get().output
24-
runtimeClasspath += main.get().output + test.get().output
25-
}
26-
// }
27-
}
28-
29-
configurations {
30-
get("integrationImplementation").apply { extendsFrom(get("testImplementation")) }
31-
}
32-
33-
java {
34-
toolchain {
35-
languageVersion.set(JavaLanguageVersion.of(8))
36-
}
37-
38-
withJavadocJar()
39-
withSourcesJar()
40-
}
41-
42-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
43-
kotlinOptions {
44-
jvmTarget = "1.8"
45-
}
46-
}
47-
48-
tasks.create<Test>("integration") {
49-
val itags = System.getProperty("includeTags") ?: ""
50-
val etags = System.getProperty("excludeTags") ?: ""
51-
52-
useJUnitPlatform {
53-
if (itags.isNotBlank()) {
54-
includeTags(itags)
55-
}
56-
57-
if (etags.isNotBlank()) {
58-
excludeTags(etags)
59-
}
60-
}
17+
version = "0.6.0"
6118

62-
systemProperty("osType", System.getProperty("osType"))
63-
systemProperty("projectPath", projectDir.absolutePath)
64-
systemProperty("shellPath", System.getProperty("shellPath"))
65-
66-
description = "Runs the integration tests."
67-
group = "verification"
68-
testClassesDirs = sourceSets["integration"].output.classesDirs
69-
classpath = sourceSets["integration"].runtimeClasspath
70-
outputs.upToDateWhen { false }
71-
mustRunAfter(tasks["test"])
72-
//dependsOn(tasks["assemble"], tasks["test"])
73-
74-
doLast {
75-
println("Include tags: $itags")
76-
println("Exclude tags: $etags")
77-
}
19+
kotlin {
20+
jvmToolchain(17)
7821
}
7922

80-
tasks.create<Task>("printIntegrationClasspath") {
81-
doLast {
82-
println(sourceSets["integration"].runtimeClasspath.asPath)
23+
tasks.withType<KotlinCompile>().all {
24+
compilerOptions {
25+
freeCompilerArgs.add("-Xcontext-parameters")
8326
}
8427
}
8528

@@ -92,77 +35,64 @@ tasks.test {
9235
useJUnitPlatform()
9336
}
9437

95-
publishing {
96-
publications {
97-
create<MavenPublication>("mavenJava") {
98-
artifactId = "shell"
99-
from(components["java"])
100-
101-
pom {
102-
name.set("kscript")
103-
description.set("Shell - library for interoperability with different system shells")
104-
url.set("https://github.com/kscripting/shell")
105-
106-
licenses {
107-
license {
108-
name.set("MIT License")
109-
url.set("https://opensource.org/licenses/MIT")
110-
}
111-
}
112-
developers {
113-
developer {
114-
id.set("aartiPl")
115-
name.set("Marcin Kuszczak")
116-
email.set("aarti@interia.pl")
117-
}
118-
}
119-
scm {
120-
connection.set("scm:git:git://https://github.com/kscripting/shell.git")
121-
developerConnection.set("scm:git:ssh:https://github.com/kscripting/shell.git")
122-
url.set("https://github.com/kscripting/shell")
123-
}
124-
}
125-
}
126-
}
38+
// NOTE: deploying snapshots is complicated with this plugin
39+
// It is better to use repository with the staging version of artifact to test it
40+
mavenPublishing {
41+
coordinates(project.group.toString(), project.name, project.version.toString())
12742

128-
repositories {
129-
maven {
130-
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
131-
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
132-
url = uri(if (project.version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
43+
pom {
44+
name.set("shell")
45+
description.set("Shell - library for interoperability with different system shells")
46+
url.set("https://github.com/kscripting/shell")
13347

134-
credentials {
135-
username = project.findProperty("sonatype.user") as String? ?: System.getenv("SONATYPE_USER")
136-
password = project.findProperty("sonatype.password") as String? ?: System.getenv("SONATYPE_PASSWORD")
48+
licenses {
49+
license {
50+
name.set("MIT License")
51+
url.set("https://opensource.org/licenses/MIT")
52+
}
53+
}
54+
developers {
55+
developer {
56+
id.set("aartiPl")
57+
name.set("Marcin Kuszczak")
58+
email.set("aarti@interia.pl")
13759
}
13860
}
61+
scm {
62+
connection.set("scm:git:git://https://github.com/kscripting/shell.git")
63+
developerConnection.set("scm:git:ssh:https://github.com/kscripting/shell.git")
64+
url.set("https://github.com/kscripting/shell")
65+
}
13966
}
14067
}
14168

142-
signing {
143-
sign(publishing.publications["mavenJava"])
69+
mavenPublishing {
70+
publishToMavenCentral()
71+
signAllPublications()
14472
}
14573

14674
dependencies {
14775
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
14876
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
149-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
77+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
15078

15179
implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
15280
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
15381
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven-all:$kotlinVersion")
154-
implementation("io.arrow-kt:arrow-core:1.1.2")
155-
implementation("org.apache.commons:commons-lang3:3.12.0")
156-
157-
implementation("org.slf4j:slf4j-nop:2.0.4")
158-
159-
testImplementation("org.junit.platform:junit-platform-suite-engine:1.9.0")
160-
testImplementation("org.junit.platform:junit-platform-suite-api:1.9.0")
161-
testImplementation("org.junit.platform:junit-platform-suite-commons:1.9.0")
162-
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.0")
163-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0")
164-
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
165-
testImplementation("io.mockk:mockk:1.13.2")
82+
implementation("io.arrow-kt:arrow-core:2.1.2")
83+
implementation("org.apache.commons:commons-lang3:3.17.0")
84+
85+
implementation("org.slf4j:slf4j-nop:2.0.17")
86+
87+
val junitVersion = "6.0.0-M1"
88+
testImplementation("org.junit.platform:junit-platform-suite-engine:$junitVersion")
89+
testImplementation("org.junit.platform:junit-platform-suite-api:$junitVersion")
90+
testImplementation("org.junit.platform:junit-platform-suite-commons:$junitVersion")
91+
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
92+
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
93+
94+
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1")
95+
testImplementation("io.mockk:mockk:1.14.4")
16696

16797
testImplementation(kotlin("script-runtime"))
16898
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/kotlin/io/github/kscripting/shell/model/OsPathExt.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ fun OsPath.toNativeFile(): File = toNativePath().toFile()
3030

3131
// OsPath operations
3232

33+
operator fun OsPath.div(osPath: OsPath): OsPath = resolve(osPath)
34+
35+
operator fun OsPath.div(path: String): OsPath = resolve(path)
36+
3337
fun OsPath.exists() = toNativePath().exists()
3438

3539
fun OsPath.createDirectories(): OsPath = OsPath.createOrThrow(nativeType, toNativePath().createDirectories().pathString)

src/test/kotlin/io/github/kscripting/shell/model/OsPathTest.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.kscripting.shell.model
22

3+
import assertk.assertFailure
34
import assertk.assertThat
45
import assertk.assertions.*
56
import org.junit.jupiter.api.Test
@@ -91,14 +92,14 @@ class OsPathTest {
9192
it.prop(OsPath::osType).isEqualTo(OsType.LINUX)
9293
}
9394

94-
assertThat { OsPath.createOrThrow(OsType.LINUX, "/.kscript/../../") }.isFailure()
95+
assertFailure { OsPath.createOrThrow(OsType.LINUX, "/.kscript/../../") }
9596
.isInstanceOf(IllegalArgumentException::class.java)
9697
.hasMessage("Path after normalization goes beyond root element: '/.kscript/../../'")
9798
}
9899

99100
@Test
100101
fun `Test invalid Linux paths`() {
101-
assertThat { OsPath.createOrThrow(OsType.LINUX, "/ad*asdf") }.isFailure()
102+
assertFailure { OsPath.createOrThrow(OsType.LINUX, "/ad*asdf") }
102103
.isInstanceOf(IllegalArgumentException::class.java)
103104
.hasMessage("Invalid character '*' in path '/ad*asdf'")
104105
}
@@ -147,15 +148,15 @@ class OsPathTest {
147148
.stringPath()
148149
).isEqualTo("./.kscript")
149150

150-
assertThat {
151+
assertFailure {
151152
OsPath.createOrThrow(OsType.LINUX, "./home/admin").resolve(OsPath.createOrThrow(OsType.WINDOWS, ".\\run"))
152-
}.isFailure()
153+
}
153154
.isInstanceOf(IllegalArgumentException::class.java)
154155
.hasMessage("Paths from different OS's: 'LINUX' path can not be resolved with 'WINDOWS' path")
155156

156-
assertThat {
157+
assertFailure {
157158
OsPath.createOrThrow(OsType.LINUX, "./home/admin").resolve(OsPath.createOrThrow(OsType.LINUX, "/run"))
158-
}.isFailure()
159+
}
159160
.isInstanceOf(IllegalArgumentException::class.java)
160161
.hasMessage("Can not resolve absolute, relative or undefined path './home/admin' using absolute path '/run'")
161162
}
@@ -247,18 +248,18 @@ class OsPathTest {
247248
it.prop(OsPath::osType).isEqualTo(OsType.WINDOWS)
248249
}
249250

250-
assertThat { OsPath.createOrThrow(OsType.WINDOWS, "C:\\.kscript\\..\\..\\") }.isFailure()
251+
assertFailure { OsPath.createOrThrow(OsType.WINDOWS, "C:\\.kscript\\..\\..\\") }
251252
.isInstanceOf(IllegalArgumentException::class.java)
252253
.hasMessage("Path after normalization goes beyond root element: 'C:\\.kscript\\..\\..\\'")
253254
}
254255

255256
@Test
256257
fun `Test invalid Windows paths`() {
257-
assertThat { OsPath.createOrThrow(OsType.WINDOWS, "C:\\adas?df") }.isFailure()
258+
assertFailure { OsPath.createOrThrow(OsType.WINDOWS, "C:\\adas?df") }
258259
.isInstanceOf(IllegalArgumentException::class.java)
259260
.hasMessage("Invalid character '?' in path 'C:\\adas?df'")
260261

261-
assertThat { OsPath.createOrThrow(OsType.WINDOWS, "home:\\vagrant") }.isFailure()
262+
assertFailure { OsPath.createOrThrow(OsType.WINDOWS, "home:\\vagrant") }
262263
.isInstanceOf(IllegalArgumentException::class.java)
263264
.hasMessage("Invalid character ':' in path 'home:\\vagrant'")
264265
}

0 commit comments

Comments
 (0)