Ejemplo n.º 1
0
  @Test
  public void overrideVersion() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "overrideVersion.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("1.0");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
Ejemplo n.º 2
0
  @Test
  public void mergeSettings() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "mergeSettings.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("0.9");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
Ejemplo n.º 3
0
  @Test
  public void registerNewPlugin() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "registerNewPlugin.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    assertThat(mavenPlugin).isNotNull();
    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("1.0");
  }
Ejemplo n.º 4
0
  @Test
  public void keepPluginDependencies() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "keepPluginDependencies.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");
    assertThat(plugin.getDependencies().size()).isEqualTo(1);
  }
Ejemplo n.º 5
0
  @Test
  public void getConfigurationFromReport() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "getConfigurationFromReport.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    assertThat(pom.getBuildPlugins().size()).isEqualTo(1);
    assertThat(pom.getReportPlugins().size()).isEqualTo(0);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("1.0");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
Ejemplo n.º 6
0
  @Test
  public void doNotOverrideVersionFromPluginManagementSection() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "overridePluginManagementSection.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");

    Plugin pluginManagement =
        MavenUtils.getPlugin(pom.getPluginManagement().getPlugins(), "mygroup", "my.artifact");
    assertThat(pluginManagement).isNull();
  }