diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 1ea7c06..b2820cf 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "1.3.71" + id("org.jetbrains.kotlin.jvm") version "1.3.72" id("com.github.ben-manes.versions") version "0.28.0" application } @@ -18,8 +18,8 @@ dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("net.thauvin.erik:bitly-shorten:0.9.1-beta") - implementation("org.json:json:20190722") + implementation("net.thauvin.erik:bitly-shorten:0.9.2") + implementation("org.json:json:20200518") } application { diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar index f3d88b1..62d4c05 100644 Binary files a/examples/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties index a2bf131..622ab64 100644 --- a/examples/gradle/wrapper/gradle-wrapper.properties +++ b/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/gradlew b/examples/gradlew index 2fe81a7..fbd7c51 100644 --- a/examples/gradlew +++ b/examples/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/examples/gradlew.bat b/examples/gradlew.bat index 62bd9b9..5093609 100644 --- a/examples/gradlew.bat +++ b/examples/gradlew.bat @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/examples/src/main/java/com/example/BitlySample.java b/examples/src/main/java/com/example/BitlySample.java index 0a6cf48..de39b6b 100644 --- a/examples/src/main/java/com/example/BitlySample.java +++ b/examples/src/main/java/com/example/BitlySample.java @@ -6,12 +6,16 @@ public final class BitlySample { public static void main(final String[] args) { if (args.length > 0) { final Bitly bitly = new Bitly(/* "YOUR_API_TOKEN from https://bitly.is/accesstoken" */); - for (final String arg : args) { - if (arg.contains("bit.ly")) { - System.out.println(arg + " <-- " + bitly.bitlinks().expand(arg)); - } else { - System.out.println(arg + " --> " + bitly.bitlinks().shorten(arg)); + if (!bitly.getAccessToken().isEmpty()) { + for (final String arg : args) { + if (arg.contains("bit.ly")) { + System.out.println(arg + " <-- " + bitly.bitlinks().expand(arg)); + } else { + System.out.println(arg + " --> " + bitly.bitlinks().shorten(arg)); + } } + } else { + System.err.println("Please specify a Bitly API access token."); } } else { System.err.println("Try specifying one or more URLs as arguments."); diff --git a/examples/src/main/kotlin/com/example/BitlyExample.kt b/examples/src/main/kotlin/com/example/BitlyExample.kt index 208758a..f011a1e 100644 --- a/examples/src/main/kotlin/com/example/BitlyExample.kt +++ b/examples/src/main/kotlin/com/example/BitlyExample.kt @@ -6,11 +6,15 @@ import kotlin.system.exitProcess fun main(args: Array) { if (args.isNotEmpty()) { val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */) - args.forEach { - if (it.contains("bit.ly")) - println(it + " <-- " + bitly.bitlinks().expand(it)) - else - println(it + " --> " + bitly.bitlinks().shorten(it)) + if (bitly.accessToken.isNotEmpty()) { + args.forEach { + if (it.contains("bit.ly")) + println(it + " <-- " + bitly.bitlinks().expand(it)) + else + println(it + " --> " + bitly.bitlinks().shorten(it)) + } + } else { + println("Please specify a Bitly API access token.") } } else { println("Try specifying one or more URLs as arguments.")