@Test public void run_buildSpecifiedPlugins() { MavenProject project1 = mock(MavenProject.class); MavenProject project2 = mock(MavenProject.class); MavenProject project3 = mock(MavenProject.class); List<Plugin> pluginsBuild = new ArrayList<Plugin>(); List<Plugin> plugins1 = new ArrayList<Plugin>(); List<Plugin> plugins2 = new ArrayList<Plugin>(); List<Plugin> plugins3 = new ArrayList<Plugin>(); Plugin plugin1 = new Plugin(); Plugin plugin2 = new Plugin(); Plugin plugin3 = new Plugin(); pluginsBuild.add(plugin1); pluginsBuild.add(plugin2); pluginsBuild.add(plugin3); plugins1.add(plugin1); plugins2.add(plugin2); plugins3.add(plugin3); when(project1.getBuildPlugins()).thenReturn(pluginsBuild); when(project2.getBuildPlugins()).thenReturn(pluginsBuild); when(project3.getBuildPlugins()).thenReturn(pluginsBuild); Model model1 = mock(Model.class); Model model2 = mock(Model.class); Model model3 = mock(Model.class); when(project1.getOriginalModel()).thenReturn(model1); when(project2.getOriginalModel()).thenReturn(model2); when(project3.getOriginalModel()).thenReturn(model3); Build build1 = mock(Build.class); Build build2 = mock(Build.class); Build build3 = mock(Build.class); when(model1.getBuild()).thenReturn( build1 ); when(model2.getBuild()).thenReturn( build2 ); when(model3.getBuild()).thenReturn( build3 ); when(build1.getPlugins()).thenReturn(plugins1); when(build2.getPlugins()).thenReturn(plugins2); when(build3.getPlugins()).thenReturn(plugins3); when(project1.getParent()).thenReturn( project2 ); when(project2.getParent()).thenReturn( project3 ); when(project3.getParent()).thenReturn(null); Configurer configurer = new Configurer(); Set<Plugin> specifiedPlugins = configurer.buildSpecifiedPlugins( project1 ); assertTrue(specifiedPlugins.contains( plugin1 )); assertTrue(specifiedPlugins.contains( plugin2 )); assertTrue(specifiedPlugins.contains( plugin3 )); }
protected Set<Plugin> buildSpecifiedPlugins( MavenProject project ) { Set<Plugin> plugins = new HashSet<Plugin>( project.getBuildPlugins().size() ); MavenProject currentProject = project; while ( currentProject != null ) { Build build = currentProject.getOriginalModel().getBuild(); if ( build != null ) { plugins.addAll( build.getPlugins() ); } currentProject = currentProject.getParent(); } return plugins; }
Configurer extends AbstractMavenLifecycleParticipant { protected Set<Plugin> buildSpecifiedPlugins( MavenProject project ) { Set<Plugin> plugins = new HashSet<Plugin>( project.getBuildPlugins().size() ); MavenProject currentProject = project; while ( currentProject != null ) { Build build = currentProject.getOriginalModel().getBuild(); if ( build != null ) { plugins.addAll( build.getPlugins() ); } currentProject = currentProject.getParent(); } return plugins; } }
Configurer extends AbstractMavenLifecycleParticipant { protected Set<Plugin> buildSpecifiedPlugins( MavenProject project ) { Set<Plugin> plugins = new HashSet<Plugin>( project.getBuildPlugins().size() ); MavenProject currentProject = project; while ( currentProject != null ) { Build build = currentProject.getOriginalModel().getBuild(); if ( build != null ) { plugins.addAll( build.getPlugins() ); } currentProject = currentProject.getParent(); } return plugins; }  }
Configurer extends AbstractMavenLifecycleParticipant { protected Set<Plugin> buildSpecifiedPlugins( MavenProject project ) { Set<Plugin> plugins = new HashSet<Plugin>( project.getBuildPlugins().size() ); MavenProject currentProject = project; while ( currentProject != null ) { Build build = currentProject.getOriginalModel().getBuild(); if ( build != null ) { plugins.addAll( build.getPlugins() ); } currentProject = currentProject.getParent(); } return plugins; }  @Override /** {@inheritDoc} */ void afterProjectsRead( MavenSession session ); }
Configurer extends AbstractMavenLifecycleParticipant { protected Set<Plugin> buildSpecifiedPlugins( MavenProject project ) { Set<Plugin> plugins = new HashSet<Plugin>( project.getBuildPlugins().size() ); MavenProject currentProject = project; while ( currentProject != null ) { Build build = currentProject.getOriginalModel().getBuild(); if ( build != null ) { plugins.addAll( build.getPlugins() ); } currentProject = currentProject.getParent(); } return plugins; }  @Override /** {@inheritDoc} */ void afterProjectsRead( MavenSession session );  }