Java Code Examples for org.apache.maven.artifact.repository.metadata.Metadata#addPlugin()

The following examples show how to use org.apache.maven.artifact.repository.metadata.Metadata#addPlugin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryMetadataMerger.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Merges "right" plugins into "left", the instances are mutated.
 */
private void mergePlugins(final Metadata left, final Metadata right) {
  nullElementFilter(left.getPlugins());
  nullElementFilter(right.getPlugins());
  for (Plugin plugin : right.getPlugins()) {
    boolean found = false;
    for (Plugin preExisting : left.getPlugins()) {
      if (Objects.equals(preExisting.getArtifactId(), plugin.getArtifactId())
          && Objects.equals(preExisting.getPrefix(), plugin.getPrefix())) {
        found = true;
        preExisting.setName(plugin.getName());
        break;
      }
    }
    if (!found) {
      Plugin newPlugin = new Plugin();
      newPlugin.setArtifactId(plugin.getArtifactId());
      newPlugin.setPrefix(plugin.getPrefix());
      newPlugin.setName(plugin.getName());
      left.addPlugin(newPlugin);
    }
  }
}
 
Example 2
Source File: RepositoryMetadataMergerTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private Metadata g(final String... pluginNames)
{
  final Metadata m = new Metadata();
  for (String pluginName : pluginNames) {
    m.addPlugin(plugin(pluginName));
  }
  return m;
}