Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] ManualRepositorySystemFactory.getRepositorySystem() returns null

I finally have some time to dig into this further. Unfortunately eclipse (STS, actually) is being a real pain and not letting me set breakpoints so I'm having to play with reflection instead of doing it more directly.

Anyway I'm using the sample code:

DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);

when I try to get a RepositorySystem I get a null result:

RepositorySystem rs = locator.getService(RepositorySystem.class);
System.out.println(" rs --> " + rs);

and when I ask the locator for a list of these services I get an empty list:

List<RepositorySystem> l = locator.getServices(RepositorySystem.class);
System.out.println(" cnt --> " + l.size());

but when I use a bit of reflection to peek at the underlying data structure I can find a value:

Field f = locator.getClass().getDeclaredField("entries");
f.setAccessible(true);
Map<Class, Object> map = (Map<Class, Object>) f.get(locator);
System.out.println(" contains --> " + map.containsKey(RepositorySystem.class));
Object obj = map.get(RepositorySystem.class);

and with a bit more reflection I see that there is one provider, of type DefaultRepositorySystem, but no instances. It's the latter that's returned by "getService()" and that's why I'm getting a null value. I don't know why I have a provider but no instance.

When I try creating a DefaultRepositorySystem directly I get a NPE in newLocalRepositoryManager() - I'm sure it's a null localRepositoryProvider. I see that that value is annotated with @Requirement.

This raises the question of initialization...  it's failing when I try a naked junit test and when @RunWith SpringJUnit4ClassRunner, but I don't have a @ContextConfiguration in the latter case. Am I simply missing some magic initialization?

Bear













On Tue, Sep 3, 2013 at 4:35 PM, Bear Giles <bgiles@xxxxxxxxxxxxxx> wrote:
We have a really painful proxy / local repository setup to, ahem, make sure we stick with the approved jars written in 197... well, at least within the last decade. During internal dev we can grab more recent stuff and make a business case for it but in the meanwhile it's a case of manually downloading the jars from the central repository, adding them to our dev box using mvn install:install-file, and then drinking heavily after work.

The central repositories usually have the javadoc and source jarballs with the binaries but for some weird reason I didn't see them in this case.


On Tue, Sep 3, 2013 at 4:28 PM, Benjamin Bentmann <bentmann@xxxxxxxxxxxx> wrote:
Bear Giles wrote:

I was afraid you would say that.

Don't be scared, the very purpose of that service locator stuff is to be no-frills, so stepping through it should be a rather easy task. The sources for Maven 3.x have been migrated to Git and that SVN tag doesn't correspond to the actual 3.1.0 release. The better fit would be
https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob;f=maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java;h=b7ed320158887cacbb48fa893b767ceedca3e028;hb=893ca28a1da9d5f51ac03827af98bb730128f9f2

Though seeing you gather sources this way makes me wonder how you imported the example project in the first place. Those are Maven projects and your IDE (e.g. Eclipse+m2e) should automatically download the sources JARs for all dependencies in there such that opening a given shows the sources.



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



Back to the top