Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created July 8, 2023 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxandersen/698334f17b82249eac15d37330c97a51 to your computer and use it in GitHub Desktop.
Save maxandersen/698334f17b82249eac15d37330c97a51 to your computer and use it in GitHub Desktop.
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.6.3
//DEPS morpher.java
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;
@Command(name = "hello", mixinStandardHelpOptions = true, version = "hello 0.1",
description = "hello made with jbang")
class hello 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 hello()).execute(args);
System.exit(exitCode);
}
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Hello " + greeting);
return 0;
}
}
///usr/bin/env jbang "$0" "$@" ; exit $?
//FILES META-INF/jbang-integration.list=morpher.list
import static java.lang.System.*;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class morpher {
public static Map<String, Object> postBuild(Path temporaryJar,
Path pomFile,
List<Map.Entry<String, String>> repositories,
List<Map.Entry<String, Path>> dependencies,
List<String> comments,
boolean nativeImage) {
System.out.println("Integration... (out)");
System.err.println("Integration... (err)");
if (System.getProperty("failintegration") != null) {
throw new RuntimeException("Failing integration...");
} else {
System.out.println("Integration OK (out)");
System.err.println("Integration OK (err)");
return Collections.emptyMap();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment