Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Missing Transport Connector for HTTP Repositories

Hello Benjamin,

perfect - this works like a charm! Thank you for your help... I was just unable to find that hint with the "shallow copy" of the repository session...

Best regards
Timo


2013/10/7 Benjamin Bentmann <bentmann@xxxxxxxxxxxx>
Timo Rohrberg wrote:

public static RepositorySystem newRepositorySystem()
{
   DefaultServiceLocator locator =
MavenRepositorySystemUtils.newServiceLocator();
   locator.addService(RepositoryConnectorFactory.class,
BasicRepositoryConnectorFactory.class);
   locator.addService(TransporterFactory.class,
FileTransporterFactory.class);
   locator.addService(TransporterFactory.class,
HttpTransporterFactory.class);

   return locator.getService(RepositorySystem.class);
}

public static DefaultRepositorySystemSession
newRepositorySystemSession(RepositorySystem system)
{
   DefaultRepositorySystemSession session =
MavenRepositorySystemUtils.newSession();

   LocalRepository localRepo = new LocalRepository("target/local-repo");

session.setLocalRepositoryManager(system.newLocalRepositoryManager(session,
localRepo));

   session.setTransferListener(new ConsoleTransferListener());
   session.setRepositoryListener(new ConsoleRepositoryListener());

   return session;
}

That code looks like it was taken from the example project, so generally works.


private boolean existArtifactInRepository(final Artifact artifact, final
RemoteRepository repository)
{
   ArtifactRequest request = new ArtifactRequest();
   request.setArtifact(artifact);
   request.setRepositories(Collections.singletonList(repository));

request.addRepository(repository) might be less typing.


And uploading artifacts works if I use
the injected repository system and session. However, in my use case I
cannot use the same repository system and session for checking the
existence since I am in a reactor build

>From this I take it you're coding a Maven plugin. A Maven plugin that creates its own repo system and session is pretty much doomed to misbehave, e.g. ignore Maven's network/proxy configuration.

Maven's reactor output is provided to Aether via a WorkspaceReader configured on the repo session. So for your case, you should have tried the following, using the injected repo system and session:

DefaultRepositorySystemSession mySession = new DefaultRepositorySystemSession(injectedSession):
mySession.setWorkspaceReader(null); // disable reactor resolution
mySession.setLocalRepositoryManager(...); // as before, bypass previous build output via temp local repo
injectedSystem.resolveArtifact(mySession, ...);


Benjamin

_______________________________________________
aether-users mailing list
aether-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aether-users


Back to the top