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.eclipse.aether.spi.validator;
20
21 import org.eclipse.aether.artifact.Artifact;
22 import org.eclipse.aether.graph.Dependency;
23 import org.eclipse.aether.metadata.Metadata;
24 import org.eclipse.aether.repository.LocalRepository;
25 import org.eclipse.aether.repository.RemoteRepository;
26
27 /**
28 * A repository system main input validator; this validator is used in repository system "main entry methods".
29 *
30 * @since 2.0.8
31 */
32 public interface Validator {
33 /**
34 * Validates artifact.
35 *
36 * @param artifact the artifact to validate, never {@code null}.
37 * @throws IllegalArgumentException if artifact is invalid.
38 */
39 default void validateArtifact(Artifact artifact) throws IllegalArgumentException {}
40
41 /**
42 * Validates metadata.
43 *
44 * @param metadata the metadata to validate, never {@code null}.
45 * @throws IllegalArgumentException if metadata is invalid.
46 */
47 default void validateMetadata(Metadata metadata) throws IllegalArgumentException {}
48
49 /**
50 * Validates dependency.
51 *
52 * @param dependency the dependency to validate, never {@code null}.
53 * @throws IllegalArgumentException if dependency is invalid.
54 */
55 default void validateDependency(Dependency dependency) throws IllegalArgumentException {}
56
57 /**
58 * Validates managed dependency.
59 * <em>Important:</em> They are declarative constraints (version/scope/exclusion overrides) that only take effect
60 * when a matching dependency is encountered during collection. Validating them eagerly may reject valid builds
61 * where a BOM imports managed dependencies with uninterpolated property expressions (e.g. {@code ${osgi.version}})
62 * that are never actually used. If a managed dependency IS matched and its coordinates are invalid, the error
63 * will surface naturally during version resolution or artifact resolution.
64 *
65 * @param managedDependency the managed dependency to validate, never {@code null}.
66 * @throws IllegalArgumentException if dependency is invalid.
67 * @since 2.0.22
68 */
69 default void validateManagedDependency(Dependency managedDependency) throws IllegalArgumentException {}
70
71 /**
72 * Validates local repository.
73 *
74 * @param localRepository the local repository to validate, never {@code null}.
75 * @throws IllegalArgumentException if local repository is invalid.
76 */
77 default void validateLocalRepository(LocalRepository localRepository) throws IllegalArgumentException {}
78
79 /**
80 * Validates remote repository.
81 *
82 * @param remoteRepository the remote repository to validate, never {@code null}.
83 * @throws IllegalArgumentException if remote repository is invalid.
84 */
85 default void validateRemoteRepository(RemoteRepository remoteRepository) throws IllegalArgumentException {}
86 }