Added fatJar task and standalone instructions
This commit is contained in:
parent
ac5f8e5334
commit
b9c1449d55
4 changed files with 60 additions and 3 deletions
41
README.md
41
README.md
|
@ -48,3 +48,44 @@ dependencies {
|
|||
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/urlencoder).
|
||||
|
||||
## Standalone usage
|
||||
|
||||
UrlEncoder can be used on the command line also, both for encoding and decoding.
|
||||
|
||||
You have two options:
|
||||
* run it with Gradle
|
||||
* build the jar and launch it with Java
|
||||
|
||||
The usage is as follows:
|
||||
|
||||
```
|
||||
Encode and decode URL parameters.
|
||||
-e encode (default)
|
||||
-d decode
|
||||
```
|
||||
|
||||
### Running with Gradle
|
||||
|
||||
```shell
|
||||
./gradlew run --args="-e 'a test &'" # -> a%20test%20%26
|
||||
./gradlew run --args="%#okékÉȢ" # -> %25%23ok%C3%A9k%C3%89%C8%A2
|
||||
|
||||
./gradlew run --args="-d 'a%20test%20%26'" # -> a test &
|
||||
```
|
||||
|
||||
### Running with Java
|
||||
|
||||
First build the jar file:
|
||||
|
||||
```shell
|
||||
./gradlew clean fatJar
|
||||
```
|
||||
|
||||
Then run it:
|
||||
|
||||
```shell
|
||||
java -jar lib/build/libs/urlencoder-*all.jar -e "a test &" # -> a%20test%20%26
|
||||
java -jar lib/build/libs/urlencoder-*all.jar "%#okékÉȢ" # -> %25%23ok%C3%A9k%C3%89%C8%A2
|
||||
|
||||
java -jar lib/build/libs/urlencoder-*.all.jar -d "a%20test%20%26" # -> a test &
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ plugins {
|
|||
|
||||
description = "A simple library to encode/decode URL parameters"
|
||||
group = "net.thauvin.erik"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1-SNAPSHOT"
|
||||
|
||||
|
||||
val mavenName = "UrlEncoder"
|
||||
|
@ -81,6 +81,22 @@ tasks {
|
|||
}
|
||||
}
|
||||
|
||||
val fatJar = register<Jar>("fatJar") {
|
||||
group = "build"
|
||||
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources"))
|
||||
archiveClassifier.set("all")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
manifest { attributes(mapOf("Main-Class" to application.mainClass)) }
|
||||
val sourcesMain = sourceSets.main.get()
|
||||
val contents = configurations.runtimeClasspath.get()
|
||||
.map { if (it.isDirectory) it else zipTree(it) } + sourcesMain.output
|
||||
from(contents)
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(fatJar)
|
||||
}
|
||||
|
||||
withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.thauvin.erik</groupId>
|
||||
<artifactId>urlencoder</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<name>UrlEncoder</name>
|
||||
<description>A simple library to encode/decode URL parameters</description>
|
||||
<url>https://github.com/ethauvin/urlencoder</url>
|
||||
|
|
|
@ -32,7 +32,7 @@ import kotlin.system.exitProcess
|
|||
object UrlEncoder {
|
||||
private val hexDigits = "0123456789ABCDEF".toCharArray()
|
||||
internal val usage =
|
||||
"Usage : kotlin -cp urlencoder-*.jar ${UrlEncoder::class.java.name} [-ed] text" + System.lineSeparator() +
|
||||
"Usage : java -jar urlencoder-*all.jar [-ed] text" + System.lineSeparator() +
|
||||
"Encode and decode URL parameters." + System.lineSeparator() + " -e encode (default) " +
|
||||
System.lineSeparator() + " -d decode"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue