1   package org.apache.maven;
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 org.codehaus.classworlds.ClassRealm;
23  import org.codehaus.classworlds.ClassWorld;
24  import org.codehaus.plexus.DefaultPlexusContainer;
25  import org.codehaus.plexus.PlexusContainer;
26  
27  import java.io.File;
28  
29  /**
30   * This is a utility class for helping to configure a PlexusTestCase for testing with maven.
31   *
32   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
33   * @version $Id: MavenTestUtils.java 495147 2007-01-11 07:47:53Z jvanzyl $
34   */
35  public class MavenTestUtils
36  {
37      private MavenTestUtils()
38      {
39      }
40  
41      public static PlexusContainer getContainerInstance()
42      {
43          return new DefaultPlexusContainer();
44      }
45  
46      public static void customizeContext( PlexusContainer container, File basedir, File mavenHome, File mavenHomeLocal )
47          throws Exception
48      {
49          ClassWorld classWorld = new ClassWorld();
50  
51          ClassRealm rootClassRealm = classWorld.newRealm( "root", Thread.currentThread().getContextClassLoader() );
52  
53          container.addContextValue( "rootClassRealm", rootClassRealm );
54  
55          container.addContextValue( "maven.home", mavenHome.getAbsolutePath() );
56  
57          container.addContextValue( "maven.home.local", mavenHomeLocal.getAbsolutePath() );
58      }
59  }