Skip to content

Commit

Permalink
[3.9.x][MNG-8106] Fix metadata merge (#1480)
Browse files Browse the repository at this point in the history
As currently if given metadata serves multiple roles (G, A or V level), data loss occurs.

---

https://issues.apache.org/jira/browse/MNG-8106
  • Loading branch information
cstamas authored Apr 25, 2024
1 parent 587e99b commit bc52363
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'temurin'
distribution: 'zulu'
cache: 'maven'

- name: Build with Maven
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
distribution: 'zulu'
cache: 'maven'

- name: Running integration tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ protected void merge(Metadata recessive) {

metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
}
// just carry-on as-is
if (!recessive.getPlugins().isEmpty()) {
metadata.setPlugins(new ArrayList<>(recessive.getPlugins()));
}

artifacts.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ private static Metadata createRepositoryMetadata(PluginInfo pluginInfo) {
protected void merge(Metadata recessive) {
List<Plugin> recessivePlugins = recessive.getPlugins();
List<Plugin> plugins = metadata.getPlugins();
if (!plugins.isEmpty()) {
if (!recessivePlugins.isEmpty() || !plugins.isEmpty()) {
LinkedHashMap<String, Plugin> mergedPlugins = new LinkedHashMap<>();
recessivePlugins.forEach(p -> mergedPlugins.put(p.getPrefix(), p));
plugins.forEach(p -> mergedPlugins.put(p.getPrefix(), p));
metadata.setPlugins(new ArrayList<>(mergedPlugins.values()));
}
// just carry-on as-is
if (recessive.getVersioning() != null) {
metadata.setVersioning(recessive.getVersioning());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ protected void merge(Metadata recessive) {
if (!legacyFormat) {
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
}
// just carry-on as-is
if (!recessive.getPlugins().isEmpty()) {
metadata.setPlugins(new ArrayList<>(recessive.getPlugins()));
}
}

private static int getBuildNumber(Metadata metadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ protected void merge(Metadata recessive) {
versions.addAll(versioning.getVersions());
versioning.setVersions(new ArrayList<>(versions));
}
// just carry-on as-is
if (!recessive.getPlugins().isEmpty()) {
metadata.setPlugins(new ArrayList<>(recessive.getPlugins()));
}
}

public Object getKey() {
Expand Down

0 comments on commit bc52363

Please sign in to comment.