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;
20
21 import java.util.List;
22
23 import org.apache.maven.artifact.Artifact;
24 import org.apache.maven.model.Plugin;
25 import org.apache.maven.project.MavenProject;
26 import org.eclipse.aether.RepositorySystemSession;
27 import org.eclipse.aether.graph.DependencyFilter;
28 import org.eclipse.aether.repository.RemoteRepository;
29
30 /**
31 * Caches plugin artifacts. <strong>Warning:</strong> This is an internal utility interface that is only public for
32 * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without
33 * prior notice.
34 *
35 */
36 public interface PluginArtifactsCache {
37
38 /**
39 * A cache key.
40 */
41 interface Key {
42 // marker interface for cache keys
43 }
44
45 /**
46 * CacheRecord
47 */
48 class CacheRecord {
49
50 private final List<Artifact> artifacts;
51
52 public List<Artifact> getArtifacts() {
53 return artifacts;
54 }
55
56 public PluginResolutionException getException() {
57 return exception;
58 }
59
60 private final PluginResolutionException exception;
61
62 public CacheRecord(List<Artifact> artifacts) {
63 this.artifacts = artifacts;
64 this.exception = null;
65 }
66
67 public CacheRecord(PluginResolutionException exception) {
68 this.artifacts = null;
69 this.exception = exception;
70 }
71 }
72
73 Key createKey(
74 Plugin plugin,
75 DependencyFilter extensionFilter,
76 List<RemoteRepository> repositories,
77 RepositorySystemSession session);
78
79 CacheRecord get(Key key) throws PluginResolutionException;
80
81 CacheRecord put(Key key, List<Artifact> pluginArtifacts);
82
83 CacheRecord put(Key key, PluginResolutionException e);
84
85 void flush();
86
87 /**
88 * Registers the specified cache record for usage with the given project. Integrators can use the information
89 * collected from this method in combination with a custom cache implementation to dispose unused records from the
90 * cache.
91 *
92 * @param project The project that employs the plugin realm, must not be {@code null}.
93 * @param record The cache record being used for the project, must not be {@code null}.
94 */
95 void register(MavenProject project, Key cacheKey, CacheRecord record);
96 }