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; 20 21 import org.apache.maven.model.building.ModelBuilder; 22 import org.eclipse.aether.impl.RemoteRepositoryManager; 23 import org.eclipse.aether.impl.UpdatePolicyAnalyzer; 24 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider; 25 import org.eclipse.aether.supplier.RepositorySystemSupplier; 26 27 /** 28 * The Ant modified supplier, that on repository system creation "remembers" (and exposes) other required components as well. 29 * <p> 30 * This supplier retains references to the {@link ModelBuilder} and {@link RemoteRepositoryManager} 31 * instances created during the initialization of the repository system. These components are used 32 * later by the Ant infrastructure (e.g., for resolving POMs or remote repositories). 33 * </p> 34 * 35 * @since 1.5.0 36 */ 37 public class AntRepositorySystemSupplier extends RepositorySystemSupplier { 38 39 /** 40 * The model builder used to construct Maven models from POM files. 41 * Initialized during {@link #getModelBuilder()}. 42 */ 43 ModelBuilder modelBuilder; 44 45 /** 46 * The remote repository manager used for managing mirrors, proxies, and authentication 47 * for remote repositories. Initialized during {@link #getRemoteRepositoryManager(UpdatePolicyAnalyzer, ChecksumPolicyProvider)}. 48 */ 49 RemoteRepositoryManager remoteRepositoryManager; 50 51 /** 52 * Creates a new instance of {@code AntRepositorySystemSupplier}. 53 */ 54 public AntRepositorySystemSupplier() { 55 // Default constructor 56 } 57 58 /** 59 * Returns the {@link ModelBuilder} and stores it in the {@link #modelBuilder} field for later access. 60 * 61 * @return the {@link ModelBuilder} used for building effective models from POMs 62 */ 63 @Override 64 protected ModelBuilder getModelBuilder() { 65 modelBuilder = super.getModelBuilder(); 66 return modelBuilder; 67 } 68 69 /** 70 * Returns the {@link RemoteRepositoryManager} and stores it in the {@link #remoteRepositoryManager} field for later access. 71 * 72 * @param updatePolicyAnalyzer the analyzer for update policies 73 * @param checksumPolicyProvider the provider for checksum policies 74 * @return the {@link RemoteRepositoryManager} used for handling repository-specific configurations 75 */ 76 @Override 77 protected RemoteRepositoryManager getRemoteRepositoryManager( 78 UpdatePolicyAnalyzer updatePolicyAnalyzer, ChecksumPolicyProvider checksumPolicyProvider) { 79 remoteRepositoryManager = super.getRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider); 80 return remoteRepositoryManager; 81 } 82 }