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 String executionId;
44  
45      private MavenProject project;
46  
47      private ReportPlugin[] reportPlugins;
48  
49      @Deprecated
50      public ArtifactRepository getLocalRepository() {
51          return localRepository;
52      }
53  
54      @Deprecated
55      public void setLocalRepository(ArtifactRepository localRepository) {
56          this.localRepository = localRepository;
57      }
58  
59      public MavenSession getMavenSession() {
60          return mavenSession;
61      }
62  
63      public void setMavenSession(MavenSession mavenSession) {
64          this.mavenSession = mavenSession;
65      }
66  
67      public String getExecutionId() {
68          return executionId;
69      }
70  
71      public void setExecutionId(String executionId) {
72          this.executionId = executionId;
73      }
74  
75      public MavenProject getProject() {
76          return project;
77      }
78  
79      public void setProject(MavenProject project) {
80          this.project = project;
81      }
82  
83      public ReportPlugin[] getReportPlugins() {
84          return reportPlugins;
85      }
86  
87      public void setReportPlugins(ReportPlugin[] reportPlugins) {
88          this.reportPlugins = reportPlugins;
89      }
90  
91      /**
92       * Set the report plugin directly from <code>${project.reporting.plugins}</code> parameter value.
93       *
94       * @param reportPlugins the report plugins from <code>&lt;reporting&gt;</code> section
95       * @since 1.4
96       */
97      public void setReportPlugins(org.apache.maven.model.ReportPlugin[] reportPlugins) {
98          setReportPlugins(new ReportPlugin[reportPlugins.length]);
99  
100         int i = 0;
101         for (org.apache.maven.model.ReportPlugin r : reportPlugins) {
102             ReportPlugin p = new ReportPlugin();
103             p.setGroupId(r.getGroupId());
104             p.setArtifactId(r.getArtifactId());
105             p.setVersion(r.getVersion());
106             if (r.getConfiguration() != null) {
107                 p.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) r.getConfiguration()));
108             }
109 
110             List<ReportSet> prs = new ArrayList<>();
111             for (org.apache.maven.model.ReportSet rs : r.getReportSets()) {
112                 ReportSet ps = new ReportSet();
113                 ps.setId(rs.getId());
114                 ps.setReports(rs.getReports());
115                 if (rs.getConfiguration() != null) {
116                     ps.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) rs.getConfiguration()));
117                 }
118                 prs.add(ps);
119             }
120             p.setReportSets(prs);
121 
122             this.reportPlugins[i++] = p;
123         }
124     }
125 }