|
| 1 | +--- |
| 2 | +slug: proto-v0.59 |
| 3 | +title: proto v0.59 - Java support, a new version parser, improved OpenTelemetry, and more |
| 4 | +authors: [milesj] |
| 5 | +tags: [java, jdk, jre, foojay, versions, semver, calver, scopes, otel] |
| 6 | +image: ./img/proto/v0.59.png |
| 7 | +--- |
| 8 | + |
| 9 | +In this release, we're shipping one of our most requested tools to date, Java, alongside a |
| 10 | +ground-up rewrite of our version parsing layer that makes it possible. |
| 11 | + |
| 12 | +<!--truncate--> |
| 13 | + |
| 14 | +## Java support |
| 15 | + |
| 16 | +Java has been requested since proto's early days, but between the sheer number of vendors, |
| 17 | +distributions, and packaging formats, it was never a simple plugin to write. Until now, the closest |
| 18 | +workaround was the `asdf` backend, which doesn't work on Windows. That changes today, as proto now |
| 19 | +ships with a built-in Java plugin, powered by the [foojay.io Disco API](https://foojay.io/)! |
| 20 | + |
| 21 | +The plugin is available through 3 tool identifiers: `java` or `jdk` for the full development kit, |
| 22 | +and `jre` for the slimmer runtime-only package. |
| 23 | + |
| 24 | +```shell |
| 25 | +$ proto install java |
| 26 | +$ proto install jre 21 |
| 27 | +``` |
| 28 | + |
| 29 | +On top of installing Java itself (with shims for `java`, `javac`, and `jar`), the plugin will |
| 30 | +detect versions from `.java-version` and `.sdkmanrc` files (easing migration from other version |
| 31 | +managers), and will export `JAVA_HOME` for |
| 32 | +[activated shells](/docs/proto/commands/activate). |
| 33 | + |
| 34 | +### Choosing a distribution |
| 35 | + |
| 36 | +Java isn't a single tool with a single publisher — it's an ecosystem of vendors, each shipping |
| 37 | +their own builds. By default, the plugin installs the `openjdk` distribution (Oracle OpenJDK |
| 38 | +builds), but you can choose another by prefixing the version with a scope: |
| 39 | + |
| 40 | +```toml title=".prototools" |
| 41 | +jdk = "temurin-21" |
| 42 | +``` |
| 43 | + |
| 44 | +Over 30 distributions are supported through the Disco API, including Temurin, Zulu, Corretto, |
| 45 | +Liberica, GraalVM, Microsoft, SapMachine, Semeru, Kona, Dragonwell, and more. Common |
| 46 | +[SDKMAN!](https://sdkman.io/) shorthands (`tem`, `amzn`, `librca`, etc) are also accepted, both in |
| 47 | +version specifications and in `.sdkmanrc` files. |
| 48 | + |
| 49 | +And lastly, if you need early access builds instead of general availability, or want to route |
| 50 | +through a self-hosted Disco API, the plugin supports both: |
| 51 | + |
| 52 | +```toml title=".prototools" |
| 53 | +[tools.java] |
| 54 | +api-url = "https://custom-foojay.hosted.com/disco/v3.0" |
| 55 | +release-type = "ea" |
| 56 | +``` |
| 57 | + |
| 58 | +## A new version specification parser |
| 59 | + |
| 60 | +Since its inception, proto has parsed versions with the [`semver`](https://crates.io/crates/semver) |
| 61 | +crate, wrapped in layers of regex and string munging to squeeze in everything that crate wasn't |
| 62 | +designed for — calendar versions, partial versions, and tool-specific quirks. This approach has |
| 63 | +been a constant source of edge cases, so in this release, we threw it all away and wrote a custom |
| 64 | +grammar-based parser designed for how proto actually consumes versions. |
| 65 | + |
| 66 | +What does this unlock? For starters, first-class |
| 67 | +[version scopes](/docs/proto/tool-spec#version-scopes): a named prefix attached to a version or |
| 68 | +requirement, such as `openjdk-21.0.2`, `zulu-26`, or `pypy-2.1`. Scopes are what power |
| 69 | +Java distributions above, are passed through the WASM plugin API for any plugin to consume, and |
| 70 | +remote version lists are now cached per scope. |
| 71 | + |
| 72 | +Beyond scopes, the new parser brings consistency to both versioning schemes: |
| 73 | + |
| 74 | +- [Semantic versions](/docs/proto/tool-spec#semantic-versions) and |
| 75 | + [calendar versions](/docs/proto/tool-spec#calendar-versions) now support the same features: |
| 76 | + pre-releases, build metadata (`+123`), leading `v` prefixes, and |
| 77 | + [requirements and ranges](/docs/proto/tool-spec#requirements-and-ranges) (`^`, `~`, comparison |
| 78 | + operators, wildcards, `&&`, `||`). |
| 79 | +- Calendar versions are parsed with dash separators exclusively, so ambiguous values like `24.12` |
| 80 | + are always treated as semantic versions. |
| 81 | +- Better error messages when a version fails to parse, instead of cryptic `semver` errors. |
| 82 | + |
| 83 | +## OpenTelemetry improvements |
| 84 | + |
| 85 | +We introduced [OpenTelemetry support](./proto-v0.58#opentelemetry-support) in the last release, |
| 86 | +with traces, metrics, and logs exported over gRPC. In this release, we've expanded the |
| 87 | +implementation: |
| 88 | + |
| 89 | +- Added experimental HTTP transport support, enabled with |
| 90 | + `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`. |
| 91 | +- Added experimental TLS support for both HTTP and gRPC transports. |
| 92 | +- Added support for the standard `OTEL_SERVICE_NAME`, `OTEL_*_EXPORTER`, |
| 93 | + `OTEL_EXPORTER_OTLP_*_PROTOCOL`, and `OTEL_EXPORTER_OTLP_*_ENDPOINT` environment variables |
| 94 | + (including their signal-specific variants). |
| 95 | + |
| 96 | +If your environment already configures OTEL exporters through these variables, proto will now |
| 97 | +respect them out of the box. |
| 98 | + |
| 99 | +## Smarter `PATH` handling in shims |
| 100 | + |
| 101 | +This release fixes two long-standing `PATH` issues in `proto run` and shim executions: |
| 102 | + |
| 103 | +- When a tool requires another tool to function (npm requires node), the required tool's paths were |
| 104 | + placed _before_ the paths of the tool being ran. For example, `npm run` scripts that execute |
| 105 | + `npm` would resolve node's bundled npm, instead of the npm version managed by proto. The tool |
| 106 | + being ran now takes precedence. |
| 107 | +- When falling back to a global executable on `PATH`, proto could recursively execute forever if |
| 108 | + that executable was itself a proto shim from _another store_ (typically caused by `HOME` or |
| 109 | + `PROTO_HOME` changing, or symlinked paths). We now skip shims from foreign stores during the |
| 110 | + lookup, and detect and error on the loop instead of hanging. |
| 111 | + |
| 112 | +## Breaking changes |
| 113 | + |
| 114 | +### Calendar version build segments |
| 115 | + |
| 116 | +As part of the new parser, the proto-specific "micro" build segment (dot or underscore separated) |
| 117 | +has been removed from calendar versions. Use standard build metadata instead. |
| 118 | + |
| 119 | +``` |
| 120 | +2024-02-26.123 -> 2024-02-26+123 |
| 121 | +2024-02-26_123-alpha.0 -> 2024-02-26-alpha.0+123 |
| 122 | +``` |
| 123 | + |
| 124 | +## Other changes |
| 125 | + |
| 126 | +View the [official release](https://github.com/moonrepo/proto/releases/tag/v0.59.0) for a full |
| 127 | +list of changes. |
| 128 | + |
| 129 | +- Added `bzip2`, `xz`, and `z` codec support for self-compressed binaries (not packed with tar or |
| 130 | + zip), as well as `.tar.Z` (LZW) archive support. |
| 131 | +- Updated archive unpacking to be streamed when applicable, reducing memory usage. |
| 132 | +- Updated offline detection to take AI agent firewall policies into account. If networking is |
| 133 | + disabled, we mark as offline, otherwise if it's open or filtered, we mark it as online. |
| 134 | +- Fixed an issue where `proto clean` would not recursively clean certain directories. |
| 135 | +- Fixed an issue where we didn't check for an internet connection when downloading a plugin from an |
| 136 | + OCI registry or GitHub. |
| 137 | +- Updated Rust to v1.97. |
0 commit comments