Java Code Examples for org.codehaus.plexus.configuration.PlexusConfiguration#toString()

The following examples show how to use org.codehaus.plexus.configuration.PlexusConfiguration#toString() . 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: MojoConfigurationMergerTest.java    From takari-lifecycle with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration() throws Exception {
  InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml");
  assertNotNull(is);
  PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8"));
  String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor);
  assertEquals("We expect the goal name to be 'jar'", "jar", goal);
  MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
  PlexusConfiguration defaultMojoConfiguration = mojoDescriptor.getMojoConfiguration();
  System.out.println(defaultMojoConfiguration);

  PlexusConfiguration configurationFromMaven = builder("configuration") //
      .es("jar") //
      .es("sourceJar").v("true").ee() //
      .ee() //
      .buildPlexusConfiguration();

  PlexusConfiguration mojoConfiguration = merger.extractAndMerge(goal, configurationFromMaven, defaultMojoConfiguration);

  String xml = mojoConfiguration.toString();
  assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
  assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
  assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
  assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
  assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}
 
Example 2
Source File: MojoConfigurationMergerTest.java    From takari-lifecycle with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void plexusConfigurationMerging() throws Exception {

  PlexusConfiguration mojoConfigurationFromPom = builder("configuration") //
      .es("sourceJar").v("true").ee() //
      .buildPlexusConfiguration();

  PlexusConfiguration defaultMojoConfiguration = builder("configuration") //
      .entry("classesDirectory", "java.io.File", "${project.build.outputDirectory}") //
      .entry("reactorProjects", "java.util.List", "${reactorProjects}") //
      .entry("souceJar", "boolean", "${sourceJar") //
      .buildPlexusConfiguration();

  PlexusConfiguration mojoConfiguration = merger.mergePlexusConfiguration(mojoConfigurationFromPom, defaultMojoConfiguration);

  String xml = mojoConfiguration.toString();
  assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
  assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
  assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
  assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
  assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}