Skip to content

Commit

Permalink
Add support for default-for attribute
Browse files Browse the repository at this point in the history
This new index.json attribute is designed to allow more
flexible version matching to avoid breakage due to
switching on the latest version for untested ones.

It should have a `default-for` key and a regexp as a
string value, for example "1\\.0\\..*" which should
match versions like 1.0.0, 1.0.1, 1.0.2, etc.

Closes oracle#62
  • Loading branch information
sdeleuze committed Apr 28, 2023
1 parent 5553adb commit b712220
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ It should contain the following entries:
```json
[
{
"latest": false,
"metadata-version": "0.0.1",
"module": "org.example:library",
"tested-versions": [
Expand All @@ -106,8 +105,23 @@ The `override` flag allows to express the intent to exclude outdated builtin met
So, the metadata for `org.example:library:0.0.1` and `org.example:library:0.0.2` is located
at `metadata/org.example/library/0.0.1`.

Make sure that each supported version is listed in `tested-versions`, as that value is used in build tools to match
metadata to a specific library.
For entries without `"latest": true`, it is recommended to define the optional `default-for` key with a value containing
a regexp (Java format) matching the version pattern. For example, for the example above, the first entry could be:

```json
{
"metadata-version": "0.0.1",
"module": "org.example:library",
"tested-versions": [
"0.0.1",
"0.0.2"
],
"default-for": "0\\.0\\..*"
}
```

You can also list each supported version is listed in `tested-versions`, as that value is used in build tools to match
metadata to a specific library, but this is more likely to break when new versions are released.
Every metadata for a specific library version has a `index.json`. For this
example `metadata/org.example/library/0.0.1/index.json` would contain:

Expand Down
1 change: 1 addition & 0 deletions metadata/org.hibernate.orm/hibernate-core/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
{
"metadata-version": "6.1.1.Final",
"default-for": "6\\.1\\..*",
"module": "org.hibernate.orm:hibernate-core",
"tested-versions": [
"6.1.1.Final"
Expand Down

0 comments on commit b712220

Please sign in to comment.