View Javadoc
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.resolver.internal.ant.types;
20  
21  import java.util.List;
22  
23  import org.apache.tools.ant.Task;
24  
25  /**
26   * Represents a collection of one or more {@link Artifact} instances in an Ant build context.
27   * <p>
28   * This interface is implemented by Ant types that logically group or provide access to Maven artifacts,
29   * such as {@link Artifact}, {@link Artifacts}, or other custom container types.
30   * </p>
31   *
32   * <p>
33   * Implementations must be able to:
34   * <ul>
35   *   <li>Validate their internal artifact structure for consistency and completeness.</li>
36   *   <li>Return all artifacts they contain for further processing (e.g., deployment, installation).</li>
37   * </ul>
38   *
39   * <h2>Known Implementations:</h2>
40   * <ul>
41   *   <li>{@link Artifact} — represents a single Maven artifact</li>
42   *   <li>{@link Artifacts} — represents a group of artifacts or nested artifact containers</li>
43   * </ul>
44   *
45   * <p>This interface is typically used by Ant tasks such as
46   * {@link org.apache.maven.resolver.internal.ant.tasks.Install Install} and
47   * {@link org.apache.maven.resolver.internal.ant.tasks.Deploy Deploy}.</p>
48   *
49   * @see Artifact
50   * @see Artifacts
51   * @see org.apache.maven.resolver.internal.ant.tasks.Install
52   * @see org.apache.maven.resolver.internal.ant.tasks.Deploy
53   */
54  public interface ArtifactContainer {
55  
56      /**
57       * Validates the artifact(s) within this container.
58       *
59       * @param task the Ant task requesting validation; used for context or error reporting
60       * @throws org.apache.tools.ant.BuildException if any artifact is invalid or required attributes are missing
61       */
62      void validate(Task task);
63  
64      /**
65       * Returns a flat list of all {@link Artifact} instances in this container.
66       *
67       * @return a list of artifacts; never {@code null}, but may be empty
68       */
69      List<Artifact> getArtifacts();
70  }