1 package org.apache.maven.classrealm; 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.List; 23 import java.util.Map; 24 25 import org.apache.maven.model.Model; 26 import org.apache.maven.model.Plugin; 27 import org.codehaus.plexus.classworlds.realm.ClassRealm; 28 import org.sonatype.aether.artifact.Artifact; 29 30 /** 31 * Manages the class realms used by Maven. <strong>Warning:</strong> This is an internal utility interface that is only 32 * public for technical reasons, it is not part of the public API. In particular, this interface can be changed or 33 * deleted without prior notice. 34 * 35 * @author Benjamin Bentmann 36 */ 37 public interface ClassRealmManager 38 { 39 40 /** 41 * Gets the class realm hosting the Maven core. 42 * 43 * @return The class realm hosting the Maven core, never {@code null}. 44 */ 45 ClassRealm getCoreRealm(); 46 47 /** 48 * Gets the class realm exposing the Maven API. This is basically a restricted view on the Maven core realm. 49 * 50 * @return The class realm exposing the Maven API, never {@code null}. 51 */ 52 ClassRealm getMavenApiRealm(); 53 54 /** 55 * Creates a new class realm for the specified project and its build extensions. 56 * 57 * @param model The model of the project for which to create a realm, must not be {@code null}. 58 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 59 * missing file) will automatically be excluded from the realm. 60 * @return The new project realm, never {@code null}. 61 */ 62 ClassRealm createProjectRealm( Model model, List<Artifact> artifacts ); 63 64 /** 65 * Creates a new class realm for the specified build extension. 66 * 67 * @param plugin The extension plugin for which to create a realm, must not be {@code null}. 68 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 69 * missing file) will automatically be excluded from the realm. 70 * @return The new extension realm, never {@code null}. 71 */ 72 ClassRealm createExtensionRealm( Plugin extension, List<Artifact> artifacts ); 73 74 /** 75 * Creates a new class realm for the specified plugin. 76 * 77 * @param plugin The plugin for which to create a realm, must not be {@code null}. 78 * @param parent The parent realm for the new realm, may be {@code null}. 79 * @param parentImports The packages/types to import from the parent realm, may be {@code null}. 80 * @param foreignImports The packages/types to import from foreign realms, may be {@code null}. 81 * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a 82 * missing file) will automatically be excluded from the realm. 83 * @return The new plugin realm, never {@code null}. 84 */ 85 ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List<String> parentImports, 86 Map<String, ClassLoader> foreignImports, List<Artifact> artifacts ); 87 88 }