Skip to content

Commit

Permalink
Extract the RepositoryIdManager into an own component
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laeubi committed Nov 21, 2022
1 parent 60d5cd3 commit 80983d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -147,10 +145,4 @@ public Stream<MavenRepositoryLocation> getKnownMavenRepositoryLocations() {
.map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey()));
}

@Override
public Object createService(IProvisioningAgent agent) {
// this don't care about different agents
return this;
}

}
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit 80983d5

Please sign in to comment.