Skip to content

Remove global metadata/index.json file and its usage#983

Merged
jormundur00 merged 1 commit intomasterfrom
jormundur00/global-index-removal
Feb 11, 2026
Merged

Remove global metadata/index.json file and its usage#983
jormundur00 merged 1 commit intomasterfrom
jormundur00/global-index-removal

Conversation

@jormundur00
Copy link
Copy Markdown
Member

What does this PR do?

In this PR we remove the global index.json file located at metadata/index.json to simplify new metadata addition (so we only need to create/maintain one index.json file located at metadata/groupId/artifactId/index.json per library artifact).

To do this, we move the allowed-packages and requires fields to the inner index.json, as this is data that only the global one had previously. As the module field was used to map between the global and inner index files, we remove this field as it was redundant (the information it keeps can always be resolved from the inner-index's path). All library metadata resolution is now based on file paths (so every library is strictly in metadata/<groupId>/<artifactId>). The scaffold and other tasks which generate these metadata directories have also been updated accordingly to match the new format.

As these changes include relatively major changes to the index structure, the remaining schema version was bumped from 1.0.0 to 2.0.0.

As running changes in this PR depend on the buildtools PR which adds support for the removal of the metadata/index.json file, and this PR depends on buildtools working with the new format to successfully pass CI, the merge/release process of these PRs should have the following order:

  1. This PR should be merged first (running CI on the branch of the buildtools PR to complete successfully),
  2. The next reachability metadata release should be dispatched so that buildtools can use it in their corresponding PR,
  3. The buildtools PR should then include the bump to this new reachability metadata version and get merged ASAP,
  4. This repository's CI will work on the latest SNAPSHOT of buildtools until the new NBT release is released (which should be scheduled as soon as the buildtools PR is merged),
  5. We open a follow-up PR here to use the newest release of buildtools and no longer use snapshots in the CI.

Fixes: #847

groupDirs.filter(Files::isDirectory).forEach(g -> {
String gName = g.getFileName().toString();
// Filter by group if provided
if (groupId != null && !groupId.equals(gName)) return;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can groupId be null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groupId and artifactId can be null when using coordinates such as -Pcoordinates=all. In those cases, nothing gets filtered, so all metadata directories are added to dirs.

artifactDirs.filter(Files::isDirectory).forEach(a -> {
String aName = a.getFileName().toString();
// Filter by artifact if provided
if (artifactId != null && !artifactId.equals(aName)) return;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question for artifactId.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in the groupId comment above.

if (library.containsKey("directory")) {
dirs.add((String) library.get("directory"));
}
if (library.containsKey("requires")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the changed code you removed adding directories, which are present in the requires field. Is this intentional? We should probably still parse requires?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this offline and decided that parsing requires here is redundant. We already parse it on native build tools when building the classpath (deciding what metadata to include), and adding it here does functionally nothing.

if (testedVersions == null) continue;

// Derive group/artifact from directory path (index is per artifact)
String g = fullDir.getParent().getFileName().toString();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more elegant approach?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it as it is for now, as I don't see a much more elegant way to do this that wouldn't break semantics.

testedVersions,
null
null, // skipped-versions
null, // allowed-packages
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that allowed-packages and requires are fields in each version entry, it's a bit tricky deciding what should be their values when entry is automatically generated. Probably best solution would be to copy that information from the previous latest version.

null // requires
);
entries.addFirst(newEntry);
entries.add(0, newEntry);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can revert this change.

Object ap = entry.get("allowed-packages");
if (ap != null) {
if (ap instanceof List) {
return (List<String>) ap;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a potential problem if allowed-packages can differ between versions. Can this happen?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Since we have the metadata-version here (which uniquely distinguishes an index.json entry), we can retrieve a specific versions allowed-packages here. Fixed.

@jormundur00 jormundur00 force-pushed the jormundur00/global-index-removal branch from b69e7a2 to d106a72 Compare February 10, 2026 13:55
@jormundur00 jormundur00 force-pushed the jormundur00/global-index-removal branch from d106a72 to 2bc2db2 Compare February 10, 2026 13:57
@jormundur00 jormundur00 merged commit 6090e52 into master Feb 11, 2026
63 checks passed
jormundur00 added a commit that referenced this pull request Feb 18, 2026
jormundur00 added a commit that referenced this pull request Feb 18, 2026
jormundur00 added a commit that referenced this pull request Feb 18, 2026
jormundur00 added a commit that referenced this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Remove global metadata index.json from the repository

3 participants