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