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.plugin.surefire.booterclient;
20  
21  import javax.annotation.Nonnull;
22  import javax.annotation.Nullable;
23  
24  import java.io.File;
25  import java.util.Map;
26  import java.util.Properties;
27  
28  import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
29  import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
30  import org.apache.maven.surefire.booter.Classpath;
31  import org.apache.maven.surefire.booter.StartupConfiguration;
32  import org.apache.maven.surefire.booter.SurefireBooterForkException;
33  import org.apache.maven.surefire.extensions.ForkNodeFactory;
34  
35  import static org.apache.maven.surefire.shared.utils.StringUtils.join;
36  
37  /**
38   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
39   * @since 2.21.0.Jigsaw
40   */
41  public final class ClasspathForkConfiguration extends AbstractClasspathForkConfiguration {
42      @SuppressWarnings("checkstyle:parameternumber")
43      public ClasspathForkConfiguration(
44              @Nonnull Classpath bootClasspath,
45              @Nonnull File tempDirectory,
46              @Nullable String debugLine,
47              @Nonnull File workingDirectory,
48              @Nonnull Properties modelProperties,
49              @Nullable String argLine,
50              @Nonnull Map<String, String> environmentVariables,
51              @Nonnull String[] excludedEnvironmentVariables,
52              boolean debug,
53              int forkCount,
54              boolean reuseForks,
55              @Nonnull Platform pluginPlatform,
56              @Nonnull ConsoleLogger log,
57              @Nonnull ForkNodeFactory forkNodeFactory) {
58          super(
59                  bootClasspath,
60                  tempDirectory,
61                  debugLine,
62                  workingDirectory,
63                  modelProperties,
64                  argLine,
65                  environmentVariables,
66                  excludedEnvironmentVariables,
67                  debug,
68                  forkCount,
69                  reuseForks,
70                  pluginPlatform,
71                  log,
72                  forkNodeFactory);
73      }
74  
75      @Override
76      protected void resolveClasspath(
77              @Nonnull Commandline cli,
78              @Nonnull String booterThatHasMainMethod,
79              @Nonnull StartupConfiguration config,
80              @Nonnull File dumpLogDirectory)
81              throws SurefireBooterForkException {
82          cli.addEnvironment("CLASSPATH", join(toCompleteClasspath(config).iterator(), File.pathSeparator));
83          cli.createArg().setValue(booterThatHasMainMethod);
84      }
85  }