Remove global metadata/index.json file and its usage#983
Conversation
| groupDirs.filter(Files::isDirectory).forEach(g -> { | ||
| String gName = g.getFileName().toString(); | ||
| // Filter by group if provided | ||
| if (groupId != null && !groupId.equals(gName)) return; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Same question for artifactId.
There was a problem hiding this comment.
Explained in the groupId comment above.
| if (library.containsKey("directory")) { | ||
| dirs.add((String) library.get("directory")); | ||
| } | ||
| if (library.containsKey("requires")) { |
There was a problem hiding this comment.
In the changed code you removed adding directories, which are present in the requires field. Is this intentional? We should probably still parse requires?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Is there a more elegant approach?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
You can revert this change.
| Object ap = entry.get("allowed-packages"); | ||
| if (ap != null) { | ||
| if (ap instanceof List) { | ||
| return (List<String>) ap; |
There was a problem hiding this comment.
This could be a potential problem if allowed-packages can differ between versions. Can this happen?
There was a problem hiding this comment.
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.
b69e7a2 to
d106a72
Compare
d106a72 to
2bc2db2
Compare
)" This reverts commit 6090e52.
)" This reverts commit 6090e52.
)" This reverts commit 6090e52.
What does this PR do?
In this PR we remove the global
index.jsonfile located atmetadata/index.jsonto simplify new metadata addition (so we only need to create/maintain oneindex.jsonfile located atmetadata/groupId/artifactId/index.jsonper library artifact).To do this, we move the
allowed-packagesandrequiresfields to the innerindex.json, as this is data that only the global one had previously. As themodulefield 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 inmetadata/<groupId>/<artifactId>). Thescaffoldand 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.0to2.0.0.As running changes in this PR depend on the buildtools PR which adds support for the removal of the
metadata/index.jsonfile, 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:Fixes: #847