jbang

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

Stars
1.3K
Committers
91

Bot releases are hidden (Show)

jbang - v0.102.0

Published by maxandersen almost 2 years ago

Its 2023 and time to get releases going again :)

Basic Auth

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

Download sources

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 consistent

jbang 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.

Using other package manager's java (Experimental)

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.

Changelog

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, Francesco Marchioni, Mikael Koskinen, Michael Meyer

๐Ÿš€ Features

  • 20b39af Enabled the usage of existing JDK installations (#1500)
  • 28957ce adding --ds/--download-sources and auto download for edit (#1539)
  • 019d732 support basic-auth for loading scripts (#1516)

๐Ÿ› Fixes

  • ddb15da upgraded to latest spotless
  • 6a991da make integrations work again (#1525)
  • ff43188 first install on Windows not working

๐Ÿ›  Build

  • 062e1c8 remove spotlessxml implicit dependency warnings

jbang - v0.101.0

Published by maxandersen almost 2 years ago

Changelog

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)

๐Ÿš€ Features

  • dab4bc3 mastodon url support (#1517)

๐Ÿงฐ Tasks

  • 3c2d256 Official Gradle Wrapper Validation Action (#1515)
  • 1aa1404 upgraded to Gradle 7 (#1518)

  • f12b1db [minor]

Contributors

We'd like to thank the following people for their contributions:
Manik Magar, Tako Schotanus, Max Rydahl Andersen, GitHub

jbang - v0.100.1

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!

๐Ÿ› Fixes

  • 35d2038 only add -g for javac invocations.

  • 7345c4e [patch]

Contributors

We'd like to thank the following people for their contributions:
evanchooly, Tako Schotanus, Max Rydahl Andersen

jbang - v0.100.0

Published by maxandersen almost 2 years ago

JBang is now a 100!

Fix missing authentication for Maven repositories

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.

Compile and runtime flags

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.

Download specific JBang version

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!

Changelog

๐Ÿš€ Features

  • 1649814 honor JBANG_DOWNLOAD_VERSION in bootstrap setup (#1505)
  • 6e6312d added support for specifying native options (#1494)
  • 876a540 enable -g by default + allow -g=vars,lines,source,none (#1479)

๐Ÿ› Fixes

  • cd1f71f ensure cache jdks directory exists before creating link (#1503)
  • 5227a95 apply auth from global settings to repositories and use ~/.m2/settings.xml as global rather than user settings (#1506)
  • 192972e now actually passing native options to nativeimage

๐Ÿ“ Documentation

  • d453045 Explain how you can install an existing jdk (#1487)
  • dae3dff update links to the Conventional Commits spec (#1488)

  • e74d8b0 [minor]
  • fa3c0c0 add oliv37 as a contributor for code (#1509)
  • 28bf948 Refactor RunContext into ProjectBuilder and other stuff (#1469)

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, oliv37, Max Rydahl Andersen, GitHub, Jรฉrรฉmie Bresson, allcontributors[bot]

jbang - v0.99.1

Published by maxandersen about 2 years ago

Changelog

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 !

๐Ÿ› Fixes

  • 2edef92 the Aether resolver now uses packing types
  • 3dbb8f9 do not use daemon in ci build

๐Ÿ“ Documentation

  • bbe96ca fix typo in running.adoc (#1477)

  • c0fb5d3 [patch] release
  • d1a7e24 add 19 to jdk matrix

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub

jbang - v0.99.0

Published by maxandersen about 2 years ago

Enterprise JBang

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.

Changelog

๐Ÿš€ Features

  • b9a339c Switched Shrinkwrap for Maven/Aether API (#1456)
  • 9a3d4c9 Added --format=json flag to list commands (#1454)

๐Ÿ› Fixes

  • a38cf87 fixed "app install" using path with spaces
  • e1f62dd fixes running installed apps on Windows
  • 4d6ab0e use //GAV for export mavenrepo (#1468)
  • 7c99280 check for recursion when running info
  • d983101 update to disco v3 endpoints
  • 10426e9 Fixed NPE when running info on a JAR file (#1452)

๐Ÿ›  Build

  • 32e6b25 added tests for #1464

๐Ÿ“ Documentation

  • a7625d0 Change brew install command (#1457)

  • 0418303 [minor] release
  • 6218b6f Add @yeung66 as a contributor
  • ef8c348 add garodriguezlp as a contributor (#1463)
  • 73239f7 add jarryDk as a contributor (#1462)
  • b4aee56 add someth2say as a contributor (#1461)
  • bda9950 add agoalofalife as a contributor (#1460)
  • 5a1dc11 Fixed passing arguments to .bat files on Windows (#1449)

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub, Ilya, allcontributors[bot]

jbang - v0.98.0

Published by maxandersen about 2 years ago

New feature release!

MANIFEST

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.

build.jbang (preview)

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.

Changelog

๐Ÿš€ Features

  • 65f5723 Added //MANIFEST option for source files (#1445)
  • 731399a added support for build.jbang project files
  • 9faf9f8 Hide .project/.classpath from virtual project in VS Code (#1430)

๐Ÿ› Fixes

  • 155c8aa force minimum java 11 for quarkus init
  • 55b7833 Bump picocli to 4.6.3 in doc and src
  • 94c48c1 Bump Quarkus 1.11.0.Final -> 2.11.2.Final
  • d76a13d change kotlinc's extension to .bat on Windows (#1434)
  • ce7595c typo in README.md.tpl (#1431)

โ™ป๏ธ Changes

  • d28b4f3 more central role for Project
  • 253a1af moved build-related code from RunContext to Project
  • e62f430 introduced the concept of Project

๐Ÿงฐ Tasks

  • 2515783 put new project features behind --preview option

  • 9ae5d6f [minor] release

Contributors

We'd like to thank the following people for their contributions:
YeungYeah, Michael Bornholdt Nielsen, Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub, Fred Bricon

jbang - v0.97.0

Published by maxandersen about 2 years ago

Changelog

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.

๐Ÿš€ Features

  • 37b6781 add jbang-vscode to codium + add usability vscode settings (#1427)

๐Ÿ› Fixes

  • 3af66d9 info tools again generates info for nested sources (#1426)

  • 00f569c [minor] release

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub

jbang - v0.96.4

Published by maxandersen about 2 years ago

Changelog

--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.

๐Ÿงฐ Tasks

  • e870607 add deprecation message for export --native (#1422)

  • 7fb1f78 [patch] release

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub

jbang - v0.96.3

Published by maxandersen about 2 years ago

Changelog

Quick fix to have container images published properly.

๐Ÿ› Fixes

  • 6164750 formatting of docker readme

๐Ÿงฐ Tasks

  • 9a9562e add release overview

  • 3aca1a7 [patch] release
  • 8d20101 [patch] release

Contributors

We'd like to thank the following people for their contributions:
Max Rydahl Andersen

jbang - v0.96.1

Published by maxandersen about 2 years ago

Changelog

Important fixes to have the Windows install/script work with systems with spaces.
And a fix that avoids problem of duplicate maven repos.

๐Ÿ› Fixes

  • 9968fff now correctly handling duplicate repos (#1419)
  • a18554b Add splatting for passing arguments in Powershell scripts
  • 0eecfbf remove unnecessary quotations for java binary

๐Ÿงฐ Tasks

  • d6bf941 (deps) update java-properties to 0.0.5

๐Ÿ›  Build

  • 0b64aa1 fixed tests

  • 5f973da [patch] release
  • 074eb53 Better native export handing and native Window fix (#1406)

Contributors

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

jbang - v0.96.0

Published by maxandersen over 2 years ago

Lots of small bugfixes + stop generating class-path in jars that confuses graalvm native-image.

Changelog

๐Ÿ› Fixes

  • 5c5049d don't add Class-Path by default to JARs (#1398)
  • bfbb744 wrapper install now also copies jbang.ps1 (#1391)
  • b08c05b looking for compiler executables on Windows (#1395)
  • 077422d properly detect existing JDK on Macs
  • c89b4c5 fix problem with JDK paths containing spaces
  • 648fc02 fixed certain commands not validating input correctly (#1376)

โ™ป๏ธ Changes

  • 8d9582a fix typo in MarkdownSource.java
  • b4b5d32 small change to Builder API
  • 9fedad4 minor refactor of the IntegrationManager
  • 13df254 SourceSet no longer uses Source
  • 5455a89 minor refactor of RunContext
  • aadbb34 added manifest attributes to SourceSet
  • c1fb77e using less Optional
  • e2686a9 introduced BuildMixin

๐Ÿงฐ Tasks

  • 82d955c changed many File references to Path

๐Ÿ›  Build

  • a77e83a added tests for additional deps and cp

๐Ÿ“ Documentation

  • 1790790 minor update to PS1 script docs
  • d7c2a77 Updating Integration documentation (#1380)
  • 49a907e Updating Integration documentation (#1380)

  • a230f53 [minor] release
  • 5b5e364 Also reword //JAVA_OPTS to //JAVA_OPTIONS
  • 4fe2268 Small typo when referring to JAVAC_OPTIONS
  • 35056e8 Add test with --fresh and --repos

Contributors

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

jbang - v0.95.0

Published by maxandersen over 2 years ago

Changelog

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!

๐Ÿš€ Features

  • 902c8cb --sources and --files can now refer to directories
  • 023d820 //FILES now supports globbing and new --resources option
  • cd6a7eb added --available to jdk list
  • 81ed889 add in-progress bootstrap.sh to build jbang with jbang

๐Ÿ› Fixes

  • 8489101 make tests work on Windows
  • b880866 sub folders are now properly handled for globbed resources
  • 94bee92 inclusion of all resources
  • 8057fba remove todo
  • 26b7688 export can now build jbang with jbang
  • 207ca62 make aliases work with --repos (#1372)
  • 2d8e343 aliases now correctly added
  • 07e99c8 --sources now handle comma separated input (#1365)
  • f526a7d can now use globbing for --sources
  • d05dced move away from java.io.File to Path/Files

โ™ป๏ธ Changes

  • 411507d extracted CLI source options into a mixin
  • 9dc4741 --resource/-r are now --files/-f
  • 95adbfd removed Vendor enum
  • cf0b6c1 clean-up of the JdkManager code
  • 047f51a remove ability to set Jdk release

๐Ÿงฐ Tasks

  • d418f2a slightly improved error message when using globbing
  • 08f0b99 minor code cleanup
  • 38fd9a0 fix typo in configuration.adoc (#1366)

  • a4e7e56 [minor] release
  • fd9ff74 fix options

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Ikko Ashimine, Max Rydahl Andersen, GitHub

jbang - v0.94.0

Published by maxandersen over 2 years ago

Changelog

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

๐Ÿš€ Features

  • 1a45a50 improve maven repo shorthand and logging (#1360)
  • 60b7c5b Set Maven update policy to ALWAYS when --fresh is used

โ™ป๏ธ Changes

  • acf4146 turned isRunCommand into isMainRequired

  • 2a67ca5 [minor] release
  • ac0b344 Allow no main if not non-interactive(batch) run

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Jeremie Bresson, Max Rydahl Andersen, GitHub, andreaTP

jbang - v0.93.0

Published by maxandersen over 2 years ago

Changelog

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.

๐Ÿš€ Features

  • 6714be2 better error handling for //FILES (#1337)

๐Ÿ› Fixes

  • 59b5483 do not use @file with jshell. Fixes #1349 (#1352)
  • 018acde add sources to export (#1348)
  • 5c8094c ignore dependencies without GVA for integration (#1350)
  • 0397de4 Fixed problem with merging old PR #1271
  • c62087c some errors in alias documentation page (#1329)
  • 3f01dc8 Run locally with 'act' fails (jbangdev/jbang-action#28) (#1328)

๐Ÿงฐ Tasks

  • e7391c1 add explicit cast
  • 0750e62 switch code coverage to informational only
  • 7d6b632 fix typo in StrictParameterPreprocessor.java (#1333)

๐Ÿ›  Build

  • d2b246d add a test with a version range
  • 7856810 added docker compose file for testing proxy (#1339)

๐Ÿ“ Documentation

  • efcf18c add andreaTP as a contributor for code (#1351)

  • 0f53f8f [minor] release
  • b87b59e docs:fix markdown example (#1326)
  • 07a9449 docs:fix markdown example

Contributors

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]

jbang - v0.92.2

Published by maxandersen over 2 years ago

Changelog

Fixed a bug that caused (Quarkus) external Integration to fail on Java 16+.

๐Ÿ› Fixes

  • e61fcb4 upgrade gson to avoid breaking quarkus integration (#1317)

๐Ÿ›  Build

  • 3bb37cc force ext integration
  • 07b49e6 run only itests when feasible
  • 4936280 fail-fast off
  • 0a7b798 proper external ci test
  • 7c48421 dont enable gradle cache when not building with cache
  • 421a978 add java 17 and 18 runs
  • eb98460 add java 17 and 18 runs

  • bc68aca [patch] release
  • 662a75a Revert "Revert "fall back to TTY when asking for input on Linux/Mac (#1312)""
  • 211f020 Update copyright year to 2022 (#1315)

Contributors

We'd like to thank the following people for their contributions:
Claus Ibsen, Max Rydahl Andersen, GitHub

jbang - v0.92.1

Published by maxandersen over 2 years ago

Changelog

Had to revert zero install changes to avoid app install bug.

  • 048a68b [patch] release
  • ef580a7 Revert ""zero" install now lives up to its name (#1219)"
  • 9397a94 Revert "fall back to TTY when asking for input on Linux/Mac (#1312)"

Contributors

We'd like to thank the following people for their contributions:
Max Rydahl Andersen

jbang - v0.92.0

Published by maxandersen over 2 years ago

Changelog

This time with a mixed bag of features/improvements:

Console trust and "zero" install

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.

Integrations can run externally

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.

Allow aliases for //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!

๐Ÿš€ Features

  • ea20eff "zero" install now lives up to its name (#1219)
  • d942ada fall back to TTY when asking for input on Linux/Mac (#1312)
  • b44d783 enable integrations to run externally (#1290)
  • d3e726c allow aliases for //SOURCES (#1287)
  • c032ce2 don't ask for trust when resource is cached (#1291)

๐Ÿ› Fixes

  • e379591 fixed problem --deps and //REPOS (#1296)
  • 2d0ecd4 updated to latest java-properties (#1307)
  • 82e03f8 give proper error when -s file is missing (#1308)
  • 6337f4e don't copy classpath files more than once (#1300)
  • 97cd36d add missing contributors
  • 3ff4446 add code for manikmagar

๐Ÿงฐ Tasks

  • b259d74 make codecov less critical

๐Ÿ“ Documentation

  • 8a67177 Minor updates to installation pre-instructions (#1286)

Contributors

We'd like to thank the following people for their contributions:
Manik Magar, Tako Schotanus, Max Rydahl Andersen, GitHub

jbang - v0.91.0

Published by maxandersen over 2 years ago

Changelog

Buckle up - this is a fun release enabling some long-awaited mythical features!

  • Aliases for sources: cat logs.txt | jbang -s prelude@maxandersen -c '$$(l -> l.s(2))'
  • Websites as implicit catalog jbang [email protected]
  • Custom JDK Install: j! jdk install 18 $(sdk home java 18-open)

Details below:

Use of aliases for sources

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.

Websites as implicit catalog

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.

Install of custom JDK's

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)'

๐Ÿš€ Features

  • 64d7a27 enable jbang [email protected] and jbang tree@https:/jbang.dev (#1274)
  • b9c4b1b Made --sources script@repo work (#1283)
  • c8bcd40 add jbang jdk install (#1252)

๐Ÿ› Fixes

  • 2dceffb fixed problem with additional sources and aliases (#1284)
  • 056ca3b properly quote edit command on Windows (#1279)
  • 8a516bb some minor Jshell fixes (#1278)
  • 4ffc15f no longer throws NPE for config list (#1276)
  • 238ef90 jbang alias list and jbang alias add prints/add empty propertiesโ€ฆ (#1273)

โ™ป๏ธ Changes

  • 205d5bf Big reorg for handling sources (#1272)

Contributors

We'd like to thank the following people for their contributions:
Tako Schotanus, Max Rydahl Andersen, GitHub, Pierre-Yves Fourmond, Nรกndor Holozsnyรกk

jbang - v0.90.2

Published by maxandersen over 2 years ago

Changelog

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.

๐Ÿ› Fixes

  • 99ed4b8 support M1 initial macs java downloads (#1269)
  • ef36242 do not trust nor install editor by default (#1262)
  • 81fa1f6 upgrade to latest gradle plugin (#1251)

๐Ÿ“ Documentation

  • fd86798 Make explicit why groovy is needed (#1270)
  • 5f903c5 Use reload4j in the example instead of log4j (#1266)

  • b87d386 [patch] bugfix

Contributors

We'd like to thank the following people for their contributions:
Chromico Rek, Max Rydahl Andersen, GitHub, Jรฉrรฉmie Bresson

Package Rankings
Top 6.73% on Proxy.golang.org