Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.
/ bach Public archive
forked from sormuras/bach

Java Shell Builder - Use jshell to build your modular project

License

Notifications You must be signed in to change notification settings

ci-and-cd/bach

 
 

Repository files navigation

bach - Java Shell Builder

jdk11 travis experimental

Use Java source in jshell to build your modular project.

No need to be a maven to be able to use a build tool - forax/pro

Fast-forward to install-jdk.sh section.

simple usage

Download a copy of Bach.java to your project's root directory and put the following jshell script in file called build.jsh. Launch the build with jshell build.jsh.

/open Bach.java

new Bach().run("java", "--version")

/exit

make it executable

Want to call just ./build to launch the build?

Add the following pseudo-shebang as the first line to build.jsh:

//usr/bin/env jshell --show-version "$0" "$@"; exit $?

Don't forget to mark your build script executable, i.e. chmod u+x build.jsh. See bootstrap on-the-fly section below for an example.

bootstrap on-the-fly

Copy and paste the source of bootstrap.jsh to automatically download that latest revisions of Bach.java and Bach.jsh.

//usr/bin/env jshell --show-version "$0" "$@"; exit $?

/*
 * Open and load "Bach.java" and "Bach.jsh" into this jshell session.
 */
/open https://github.com/sormuras/bach/raw/master/src/bach/Bach.java
/open https://github.com/sormuras/bach/raw/master/src/bach/Bach.jsh

/*
 * Use it!
 */
java("--version")

/exit

install-jdk.sh

install-jdk.sh main purpose is to install the latest-and-greatest available OpenJDK release from jdk.java.net. It supports GA releases and builds provided by Oracle as well.

Options of install-jdk.sh

-h|--help                 Displays this help
-d|--dry-run              Activates dry-run mode
-s|--silent               Displays no output
-e|--emit-java-home       Print value of "JAVA_HOME" to stdout (ignores silent mode)
-v|--verbose              Displays verbose output

-f|--feature 9|10|...|ea  JDK feature release number, defaults to "ea"
-l|--license GPL|BCL      License defaults to "GPL"
-o|--os linux-x64|osx-x64 Operating system identifier (works best with GPL license)
-u|--url "https://..."    Use custom JDK archive (provided as .tar.gz file)
-w|--workspace PATH       Working directory defaults to user's ${HOME}
-t|--target PATH          Target directory, defaults to first component of the tarball
-c|--cacerts              Link system CA certificates (currently only Debian/Ubuntu is supported)

How to set JAVA_HOME with install-jdk.sh

  • Source install-jdk.sh into current shell to install latest OpenJDK and let it update JAVA_HOME and PATH environment variables:

    • source ./install-jdk.sh Caveat: if an error happens during script execution the calling shell will terminate
  • Provide target directory path to use as JAVA_HOME:

    • JAVA_HOME=~/jdk && ./install-jdk.sh --target $JAVA_HOME && PATH=$JAVA_HOME/bin:$PATH
  • Run install-jdk.sh in a sub-shell to install latest OpenJDK and emit the installation path to stdout:

    • JAVA_HOME=$(./install-jdk.sh --silent --emit-java-home)
    • JAVA_HOME=$(./install-jdk.sh --emit-java-home | tail --lines 1)

be free - have fun

jsb

About

Java Shell Builder - Use jshell to build your modular project

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.0%
  • Shell 2.0%