View Javadoc
1   package org.nuiton.config;
2   
3   /*
4    * #%L
5    * Nuiton Maven Report Plugin
6    * %%
7    * Copyright (C) 2012 - 2016 CodeLutin, Tony Chemit
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as 
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Lesser Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * #L%
23   */
24  
25  import org.apache.maven.artifact.DependencyResolutionRequiredException;
26  import org.apache.maven.plugins.annotations.Execute;
27  import org.apache.maven.plugins.annotations.LifecyclePhase;
28  import org.apache.maven.plugins.annotations.Mojo;
29  import org.apache.maven.plugins.annotations.Parameter;
30  import org.apache.maven.plugins.annotations.ResolutionScope;
31  import org.apache.maven.project.MavenProject;
32  import org.apache.maven.reporting.MavenReportException;
33  
34  import java.util.HashSet;
35  import java.util.List;
36  import java.util.Set;
37  
38  /**
39   * Generates a report for declarated application config via the
40   * {@link ApplicationConfigProvider} mecanism on a aggregate mojo.
41   *
42   * For each configuration, you can find all his options and actions.
43   *
44   * @author Tony - chemit@codelutin.com
45   * @since 2.6.10
46   */
47  @Mojo(name = "aggregate-config-report", aggregator = true,
48        requiresProject = true, requiresReports = true,
49        requiresDependencyResolution = ResolutionScope.RUNTIME)
50  @Execute(phase = LifecyclePhase.COMPILE)
51  public class AggregateApplicationConfigReport extends AbstractApplicationConfigReport {
52  
53      /**
54       * The projects in the reactor.
55       *
56       * @since 2.6.10
57       */
58      @Parameter(property = "reactorProjects", readonly = true, required = true)
59      protected List<?> reactorProjects;
60  
61      @Override
62      protected ClassLoader createClassLoader() throws MavenReportException {
63          Set<String> paths = new HashSet<String>();
64  
65          for (Object o : reactorProjects) {
66              MavenProject p = (MavenProject) o;
67              try {
68                  List runtimeClasspathElements = p.getRuntimeClasspathElements();
69                  paths.addAll(runtimeClasspathElements);
70              } catch (DependencyResolutionRequiredException e) {
71                  throw new MavenReportException("Could not obtain dependencies for project " + p);
72              }
73          }
74          return createClassLoader(paths);
75      }
76  }