From 80983d52b687ea4be1e3ea89b09f5c1d85dc3acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 21 Nov 2022 11:39:52 +0100 Subject: [PATCH] Extract the RepositoryIdManager into an own component Currently the RepositoryIdManager can only be fetched as an agent service but not with plexus. This renames and extracts the former RemoteRepositoryLoadingHelper into a dedicated component so it can be used directly in maven components as it is not dependent on the agent actually. --- ...r.java => DefaultRepositoryIdManager.java} | 12 ++----- .../RepositoryIdManagerAgentFactory.java | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) rename p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/{RemoteRepositoryLoadingHelper.java => DefaultRepositoryIdManager.java} (93%) create mode 100644 p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RepositoryIdManagerAgentFactory.java diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RemoteRepositoryLoadingHelper.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java similarity index 93% rename from p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RemoteRepositoryLoadingHelper.java rename to p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java index 6752b4439c..19c5891805 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RemoteRepositoryLoadingHelper.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java @@ -22,8 +22,6 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.eclipse.equinox.p2.core.IProvisioningAgent; -import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; import org.eclipse.tycho.IRepositoryIdManager; import org.eclipse.tycho.MavenRepositoryLocation; import org.eclipse.tycho.MavenRepositorySettings; @@ -33,8 +31,8 @@ * Helper class for the Remote*RepositoryManagers taking care of mapping repository URLs to the * settings.xml-configured mirrors and setting passwords. */ -@Component(role = IAgentServiceFactory.class, hint = IRepositoryIdManager.SERVICE_NAME) -public class RemoteRepositoryLoadingHelper implements IRepositoryIdManager, IAgentServiceFactory { +@Component(role = IRepositoryIdManager.class) +public class DefaultRepositoryIdManager implements IRepositoryIdManager { @Requirement private MavenRepositorySettings settings; @@ -147,10 +145,4 @@ public Stream getKnownMavenRepositoryLocations() { .map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey())); } - @Override - public Object createService(IProvisioningAgent agent) { - // this don't care about different agents - return this; - } - } diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RepositoryIdManagerAgentFactory.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RepositoryIdManagerAgentFactory.java new file mode 100644 index 0000000000..f7c35a5484 --- /dev/null +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/RepositoryIdManagerAgentFactory.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2022 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.p2maven.repository; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; +import org.eclipse.tycho.IRepositoryIdManager; + +@Component(role = IAgentServiceFactory.class, hint = IRepositoryIdManager.SERVICE_NAME) +public class RepositoryIdManagerAgentFactory implements IAgentServiceFactory { + + @Requirement + IRepositoryIdManager manager; + + @Override + public Object createService(IProvisioningAgent agent) { + return manager; + } + +}