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