View Javadoc
1   package org.apache.maven.extension.internal;
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.LinkedHashMap;
23  import java.util.Map;
24  import java.util.Set;
25  
26  import org.codehaus.plexus.classworlds.realm.ClassRealm;
27  
28  import com.google.common.collect.ImmutableMap;
29  import com.google.common.collect.ImmutableSet;
30  
31  /**
32   * Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by
33   * Maven core itself and loaded Maven core extensions.
34   * 
35   * @since 3.3.0
36   */
37  public class CoreExports
38  {
39      private final Set<String> artifacts;
40  
41      private final Map<String, ClassLoader> packages;
42  
43      public CoreExports( CoreExtensionEntry entry )
44      {
45          this( entry.getClassRealm(), entry.getExportedArtifacts(), entry.getExportedPackages() );
46      }
47  
48      public CoreExports( ClassRealm realm, Set<String> exportedArtifacts, Set<String> exportedPackages )
49      {
50          Map<String, ClassLoader> packages = new LinkedHashMap<>();
51          for ( String pkg : exportedPackages )
52          {
53              packages.put( pkg, realm );
54          }
55          this.artifacts = ImmutableSet.copyOf( exportedArtifacts );
56          this.packages = ImmutableMap.copyOf( packages );
57      }
58  
59      /**
60       * Returns artifacts exported by Maven core and core extensions. Artifacts are identified by their
61       * groupId:artifactId string key.
62       */
63      public Set<String> getExportedArtifacts()
64      {
65          return artifacts;
66      }
67  
68      /**
69       * Returns packages exported by Maven core and core extensions.
70       */
71      public Map<String, ClassLoader> getExportedPackages()
72      {
73          return packages;
74      }
75  }