initial jbang example

This commit is contained in:
Max Rydahl Andersen 2021-11-14 11:47:06 +01:00
parent 3dd23710d7
commit 0f1a1b5cf2
5 changed files with 92 additions and 0 deletions

11
jbang/hello.java Executable file
View File

@ -0,0 +1,11 @@
///usr/bin/env jbang "$0" "$@" ; exit $?
// //DEPS <dependency1> <dependency2>
import static java.lang.System.*;
public class hello {
public static void main(String... args) {
out.println("Hello World");
}
}

27
jbang/hellocli.java Executable file
View File

@ -0,0 +1,27 @@
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;
@Command(name = "hellocli", mixinStandardHelpOptions = true, version = "hellocli 0.1",
description = "hellocli made with jbang")
class hellocli implements Callable<Integer> {
@Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
private String greeting;
public static void main(String... args) {
int exitCode = new CommandLine(new hellocli()).execute(args);
System.exit(exitCode);
}
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Hello " + greeting);
return 0;
}
}

18
jbang/index.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JBang meets Quarkus</title>
</head>
<body>
<a href="/hello">Go Say Hello!</a>
<p>
Powered by:
<a href="https://jbang.dev"><img src="https://www.jbang.dev/assets/images/logo.png"/></a>
</p>
</body>
</html>

15
jbang/jbang-catalog.json Normal file
View File

@ -0,0 +1,15 @@
{
"catalogs": {},
"aliases": {
"hello": {
"script-ref": "hello.java"
},
"hellocli": {
"script-ref": "hellocli.java"
},
"jbangquarkus": {
"script-ref": "jbangquarkus.java"
}
},
"templates": {}
}

21
jbang/jbangquarkus.java Executable file
View File

@ -0,0 +1,21 @@
///usr/bin/env jbang "$0" "$@" ; exit $?
// Update the Quarkus version to what you want here or run jbang with
// `-Dquarkus.version=<version>` to override it.
//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.4.0.Final}@pom
//DEPS io.quarkus:quarkus-resteasy
//JAVAC_OPTIONS -parameters
//FILES META-INF/resources/index.html=index.html
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/hello")
@ApplicationScoped
public class jbangquarkus {
@GET
public String sayHello() {
return "Hello from Quarkus with jbang.dev";
}
}