Hi Hervé,

this brought me into the right direction...

Thanks.
Karl Heinz Marbaise
On 10/9/15 12:30 AM, Hervé BOUTEMY wrote:
Hi,

ModelMerger is the parent class of every model mergers: AFAIK, it does not
merge configuration of plugins

if you want to test plugins configuration merge, you'll have to test either
DefaultInheritanceAssembler.InheritanceModelMerger if you want to test
inheritance merge or DefaultPluginManagementInjector.ManagementModelMerger, if
you want to test plugin management injection

Regards,

Hervé

Le mercredi 7 octobre 2015 23:13:00 Karl Heinz Marbaise a écrit :
Hi,

currently i'm trying to understand how to create unit/integration tests
for the ModelMerger / MavenModelMerger part..which does things like
merging the configuration of plugins...

I have found a Test:

https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob_plain;f=maven-mod
el-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.j
ava;hb=HEAD

which looks like what i need....Ok i enhanced it like the following:



      private Model readPomModel( String resource )
          throws IOException, XmlPullParserException
      {
          InputStream resourceAsStream =
this.getClass().getResourceAsStream( resource );

          MavenXpp3Reader reader = new MavenXpp3Reader();
          Model read = reader.read( resourceAsStream );
          return read;
      }

      @Test
      public void testMergeModel_XXX()
          throws IOException, XmlPullParserException
      {
          Model sourceModel = readPomModel(
"/poms/merge/plugin-pom-parent.xml" );
          Model targetModel = readPomModel(
"/poms/merge/plugin-pom-child.xml" );

          ConfigurationContainer target = new ConfigurationContainer();
          target.setConfiguration(
targetModel.getBuild().getPlugins().get( 0 ).getConfiguration() );

          ConfigurationContainer source = new ConfigurationContainer();
          source.setConfiguration(
sourceModel.getBuild().getPlugins().get( 0 ).getConfiguration() );

          modelMerger.merge( targetModel, sourceModel, true, null );

          System.out.println( "Configuration parent:"
              + sourceModel.getBuild().getPlugins().get( 0
).getConfiguration().toString() );
          System.out.println( "Configuration child:"
              + targetModel.getBuild().getPlugins().get( 0
).getConfiguration().toString() );

      }


But my problem at the moment is that the configuration aren't merged in
any way as the default let me think... they should...

Can someone give me a tip where to go further into ? Or what i'm doing
wrong ?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to