Package org.apache.maven.artifact.repository.metadata

Examples of org.apache.maven.artifact.repository.metadata.Plugin


    if (oldPlugins.size() != plugins.size()) {
      return false;
    }

    for (int i = 0; i < oldPlugins.size(); i++) {
      Plugin oldPlugin = oldPlugins.get(i);

      if (!containPlugin(plugins, oldPlugin)) {
        return false;
      }
    }
View Full Code Here


    }

    if (path.endsWith("pom")) {
      // G
      if (model != null && model.getPackaging().equals("maven-plugin")) {
        Plugin plugin = new Plugin();

        plugin.setArtifactId(a);

        plugin.setPrefix(getPluginPrefix(a, path));

        if (!StringUtils.isEmpty(model.getName())) {
          plugin.setName(model.getName());
        }

        String gPath = "/" + g.replace('.', '/');

        if (gData.get(gPath) == null) {
View Full Code Here

          found = true;
        }
      }

      if (!found) {
        Plugin mappedPlugin = new Plugin();

        mappedPlugin.setArtifactId(plugin.getArtifactId());
        mappedPlugin.setPrefix(plugin.getPrefix());
        mappedPlugin.setName(plugin.getName());

        targetMetadata.addPlugin(mappedPlugin);

        changed = true;
      }
View Full Code Here

    Metadata md = readMavenMetadata(retrieveFile(inhouseRelease, "/com/mycom/group2/maven-metadata.xml"));

    Assert.assertEquals(2, md.getPlugins().size());

    for (Object o : md.getPlugins()) {
      Plugin plugin = (Plugin) o;

      if (plugin.getArtifactId().equals("maven-p1-plugin")) {
        Assert.assertEquals("Plugin P1", plugin.getName());
        Assert.assertEquals("p1", plugin.getPrefix());
      }
      else if (plugin.getArtifactId().equals("maven-p2-plugin")) {
        Assert.assertTrue(StringUtils.isEmpty(plugin.getName()));
        Assert.assertEquals("p2", plugin.getPrefix());
      }
      else {
        Assert.fail("The plugin '" + plugin.getArtifactId() + "' is incorrect");
      }
    }
  }
View Full Code Here

        assertThat(content, not(containsString("modelVersion")));
      }

    };
    Plugin plugin = new Plugin();
    plugin.setName("pName");
    plugin.setArtifactId("aid");
    plugin.setPrefix("pPrefix");
    helper.gData.put("/gid", Arrays.asList(plugin));

    GroupDirMetadataProcessor processor = new GroupDirMetadataProcessor(helper);
    processor.processMetadata("/gid");
  }
