View Javadoc
1   package org.apache.maven.shared.filtering;
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.Properties;
23  
24  import org.apache.maven.execution.DefaultMavenExecutionRequest;
25  import org.apache.maven.execution.MavenExecutionResult;
26  import org.apache.maven.execution.MavenSession;
27  import org.apache.maven.settings.Settings;
28  import org.codehaus.plexus.PlexusContainer;
29  import org.eclipse.aether.RepositorySystemSession;
30  
31  /**
32   * @author Olivier Lamy
33   * @since 1.0-beta-1
34   *
35   */
36  public class StubMavenSession
37      extends MavenSession
38  {
39  
40      private Properties userProperties;
41  
42      private Properties systemProperties;
43  
44      private final Settings settings;
45  
46      public StubMavenSession( Settings settings )
47      {
48          this( null, null, settings );
49      }
50  
51      public StubMavenSession()
52      {
53          this( null, null, null );
54      }
55  
56      public StubMavenSession( Properties userProperties )
57      {
58          this( null, userProperties, null );
59      }
60  
61      public StubMavenSession( Properties systemProperties, Properties userProperties, Settings settings )
62      {
63  
64          super( (PlexusContainer) null, (RepositorySystemSession) null, new DefaultMavenExecutionRequest(),
65                 (MavenExecutionResult) null );
66  
67          this.settings = settings;
68  
69          this.systemProperties = new Properties();
70          if ( systemProperties != null )
71          {
72              this.systemProperties.putAll( systemProperties );
73          }
74          this.systemProperties.putAll( System.getProperties() );
75  
76          this.userProperties = new Properties();
77          if ( userProperties != null )
78          {
79              this.userProperties.putAll( userProperties );
80          }
81      }
82  
83      @Override
84      public Settings getSettings()
85      {
86          return settings;
87      }
88  
89      @Override
90      public Properties getSystemProperties()
91      {
92          return this.systemProperties;
93      }
94  
95      @Override
96      public Properties getUserProperties()
97      {
98          return this.userProperties;
99      }
100 
101 }