-
1. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
ringerc Sep 19, 2012 9:59 PM (in response to alrubinger)It was between SWR 2.0.0-alpha-1 and SWR 2.0.0-alpha-2 that I noticed the change, but I didn't make that properly clear. In functionality terms it doesn't land up making any difference; I can accumulate the artifacts in a Set<String> then pass them to the Resolver like this:
// Member var: Set<String> artifacts = new HashSet<String>(); // then with `artifacts' populated: MavenResolverSystem resolver = Maven.configureResolver().fromFile("pom.xml"); WebArchive a = ShrinkWrap.create(WebArchive.class); a.addAsLibraries(resolver.resolve(artifacts.toArray(new String[artifacts.size()])).withTransitivity().as(File.class));
and that's probably the right thing to do anyway. There's no reason SWR should have to accumulate the artifacts for me, I was just initially surprised to have lost that ability. I wouldn't normally have posted that, but yesterday was an extremely exhausting day where I started off tired, so I had the mental capacity of a stoned cricket.
A `resolver.resolve(Collection<String>)` would be nice, as the current API is very much written with a single fluent in-line use where everything's a literal. That's fine for many use cases, but makes it annoying to write helper classes that're shared between many tests, where you want to add artifacts, descriptors, etc for different chunks of the application depending on what you're testing.
The more serious issue I encountered was that:
Maven.configureResolver().fromFile("pom.xml").resolve("commons-collections:commons-collections").withTransitivity().as(File.class);
fails, complaining that it cannot resolve a version for commons-collections:commons-collections, even though it's declared as a dependency in pom.xml and was resolved fine by resolvers 2a1.
-
2. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Sep 26, 2012 8:48 AM (in response to ringerc)Craig Ringer wrote:
Maven.configureResolver().fromFile("pom.xml").resolve("commons-collections:commons-collections").withTransitivity().as(File.class);
fails, complaining that it cannot resolve a version for commons-collections:commons-collections, even though it's declared as a dependency in pom.xml and was resolved fine by resolvers 2a1.
We *do* have tests for this:
I think your problem here is that you're trying to "configure" from a pom.xml. Instead, "configureFrom" applies to "settings.xml" We've changed the wording a bit. What you want is:
Maven.resolver().loadPomFromFile()
You can also load from a ClassLoader resource.
I've opened a JIRA to throw some RuntimeException if you pass a POM format file into a "configureFrom" method: https://issues.jboss.org/browse/SHRINKRES-72
Does that solve the issue for you? -
3. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Sep 27, 2012 1:55 AM (in response to alrubinger)FYI, accepting Collection<String> in "resolve" and Collection<MavenDependency> in "addDependencies" will be supported starting in 2.0.0-alpha-5:
https://issues.jboss.org/browse/SHRINKRES-66
https://github.com/shrinkwrap/resolver/commit/908b0c3e9e1723fc983d5782b6c316d539000b34
Thanks for bringing this issue to our attention.
S,
ALR
-
4. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
atiyou Sep 27, 2012 5:43 AM (in response to alrubinger)Hi,
As the new version of shrinkwrap resolver "2.0.0-alpha-4", i collect my jar files like this :
File[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve
("ch.qos.logback:logback-core",
"ch.qos.logback:logback-classic").
withTransitivity().as(File.class);
But i want to merge them with a JavaArchive not WebArchive, So how can i do it ?
jar.addAsLibraries(libs).as(JavaArchive.class); (doesn't exist)
-
5. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Sep 27, 2012 12:15 PM (in response to atiyou)Java archives don't have a spec-defined "lib" directory, so "addAsLibrary" wouldn't make sense there like it does for WebArchive (which puts the arguments into WEB-INF/lib).
You could simply use JavaArchive.add() and give the desired path? Or put in the root?
-
6. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Sep 27, 2012 12:24 PM (in response to atiyou)PS - I'll kindly ask further user questions be directed to our User Forum. It'll help t okeep these existing Development discussions focused.
-
7. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
atiyou Sep 27, 2012 1:06 PM (in response to alrubinger)No problem, i got your answer on the other side...
I was really stuck and i didn't find a answer elswhere
Tks
-
8. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
ringerc Oct 1, 2012 8:06 AM (in response to ringerc)Just back from holidays. I'll check and see, but it sounds right.
An error certainly should be thrown if it's expecting <settings/> and it gets <project/> or vice versa, especially with method names that don't use FromPomXml or FromSettingsXml or anything like that.
-
9. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Oct 2, 2012 2:21 PM (in response to ringerc)Cool. I'd also hoped, with regards to naming, that "configureResolver().fromFile()" would be clear that you're configuring from settings. While "loadPomFromFile" and "loadPomFromClassLoaderResource" should be pretty clear.
Open to renaming if we've got better suggestions on the table; we're still in Alpha for this very reason.
S,
ALR
-
10. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
ringerc Oct 2, 2012 2:53 PM (in response to alrubinger)It probably is to sensible people; to me it seemed that one might reasonably "configure" the resolver from a pom, populating it with knowledge about dependencies and versions.
-
11. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
ringerc Oct 18, 2012 5:13 AM (in response to alrubinger)Back from an extended break + other business.
I can confirm that using the API correctly fixes the issue ;-)
WebArchive a = ShrinkWrap.create(WebArchive.class); a.addAsLibraries( Maven.resolver().loadPomFromFile("pom.xml") .resolve(artifacts.toArray(new String[artifacts.size()])).withTransitivity().as(File.class));
where artifacts is a List<String>.
I'm having issues convincing it to read dependency versions from pom.xml where the dependency is declared <scope>runtime</scope>. That's easily enough worked around by first declaring the dependency without a scope in <dependencyManagement/> then referencing it with a scope override in <dependencies/> though.
(Wonder if a preview will ever be added to this forum editor?)
-
12. Re: Feature Gap between SWR 1.x and 2.0.0-alpha-2?
alrubinger Oct 18, 2012 8:01 PM (in response to ringerc)Craig Ringer wrote:
I'm having issues convincing it to read dependency versions from pom.xml where the dependency is declared <scope>runtime</scope>. That's easily enough worked around by first declaring the dependency without a scope in <dependencyManagement/> then referencing it with a scope override in <dependencies/> though.
Isn't that the expected behavior, as "runtime" scope is not transitive?
Or this is from a direct dependency declaration in the POM, where the version is provided?
S,ALR