mirror of https://github.com/apache/maven.git
[MNG-8106] Fix metadata merge (#1481)
As currently if given metadata serves multiple roles (G, A or V level), data loss occurs. --- https://issues.apache.org/jira/browse/MNG-8106
This commit is contained in:
parent
31d2dc1815
commit
854589b131
|
@ -113,6 +113,11 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
|
||||
metadata = metadata.withVersioning(metadata.getVersioning().withSnapshotVersions(versions.values()));
|
||||
|
||||
// just carry-on as-is
|
||||
if (recessive.getPlugins() != null && !recessive.getPlugins().isEmpty()) {
|
||||
metadata = metadata.withPlugins(new ArrayList<>(recessive.getPlugins()));
|
||||
}
|
||||
|
||||
artifacts.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,12 +74,16 @@ final class PluginsMetadata extends MavenMetadata {
|
|||
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 = metadata.withPlugins(mergedPlugins.values());
|
||||
}
|
||||
// just carry-on as-is
|
||||
if (recessive.getVersioning() != null) {
|
||||
metadata = metadata.withVersioning(recessive.getVersioning());
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.nio.file.Path;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -130,6 +131,11 @@ final class RemoteSnapshotMetadata extends MavenSnapshotMetadata {
|
|||
}
|
||||
|
||||
metadata = metadata.withVersioning(metadata.getVersioning().withSnapshotVersions(versions.values()));
|
||||
|
||||
// just carry-on as-is
|
||||
if (recessive.getPlugins() != null && !recessive.getPlugins().isEmpty()) {
|
||||
metadata = metadata.withPlugins(new ArrayList<>(recessive.getPlugins()));
|
||||
}
|
||||
}
|
||||
|
||||
private static int getBuildNumber(Metadata metadata) {
|
||||
|
|
|
@ -90,6 +90,11 @@ final class VersionsMetadata extends MavenMetadata {
|
|||
}
|
||||
|
||||
metadata = metadata.withVersioning(versioning.build());
|
||||
|
||||
// just carry-on as-is
|
||||
if (recessive.getPlugins() != null && !recessive.getPlugins().isEmpty()) {
|
||||
metadata = metadata.withPlugins(new ArrayList<>(recessive.getPlugins()));
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKey() {
|
||||
|
|
|
@ -114,6 +114,11 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
|
||||
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
|
||||
|
||||
// just carry-on as-is
|
||||
if (!recessive.getPlugins().isEmpty()) {
|
||||
metadata.setPlugins(new ArrayList<>(recessive.getPlugins()));
|
||||
}
|
||||
|
||||
artifacts.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,12 +75,17 @@ final class PluginsMetadata extends MavenMetadata {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
@ -128,6 +128,11 @@ final class RemoteSnapshotMetadata extends MavenSnapshotMetadata {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -84,6 +84,11 @@ final class VersionsMetadata extends MavenMetadata {
|
|||
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() {
|
||||
|
|
Loading…
Reference in New Issue