Examples · Kotlin
Try a Maven library without a build filePro
To find out whether a library does what you need, you shouldn't have to start a project. One @file:DependsOn line at the top of a query brings it, and what it depends on, from Maven Central.
This one uses Apache Commons Text for camel case, word wrapping and the edit distance between pairs of words: how many letters must change to turn one into the other.
The query
maven-library-in-a-script.kts · paste it into a Kotlin tab and press F5, or run byterunner run maven-library-in-a-script.kts in a terminal
// Pull a library from Maven Central into this one script: no build file, nothing to install.
@file:DependsOn("org.apache.commons:commons-text:1.12.0")
import org.apache.commons.text.CaseUtils
import org.apache.commons.text.WordUtils
import org.apache.commons.text.similarity.LevenshteinDistance
dump(CaseUtils.toCamelCase("order line item", false), "camelCase")
dump(WordUtils.wrap("The library is downloaded the first time and kept for next time.", 30), "Wrapped at 30")
val distance = LevenshteinDistance.getDefaultInstance()
data class Distance(val from: String, val to: String, val edits: Int)
listOf("colour" to "color", "recieve" to "receive", "kitten" to "sitting")
.map { (from, to) -> Distance(from, to, distance.apply(from, to)) }
.dump("Edit distance")
What it shows
The output of that run, from byterunner run. In the app each table is a sortable grid.
camelCase: orderLineItem
Wrapped at 30: The library is downloaded the
first time and kept for next
time.
Edit distance
from to edits
------- ------- -----
colour color 1
recieve receive 2
kitten sitting 3
(3 rows)
The first run downloads the library; after that it's kept, so the next run starts at once. Several @file:DependsOn lines can be added, and the same works in Java and Groovy queries.
Package management is part of ByteRunner Pro, and every install includes a 14-day Pro trial.