View Full Code Here

  public void testAddingPluginsDoesNotDuplicatesEntries()
      throws Exception
  {
    final Metadata md = new Metadata();
    {
      final Plugin plugin = new Plugin();
      plugin.setArtifactId("bar-maven-plugin");
      plugin.setPrefix("bar");
      plugin.setName("Bar plugin");
      md.addPlugin(plugin);
    }

    // new plugin addition
    {
      final Plugin plugin1 = new Plugin();
      plugin1.setPrefix("foo");
      plugin1.setArtifactId("foo-maven-plugin");
      plugin1.setName("Foo plugin");
      MetadataBuilder.changeMetadata(md, Collections.<MetadataOperation>singletonList(new AddPluginOperation(
          new PluginOperand(Version.V110, plugin1))));
    }
    assertThat("New plugin should be added!", md.getPlugins(), hasSize(2));
    assertThat(md.getPlugins().get(0).getPrefix(), equalTo("bar"));
    assertThat(md.getPlugins().get(0).getName(), equalTo("Bar plugin"));
    assertThat(md.getPlugins().get(1).getPrefix(), equalTo("foo"));
    assertThat(md.getPlugins().get(1).getName(), equalTo("Foo plugin"));

    // existing plugin addition
    {
      final Plugin plugin1 = new Plugin();
      plugin1.setPrefix("foo");
      plugin1.setArtifactId("foo-maven-plugin");
      plugin1.setName("The new Foo plugin");
      MetadataBuilder.changeMetadata(md, Collections.<MetadataOperation>singletonList(new AddPluginOperation(
          new PluginOperand(Version.V110, plugin1))));
    }
    assertThat("No new plugin should be added!", md.getPlugins(), hasSize(2));
    assertThat(md.getPlugins().get(0).getPrefix(), equalTo("bar"));
    assertThat(md.getPlugins().get(0).getName(), equalTo("Bar plugin"));
    assertThat(md.getPlugins().get(1).getPrefix(), equalTo("foo"));
    assertThat(md.getPlugins().get(1).getName(), equalTo("The new Foo plugin"));

    // existing plugin addition
    {
      final Plugin plugin1 = new Plugin();
      plugin1.setPrefix("bar");
      plugin1.setArtifactId("bar-maven-plugin");
      plugin1.setName("The new Bar plugin");
      MetadataBuilder.changeMetadata(md, Collections.<MetadataOperation>singletonList(new AddPluginOperation(
          new PluginOperand(Version.V110, plugin1))));
    }
    assertThat("No new plugin should be added!", md.getPlugins(), hasSize(2));
    assertThat(md.getPlugins().get(0).getPrefix(), equalTo("bar"));
    assertThat(md.getPlugins().get(0).getName(), equalTo("The new Bar plugin"));
    assertThat(md.getPlugins().get(1).getPrefix(), equalTo("foo"));
    assertThat(md.getPlugins().get(1).getName(), equalTo("The new Foo plugin"));

    // new plugin addition wrt plugin order, plugins are ordered by ArtifactID
    {
      final Plugin plugin1 = new Plugin();
      plugin1.setPrefix("alpha");
      plugin1.setArtifactId("alpha-maven-plugin");
      plugin1.setName("Alpha plugin");
      MetadataBuilder.changeMetadata(md, Collections.<MetadataOperation>singletonList(new AddPluginOperation(
          new PluginOperand(Version.V110, plugin1))));
    }
    assertThat("New plugin should be added!", md.getPlugins(), hasSize(3));
    assertThat(md.getPlugins().get(0).getPrefix(), equalTo("alpha"));
View Full Code Here

        Metadata repoMetadata = metadata.getMetadata();
        if ( repoMetadata != null )
        {
            for ( Iterator pluginIterator = repoMetadata.getPlugins().iterator(); pluginIterator.hasNext(); )
            {
                Plugin mapping = (Plugin) pluginIterator.next();

                String prefix = mapping.getPrefix();

                String artifactId = mapping.getArtifactId();

                org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin();

                plugin.setGroupId( metadata.getGroupId() );
View Full Code Here

     */
    private Plugin parsePlugin( XmlPullParser parser, boolean strict )
        throws IOException, XmlPullParserException
    {
        String tagName = parser.getName();
        Plugin plugin = new Plugin();
        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
        {
            String name = parser.getAttributeName( i );
            String value = parser.getAttributeValue( i );

            if ( name.indexOf( ':' ) >= 0 )
            {
                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
            }
            else
            {
                checkUnknownAttribute( parser, name, tagName, strict );
            }
        }
        java.util.Set parsed = new java.util.HashSet();
        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
            {
                plugin.setName( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "prefix", null, parsed ) )
            {
                plugin.setPrefix( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
            {
                plugin.setArtifactId( getTrimmedValue( parser.nextText() ) );
            }
            else
            {
                checkUnknownElement( parser, strict );
            }
View Full Code Here

        if ( ( metadata.getPlugins() != null ) && ( metadata.getPlugins().size() > 0 ) )
        {
            serializer.startTag( NAMESPACE, "plugins" );
            for ( Iterator iter = metadata.getPlugins().iterator(); iter.hasNext(); )
            {
                Plugin o = (Plugin) iter.next();
                writePlugin( o, "plugin", serializer );
            }
            serializer.endTag( NAMESPACE, "plugins" );
        }
        serializer.endTag( NAMESPACE, tagName );
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.repository.metadata.Plugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.