Commit dce593f
feat: implement version pinning for JBang aliases
Implements version pinning syntax for aliases using alias:version@catalog
format, allowing users to specify versions at invocation time without
modifying catalog files.
Features:
- Version parsing: Parse alias:version@catalog syntax in Alias.merge()
- Distinguish GAVs from alias:version using colon counting and dot detection
- Store version in transient requestedVersion field
- Validate empty version/alias names and invalid formats
- Property replacement: Support ${jbang.app.version:default} in scriptRefs
- Uses ProjectBuilder.getContextProperties() for full property context
- Property replacement takes precedence over automatic replacement
- Allows: jbang -Dmyprop=xyz myalias:1.2 to use myprop in properties
- Maven GAV version replacement
- Handle full GAV: group:artifact:version:classifier@type
- Handle lenient GAV: group:artifact (appends version)
- Preserve classifier and type when replacing version
- Git URL version replacement for GitHub, GitLab, Bitbucket
- GitHub: /blob/REF/ and raw.githubusercontent.com/org/repo/REF/
- GitLab: /-/blob/REF/ and /-/raw/REF/
- Bitbucket: /src/REF/ and /raw/REF/
- Safe version substitution with Matcher.quoteReplacement()
- Catalog reference version replacement
- Pattern: alias@org/repo/REF → alias@org/repo/version
- Version propagates through alias chains
- Error handling: Hard errors when version specified but no pattern matches
Examples:
jbang mytool:1.5.0 # Pin version 1.5.0
jbang mytool:1.5.0@myorg # Pin version from catalog
jbang tool:v2.0@org/repo/main # Pin git-based catalog
Fixes #1979
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent ffae7d4 commit dce593f
4 files changed
Lines changed: 880 additions & 14 deletions
File tree
- docs/modules/ROOT/pages
- src
- main/java/dev/jbang/catalog
- test/java/dev/jbang/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
101 | 215 | | |
102 | 216 | | |
103 | 217 | | |
| |||
0 commit comments