Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
MIT License
Bot releases are visible (Hide)
Published by maxandersen almost 2 years ago
Its 2023 and time to get releases going again :)
Michael Meyers added basic auth support for loading scripts allowing you to specify a username/password for secured scripts:
export JBANG_BASIC_AUTH_USERNAME=myname
export JBANG_BASIC_AUTH_PASSWORD=supersecret
jbang https://some.private/location.java
IDE's and Users can now tell JBang to download sources. Useful to have IDE's pickup sources immediately.
jbang edit
will resolve sources automatically, and by setting JBANG_DOWNLOAD_SOURCES=true
as a environment variable all operations resolving dependencies will resolve sources too.
jbang jdk
being more consistentjbang jdk
allows you to manage the java versions installed by jbang; thus jbang jdk java-env
would always prefer jbang managed jdk. Now jbang jdk java-env
will honor how jbang otherwise pick java. Meaning if you have a java in your path it will print the java-env info for java from the path.
This is a small change but could break your assumptions if you assumed jbang jdk java-env
would always give you a jbang installed java.
JBang defaults to use your local configured java or download and use versions of java from Adoptium project if no fitting JDK present.
Users using sdkman and other package managers, like scoop on Windows, requested that JBang could use those package managers java rather than jbang's own.
In this release there is a --jdk-providers
flag that allows you to enable use of sdkman and scoop.
i.e. to have jbang
honor sdkman installs before jbang but still use path if present do following:
jbang jdk --jdk-providers=path,sdkman,jbang list --show-details
Installed JDKs (<=default):
11 (11.0.17, path, path, /Users/manderse/.sdkman/candidates/java/current)
11 (11.0.17, sdkman, 11.0.17-zulu-sdkman, /Users/manderse/.sdkman/candidates/java/11.0.17-zulu)
11 (11.0.17, sdkman, current-sdkman, /Users/manderse/.sdkman/candidates/java/current)
11 (11.0.17, jbang, 11-jbang, /Users/manderse/.jbang/cache/jdks/11)
17 (17.0.5, jbang, 17-jbang, /Users/manderse/.jbang/cache/jdks/17)
19 (19.0.1, jbang, 19-jbang, /Users/manderse/.jbang/cache/jdks/19)
20 (20, jbang, 20-jbang, /Users/manderse/.jbang/cache/jdks/20)
Similar can be done with run, build and other jdk commands to get jbang to pick other package managers java.
We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, Francesco Marchioni, Mikael Koskinen, Michael Meyer
Published by maxandersen almost 2 years ago
JBang once had Twitter support but they shutdown non-javascript based access to statuses. Thus it seems appropriate with all
the Mastodon happening to enable JBang to run Mastodon status url's:
jbang https://fosstodon.org/@jbangdev/109367735752497165
Thanks to @fbricon for helping adding some color to age-old "Hello World!"
Oh ...and we also finally managed to upgrade build to Gradle 7 (Thanks @quintesse) and with a better verification in github (Thanks @manikmagar)
We'd like to thank the following people for their contributions:
Manik Magar, Tako Schotanus, Max Rydahl Andersen, GitHub
Published by maxandersen almost 2 years ago
Kotlin support was broken as its compiler don't support -g
for debug symbols. Now fixed - sorry for the troubles!
We'd like to thank the following people for their contributions:
evanchooly, Tako Schotanus, Max Rydahl Andersen
Published by maxandersen almost 2 years ago
JBang is now a 100!
And this release fixes a regression where auth settings from ~/.m2/.settings.xml
got ignored. Now they don't. Meaning by having the following in your ~/.m2/settings.xml
:
...
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
...
which is the default case in GitHub actions jbang
will once again work when using repositories that require authentication - which is the case for GitHub packages.
JBang now has -C
and -R
for setting compile and runtime flags.
This release adds debugging by default (i.e. running javac
with -g
). If you don't want that you can run with -C=-g:none
. Turned that on because it allows then easy debugging - and it is what is the default for Maven and Gradle.
Also added support for setting JBANG_DOWNLOAD_VERSION
environment variable to allow installing arbitrary jbang
versions. i.e.
curl -Ls https://sh.jbang.dev | JBANG_DOWNLOAD_VERSION=0.48.0 bash -s - app setup
Will (if no other jbang
available on your system) install JBang 0.48 - the earliest JBang that had support for installing this way.
Enjoy!
nativeimage
We'd like to thank the following people for their contributions:
Tako Schotanus, oliv37, Max Rydahl Andersen, GitHub, Jรฉrรฉmie Bresson, allcontributors[bot]
Published by maxandersen about 2 years ago
In our move from Shrinkwrap resolver to Aether we missed handling of special packaging types like @test-jar
. Reported by @michael-simons and now fixed by @quintesse !
We'd like to thank the following people for their contributions:
Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub
Published by maxandersen about 2 years ago
JBang now fully support proxies and credentials to use with private/internal repositories. Something that was only partially working before. Settings will be read from ~/.m2/settings.xml and in future we might make more explicit setup available based on feedback.
This was enabled as we moved from Shrinkwrap to use direct Maven/Aether API which also helped reduce the size of jbang from 5.5 to 4.9 MB
In addition various fixes and improvements enabling better use of jbang, one particular is jbang info
fixes that enables the recent new JBang Visual Studio code to be even more awesome. If you have not yet tried it do give it a go - enables to open vscode on any folder with JBang enabled .java code and thing like content assist and running with jbang Just Works. Absolutely the simplest and fastest way to start writing code in Java.
--format=json
flag to list
commands (#1454)//GAV
for export mavenrepo
(#1468)info
info
on a JAR file (#1452)We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub, Ilya, allcontributors[bot]
Published by maxandersen about 2 years ago
New feature release!
New //MANIFEST
keyword to allow writing entries to META-INF/manifest.mf
including supporting build time variables:
//MANIFEST version=${version:unknown}
will result in version=unknown
by default and version=1.2
if built using jbang -Dversion=1.2 yourapp.java
.
using jbang to building project is easy; what if you also want to run tests or other build related tasks. For that jbang are hitting its limits but we think there might be a few things we can do without forcing users to use maven/gradle/etc builds.
In this version we enabled build.jbang
to be picked up and read the commands from that external file. We will evolve/change that format but at least you can try out jbang without having a single //
directive in any of your .java files.
//MANIFEST
option for source files (#1445)build.jbang
project filesProject
RunContext
to Project
Project
--preview
optionWe'd like to thank the following people for their contributions:
YeungYeah, Michael Bornholdt Nielsen, Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub, Fred Bricon
Published by maxandersen about 2 years ago
Main thing is fix for jbang info tools
so it works again enabling IDE integration to work!
But also interesting that jbang edit
with vscodium will now install jbang-vscode
allowing you to call codium yourfolder
and edit jbang based scripts apps without having to have build.gradle project generated.
We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub
Published by maxandersen about 2 years ago
--native
flag was broken/incomplete thus replace with jbang export native
; this
patch release will explain to users what to do if they used the now removed option.
export --native
(#1422)We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub
Published by maxandersen about 2 years ago
Quick fix to have container images published properly.
We'd like to thank the following people for their contributions:
Max Rydahl Andersen
Published by maxandersen about 2 years ago
Important fixes to have the Windows install/script work with systems with spaces.
And a fix that avoids problem of duplicate maven repos.
We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, Gustavo Adolfo Rodriguez Libreros, GitHub, Gustavo Adolfo Rodrรญguez Libreros
Published by maxandersen over 2 years ago
Lots of small bugfixes + stop generating class-path in jars that confuses graalvm native-image.
Class-Path
by default to JARs (#1398)wrapper install
now also copies jbang.ps1 (#1391)Builder
APIIntegrationManager
SourceSet
no longer uses Source
RunContext
SourceSet
Optional
BuildMixin
File
references to Path
JAVAC_OPTIONS
We'd like to thank the following people for their contributions:
Tako Schotanus, Ikko Ashimine, Jeremie Bresson, Max Rydahl Andersen, GitHub, Nรกndor Holozsnyรกk, Jordi Sola
Published by maxandersen over 2 years ago
This release introduces "globbing" for --sources
and --files
meaning you can do things like:
jbang --sources src/main/java --files src/main/resources script.java
or if you want only .java and only .html files:
jbang --sources src/main/java/**.java --files src/main/resources/**.html script.java
This lets you build bigger projects with more complex structures, while still being quite compact.
A interesting sideeffect of these features is that JBang can now be used to build JBang itself. See bootstrap.java if interested - still a few things needed to do a 100% bootstrap but we are getting closer :)
As been a while since a release also a good bunch of bugfixes, especially around alias handling that had a regression. If aliases was not behaving as you expect try this update and things should be better!
--available
to jdk list
--sources
--resource
/-r
are now --files
/-f
Vendor
enumWe'd like to thank the following people for their contributions:
Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub
Published by maxandersen over 2 years ago
Repository fixes/improvements is the name of the game.
First off, --fresh
will now check for update to dependencies using SNAPSHOT and RELEASE names.
Then, adding spring-snapshot
, spring-milestone
, s01sonatype-snapshots
and sonatype-snapshots
possible shorthands for maven repositories and --deps
now properly suppport comma separated list. Means you can use snapshots in a much more compact version:
jbang --repos mavencentral,s01sonatype-snapshots -Dquarkus.version=999-SNAPSHOT myrest.java
isRunCommand
into isMainRequired
We'd like to thank the following people for their contributions:
Tako Schotanus, Jeremie Bresson, Max Rydahl Andersen, GitHub, andreaTP
Published by maxandersen over 2 years ago
Mainly small fixes.
JBang no longer uses @file for large classpath/command lines with JShell. This should allow it run for more things; but can also give problems with large dependency sets on Windows. Recommend to use powershell or a linux-like terminal on Windows to avoid problems.
Export now is possible for projects without a main, i.e. for building libraries.
Also //FILES
will now tell you what file pattern failed to be resolved. Making it easier to debug.
We'd like to thank the following people for their contributions:
Andrea Peruffo, Tako Schotanus, George Gastaldi, Ikko Ashimine, Jeremie Bresson, Max Rydahl Andersen, GitHub, Pierre-Yves Fourmond, allcontributors[bot]
Published by maxandersen over 2 years ago
Fixed a bug that caused (Quarkus) external Integration to fail on Java 16+.
We'd like to thank the following people for their contributions:
Claus Ibsen, Max Rydahl Andersen, GitHub
Published by maxandersen over 2 years ago
Had to revert zero install changes to avoid app install
bug.
We'd like to thank the following people for their contributions:
Max Rydahl Andersen
Published by maxandersen over 2 years ago
This time with a mixed bag of features/improvements:
Running using curl
will now download jbang to a temporary location if no local .jbang jar found. This ensures if you run curl
install it will use the latest available.
Also When installing or running jbang using curl
osx and linux will now use /dev/tty
to
allow using console to approve/trust scripts. Windows will still use the UI based approach if necessary.
We also now don't ask to trust a script you already downloaded and not running with --fresh
.
This should all make the installation of jbang and running of scripts simpler and more reliable.
Today when using jbang integrations (i.q. Quarkus integration) it runs in the same jvm/classloader
as jbang itself. This works normally great, but if you are targeting a Java higher than the Java you are running JBang with (i.e. uses --java 17
when running with Java 11) you can get errors about mismatched Java versions.
In this release JBang now will run the integration in an external process when Java versions does not match.
This also enables a future possible improvement of making jbang
a native binary.
//SOURCES
You can now use aliases in //SOURCES
. This is mainly interesting when running jshell based scripts. For example in a .jsh file you can use //SOURCES faker@jbangdev
and you get the faker script included.
Enjoy!
//SOURCES
(#1287)--deps
and //REPOS
(#1296)-s
file is missing (#1308)We'd like to thank the following people for their contributions:
Manik Magar, Tako Schotanus, Max Rydahl Andersen, GitHub
Published by maxandersen over 2 years ago
Buckle up - this is a fun release enabling some long-awaited mythical features!
cat logs.txt | jbang -s prelude@maxandersen -c '$$(l -> l.s(2))'
jbang [email protected]
j! jdk install 18 $(sdk home java 18-open)
Details below:
You can now use an alias to load additional sources, i.e. jbang -s myscript@mycatalog ...
- all thanks to @quintesse super refactoring!.
At first, that might not look that interesting but combining it with the previous release where we added support
for running snippets with jbang -c
you can now load in a custom source that fetches dependencies and add
use case-specific top-level methods and classes.
As an example I'll use Edoardo Vacchi's idea about implementing AWK in JBang using a script called Prelude.jsh
.
Imagine you have a logs.txt
with the following content:
GET /robots.txt HTTP/1.1
HEAD /README.md HTTP/1.1
GET /wp-admin/ HTTP/1.0
And you want to print out all the paths in that log.
There is a ton of ways to do that but if you use raw java it might be quite verbose.
Now with aliases we can cut this down to:
cat logs.txt | jbang -s prelude@evacchi -c '$$(l -> l.s(2))'
This will load the script behind prelude@evacchi
which provides a method named $$
which iterates all input and give you a Line
instance where there are various methods to extract
content, i.e. l.s(2)
gives you the second column.
You can load multiple scripts from anywhere making it possible for everyone to make
interesting toplevel methods available to do useful things like the AWK example above; or maybe
just to make it fun/easier to try out your framework/api.
Looking forward to see what crazy ways you find to use this.
Until now jbang's implicit catalogs allow you to have a jbang-catalog
repository, i.e. @maxandersen
was shorthand for catalog found in https://github.com/maxandersen/jbang-catalog
. Very useful to have short and recognizable names.
Thus now if there is a '.' in the name jbang will lookup a website with that name first.
For example: jbang [email protected]
will use the catalog available at https://xam.dk/jbang-catalog.json.
There are more ways this can be used and expanded - those are covered in the docs.
We've had many requests on having jbang
utilize existing Java installs on your machine rather
than download Java separately. i.e. use sdkman's jdk installs.
We don't do that for various reasons (mainly portability), but with @nandorholozsnyak's great contribution you
can now install custom JDK's using: jbang jdk install <version> <pathtojdk>
.
Example:
Lets say you use sdkman and you want to try out Java 18 with JBang - something that today will fail
unless you have Java 18 installed as default jdk.
You can then run:
j! jdk install 18 `sdk home java 18-open`
which setup the path printed by sdk home java 18-open
to be what what JBang treat as Java 18.
Then you can run:
j! --java 18 -c 'println(javax.lang.model.SourceVersion.RELEASE_18)'
--sources script@repo
work (#1283)We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub, Pierre-Yves Fourmond, Nรกndor Holozsnyรกk
Published by maxandersen over 2 years ago
Critical fix to avoid untrusted code to run and not auto-install vscode.
Plus if you have a M1 based machine jbang will no longer fail on first run.
jbang will now download Java 17 by default as Java 11 is not yet available from Adoptium.
We'd like to thank the following people for their contributions:
Chromico Rek, Max Rydahl Andersen, GitHub, Jรฉrรฉmie Bresson