View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.reporting.exec;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import org.apache.maven.artifact.repository.ArtifactRepository;
25  import org.apache.maven.execution.MavenSession;
26  import org.apache.maven.project.MavenProject;
27  import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
28  import org.codehaus.plexus.util.xml.Xpp3Dom;
29  
30  /**
31   * Bean which contains necessary informations to build {@link MavenReportExecution} with {@link MavenReportExecutor}:
32   * the intent is to store some informations regarding the current Maven execution.
33   *
34   * @author Olivier Lamy
35   */
36  public class MavenReportExecutorRequest {
37  
38      @Deprecated
39      private ArtifactRepository localRepository;
40  
41      private MavenSession mavenSession;
42  
43      private MavenProject project;
44  
45      private ReportPlugin[] reportPlugins;
46  
47      @Deprecated
48      public ArtifactRepository getLocalRepository() {
49          return localRepository;
50      }
51  
52      @Deprecated
53      public void setLocalRepository(ArtifactRepository localRepository) {
54          this.localRepository = localRepository;
55      }
56  
57      public MavenSession getMavenSession() {
58          return mavenSession;
59      }
60  
61      public void setMavenSession(MavenSession mavenSession) {
62          this.mavenSession = mavenSession;
63      }
64  
65      public MavenProject getProject() {
66          return project;
67      }
68  
69      public void setProject(MavenProject project) {
70          this.project = project;
71      }
72  
73      public ReportPlugin[] getReportPlugins() {
74          return reportPlugins;
75      }
76  
77      public void setReportPlugins(ReportPlugin[] reportPlugins) {
78          this.reportPlugins = reportPlugins;
79      }
80  
81      /**
82       * Set the report plugin directly from <code>${project.reporting.plugins}</code> parameter value.
83       *
84       * @param reportPlugins the report plugins from <code>&lt;reporting&gt;</code> section
85       * @since 1.4
86       */
87      public void setReportPlugins(org.apache.maven.model.ReportPlugin[] reportPlugins) {
88          setReportPlugins(new ReportPlugin[reportPlugins.length]);
89  
90          int i = 0;
91          for (org.apache.maven.model.ReportPlugin r : reportPlugins) {
92              ReportPlugin p = new ReportPlugin();
93              p.setGroupId(r.getGroupId());
94              p.setArtifactId(r.getArtifactId());
95              p.setVersion(r.getVersion());
96              if (r.getConfiguration() != null) {
97                  p.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) r.getConfiguration()));
98              }
99  
100             List<ReportSet> prs = new ArrayList<>();
101             for (org.apache.maven.model.ReportSet rs : r.getReportSets()) {
102                 ReportSet ps = new ReportSet();
103                 ps.setId(rs.getId());
104                 ps.setReports(rs.getReports());
105                 if (rs.getConfiguration() != null) {
106                     ps.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) rs.getConfiguration()));
107                 }
108                 prs.add(ps);
109             }
110             p.setReportSets(prs);
111 
112             this.reportPlugins[i++] = p;
113         }
114     }
115 }