Skip to content

Commit 48be3e0

Browse files
committed
initial jbang example
1 parent 58e95b3 commit 48be3e0

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

jbang/hello.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
// //DEPS <dependency1> <dependency2>
3+
4+
import static java.lang.System.*;
5+
6+
public class hello {
7+
8+
public static void main(String... args) {
9+
out.println("Hello World");
10+
}
11+
}

jbang/hellocli.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//DEPS info.picocli:picocli:4.5.0
3+
4+
import picocli.CommandLine;
5+
import picocli.CommandLine.Command;
6+
import picocli.CommandLine.Parameters;
7+
8+
import java.util.concurrent.Callable;
9+
10+
@Command(name = "hellocli", mixinStandardHelpOptions = true, version = "hellocli 0.1",
11+
description = "hellocli made with jbang")
12+
class hellocli implements Callable<Integer> {
13+
14+
@Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
15+
private String greeting;
16+
17+
public static void main(String... args) {
18+
int exitCode = new CommandLine(new hellocli()).execute(args);
19+
System.exit(exitCode);
20+
}
21+
22+
@Override
23+
public Integer call() throws Exception { // your business logic goes here...
24+
System.out.println("Hello " + greeting);
25+
return 0;
26+
}
27+
}

jbang/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>JBang meets Quarkus</title>
8+
9+
</head>
10+
<body>
11+
12+
<a href="/hello">Go Say Hello!</a>
13+
<p>
14+
Powered by:
15+
<a href="https://jbang.dev"><img src="https://www.jbang.dev/assets/images/logo.png"/></a>
16+
</p>
17+
</body>
18+
</html>

jbang/jbang-catalog.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"catalogs": {},
3+
"aliases": {
4+
"hello": {
5+
"script-ref": "hello.java"
6+
},
7+
"hellocli": {
8+
"script-ref": "hellocli.java"
9+
},
10+
"jbangquarkus": {
11+
"script-ref": "jbangquarkus.java"
12+
}
13+
},
14+
"templates": {}
15+
}

jbang/jbangquarkus.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
// Update the Quarkus version to what you want here or run jbang with
3+
// `-Dquarkus.version=<version>` to override it.
4+
//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.4.0.Final}@pom
5+
//DEPS io.quarkus:quarkus-resteasy
6+
//JAVAC_OPTIONS -parameters
7+
8+
//FILES META-INF/resources/index.html=index.html
9+
10+
import javax.enterprise.context.ApplicationScoped;
11+
import javax.ws.rs.GET;
12+
import javax.ws.rs.Path;
13+
14+
@Path("/hello")
15+
@ApplicationScoped
16+
public class jbangquarkus {
17+
@GET
18+
public String sayHello() {
19+
return "Hello from Quarkus with jbang.dev";
20+
}
21+
}

0 commit comments

Comments
 (0)