ShrinkWrap Resolver 2.0.0 modifications
kpiwko Nov 30, 2011 4:53 AMI'd like you to comment following modification I'm planning to do for upcoming SWR 2.0.0 release:
Resolver Maven Plugin
POC hosted at https://github.com/kpiwko/resolver-maven-plugin
This plugin must be configured in projects pom.xml. It will inject 5 system properties into the surefire environment, making SWR able to retrieve essencial information about the Maven build which started the project.
This plugin should become an core part of the resolver.
Note: M2E integration would be nice, meanwhile user will have to set 5 system properties by his own in the IDE
Keeping Maven related methods out of user's reach
Having Resolver Maven Plugin, user should not have directly exposed APIs to access Maven configuration stuff.
This means that following will not be available by default:
- loadEffectivePom(...)
- configureFrom(...)
- useCentralRepo(...)
- goOffline(...)
- repository(...), repositories(...)
All this information will be transparently set by Resolver Maven Plugin.
Enviroments without Resolver Maven Plugin
It is clear that users trying to run SWR for Ant or different tool will have no Resolver Maven Plugin injection available. These users should have access to the above-mentioned methods, so they can configure Maven environment by themselves.
Implementation
I think the correct way how to solve that is to create two entry points:
- MavenDependencyResolverWithIntegration
- MavenDependencyWithoutIntegration
The idea here is that after MavenDependencyResolverWithoutIntegration is configured, is will become a plain MavenDependencyResolverWithIntegration. We will likely have to modify what methods an EntryPoint provides.
Use cases
1/ Get hibernate-search artifact with transitive dependencies from current pom.xml
DependencyResolvers.use(MavenDependencyResolverWithIntegration.class).artifact("org.hibernate:hibernate-search")
This will fail if integration not detected suggesting user either to activate the integration or to use MavenDependencyResolverWithoutIntegration.
2/ Get hibernate-search artifact with transitive dependencies without a pom file
DependencyResolvers.use(MavenDependencyResolverWithoutIntegration.class).artifact("org.hibernate:hibernate-search:4.0.0.CR2")
It won't trigger any integration stuff. It will use default configuration, e.g. Maven Central enabled and .m2/settings.xml.
3/ Get hibernate-search artifact with transitive dependencies without integration and a pom file
DependencyResolvers.use(MavenDependencyResolverWithoutIntegration.class).loadEffectivePom("pom.xml").artifact("org.hibernate.hibernate-search")
4/ Get hibernate-search artifact with transitive dependencies using Maven configuration specific stuff:
DependencyResolvers.use(MavenDependencyResolverWithoutIntegration.class).goOffline().configureFrom("settings.xml").loadEffectivePom("pom.xml").artifact("org.hibernate:hibernate-searcch")
Access to internals
We should define a way how to let user get information from both Maven model and information retrieved from Resolver Maven Plugin. I like the idea of doing it the ShrinkWrap way, e.g. using some as() method and casting object to a information retriever. Note that this won't be available on MavenDependencyResolverWithoutIntegration for an obvious reason.
DependencyResolvers.use(MavenDependencyResolverWithIntegration.class).as(MavenProjectInformation.class).getPackaging();
DependencyResolvers.use(MavenDependencyResolverWithoutIntegration.class).loadEffectivePom("pom.xml", "as7-rocks-profile").as(MavenProjectInformation.class).getPackaging();
Renaming
Now the most confusing part. We should consider renaming of the methods and classes
I haven't found proper naming yet but definitely we need something much much shorther.