Moved from Gradle to bld
This commit is contained in:
parent
886ed86479
commit
f8cf0fd338
321 changed files with 12452 additions and 1492 deletions
8
examples/bld/src/.idea/workspace.xml
generated
Normal file
8
examples/bld/src/.idea/workspace.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"settings.editor.selected.configurable": "reference.settings.ide.settings.new.ui"
|
||||
}
|
||||
}</component>
|
||||
</project>
|
66
examples/bld/src/bld/java/com/example/ExampleBuild.java
Normal file
66
examples/bld/src/bld/java/com/example/ExampleBuild.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.example;
|
||||
|
||||
import rife.bld.BaseProject;
|
||||
import rife.bld.BuildCommand;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
import rife.bld.extension.CompileKotlinOptions;
|
||||
import rife.bld.operations.RunOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static rife.bld.dependencies.Repository.*;
|
||||
import static rife.bld.dependencies.Scope.compile;
|
||||
|
||||
public class ExampleBuild extends BaseProject {
|
||||
public ExampleBuild() {
|
||||
pkg = "com.example";
|
||||
name = "Example";
|
||||
version = version(0, 1, 0);
|
||||
|
||||
mainClass = "com.example.BitlyExampleKt";
|
||||
|
||||
javaRelease = 11;
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
|
||||
|
||||
scope(compile)
|
||||
.include(dependency("net.thauvin.erik:bitly-shorten:1.0.0"))
|
||||
.include(dependency("org.json:json:20231013"));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ExampleBuild().start(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compile() throws Exception {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.compileOptions(
|
||||
new CompileKotlinOptions()
|
||||
.jdkRelease(javaRelease)
|
||||
.verbose(true)
|
||||
)
|
||||
.execute();
|
||||
|
||||
// Also compile the Java source code
|
||||
super.compile();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "run-java", summary = "Runs the Java example")
|
||||
public void runJava() throws Exception {
|
||||
new RunOperation()
|
||||
.fromProject(this)
|
||||
.mainClass("com.example.BitlySample")
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "run-retrieve", summary = "Runs the Retrieve example")
|
||||
public void runRetrieve() throws Exception {
|
||||
new RunOperation()
|
||||
.fromProject(this)
|
||||
.mainClass("com.example.BitlyRetrieveKt")
|
||||
.execute();
|
||||
}
|
||||
}
|
27
examples/bld/src/main/java/com/example/BitlySample.java
Normal file
27
examples/bld/src/main/java/com/example/BitlySample.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.example;
|
||||
|
||||
import net.thauvin.erik.bitly.Bitly;
|
||||
|
||||
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" */);
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
23
examples/bld/src/main/kotlin/com/example/BitlyExample.kt
Normal file
23
examples/bld/src/main/kotlin/com/example/BitlyExample.kt
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.example
|
||||
|
||||
import net.thauvin.erik.bitly.Bitly
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.isNotEmpty()) {
|
||||
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
|
||||
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.")
|
||||
}
|
||||
exitProcess(0)
|
||||
}
|
24
examples/bld/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal file
24
examples/bld/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal file
|
@ -0,0 +1,24 @@
|
|||
package com.example
|
||||
|
||||
import net.thauvin.erik.bitly.Bitly
|
||||
import net.thauvin.erik.bitly.Methods
|
||||
import org.json.JSONObject
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main() {
|
||||
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
|
||||
|
||||
// See https://dev.bitly.com/v4/#operation/getBitlink
|
||||
val response = bitly.call("/bitlinks/bit.ly/380ojFd", method = Methods.GET)
|
||||
|
||||
if (response.isSuccessful) {
|
||||
val json = JSONObject(response.body)
|
||||
println("Title : " + json.getString("title"))
|
||||
println("URL : " + json.getString("long_url"))
|
||||
println("By : " + json.getString("created_by"))
|
||||
} else {
|
||||
println("${response.message}: ${response.description} (${response.statusCode})")
|
||||
}
|
||||
|
||||
exitProcess(0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue