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