PR provided https://github.com/anthonydahanne/maven-resolver-test/pull/1

in fact, you're not testing resolver directly but project builder which 
resolves everything

Regards,

Hervé

Le samedi 13 février 2021, 23:36:28 CET Anthony Dahanne a écrit :
> Hello Tamás,
> Thanks for your answer.
> Yes, I remember I also got a look at this maven-resolver-demos repo; and I
> could even leverage it to successfully resolve GAVs.
> And your remark about the MRESOLVER-157 takes all its meaning with my
> issue: reconciling the "pure maven-resolver" world (GAV transformed into a
> CollectRequest is the input) with the "maven pom model" (a pom File
> transformed into a MavenProject is the input)
> I added the maven-core dependency to the maven-resolver-demos pom, so that
> I could, from ResolveTransitiveDependencies, setup a DefaultProjectBuilder
> (like I did previously, but this time using the Booter session)
> But, alas, the DefaultProjectBuilder needs to be setup with proper DI - so
> I'm stuck here for now wit NPEs on its dependencies.
> 
> I'll continue digging to try and have the DefaultProjectBuilder correctly
> wired with all its dependencies.
> 
> So bottom line is: I want to resolve a pom file, not a GAV.
> 
> Thanks again!
> Anthony
> 
> 
> 
> 
> 
> Le sam. 13 févr. 2021, à 11 h 00, Tamás Cservenák <[email protected]> a
> 
> écrit :
> > Howdy,
> > 
> > take a peek at resolver "demo" snippets here:
> > 
> > https://github.com/apache/maven-resolver/blob/master/maven-resolver-demos/
> > maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examp
> > les/ResolveTransitiveDependencies.java
> > 
> > Word of warning: do not "mix" ServiceLocator and DI (Guice or SISU)... you
> > MUST settle on one and set up your environment using that one.
> > Take a peek a "Booter" class for that (it has commented out code that
> > leads
> > to Guice, SISU stuff, by default uses ServiceLocator).
> > 
> > Finally, just FTR I need to mention this issue
> > https://issues.apache.org/jira/browse/MRESOLVER-157
> > So, current maven-resolver releases still support ServiceLocator, in
> > upcoming 1.7.0 of it it will be deprecated, and later removed.
> > 
> > HTH
> > T
> > 
> > On Fri, Feb 12, 2021 at 3:36 AM Anthony Dahanne <[email protected]
> > 
> > wrote:
> > > Hello Maven devs,
> > > I'm trying to programmatically ingest a pom.xml and start a Maven
> > > dependency resolution on it.
> > > For that end, I'm using DefaultProjectBuildingRequest and a
> > 
> > ProjectBuilder.
> > 
> > > I could successfully issue the request, but when trying against a pom
> > 
> > that
> > 
> > > relies on a parent or a BOM (spring boot pom for example), it seems like
> > > the properties set in the poms (including dependencies poms) aren't
> > > considered.
> > > 
> > > I have set up a Github project there to reproduce the issue:
> > 
> > > Code:
> > https://github.com/anthonydahanne/maven-resolver/blob/master/src/main/java
> > /net/dahanne/mavenresolver/MavenResolverApplication.java#L37> 
> > > Error output :
> > https://github.com/anthonydahanne/maven-resolver/runs/1884304754?check_sui
> > te_focus=true> 
> > > (not sure it's public though)
> > > 
> > > Pom I tried to resolve:
> > > https://github.com/anthonydahanne/maven-resolver/blob/master/pom.xml
> > > 
> > > For convenience, I have copied the code, pom that I tried to resolve and
> > > the error log at the end of this email
> > > 
> > > I am kindly asking for your help, in case I missed an option in request
> > 
> > or
> > 
> > > the session or.. both...
> > > A debug session did not reveal much unfortunately...
> > > 
> > > Thanks in advance for your help!
> > > 
> > > Anthony
> > > 
> > > 
> > > 
> > > 
> > > Code snippet:
> > > 
> > > ContainerConfiguration config = new DefaultContainerConfiguration();
> > > 
> > >   config.setAutoWiring(true);
> > >   config.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
> > >   PlexusContainer plexusContainer = new DefaultPlexusContainer(config);
> > >   ProjectBuilder projectBuilder =
> > > 
> > > plexusContainer.lookup(ProjectBuilder.class);
> > > 
> > >   RepositorySystem repositorySystem =
> > > 
> > > plexusContainer.lookup(RepositorySystem.class);
> > > 
> > >   DefaultRepositorySystemSession session =
> > > 
> > > MavenRepositorySystemUtils.newSession();
> > > 
> > >   LocalRepository localRepository = new LocalRepository("target/.m2");
> > 
> > session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManag
> > er(session,> 
> > > localRepository));
> > > 
> > >   DefaultProjectBuildingRequest request = new
> > > 
> > > DefaultProjectBuildingRequest();
> > > 
> > >   request.setRepositorySession(session);
> > >   request.setResolveDependencies(true);
> > > 
> > > ArtifactRepository centralRepository = new MavenArtifactRepository();
> > > centralRepository.setUrl("https://repo.maven.apache.org/maven2/";);
> > > centralRepository.setLayout(new DefaultRepositoryLayout());
> > 
> > request.setRemoteRepositories(Collections.singletonList(centralRepository)
> > );> 
> > >   ProjectBuildingResult result = projectBuilder.build(new
> > > 
> > > File("pom.xml"), request);
> > > 
> > > and here is the output:
> > > 
> > > Caused by: org.apache.maven.project.ProjectBuildingException:
> > > Some problems were encountered while processing the POMs:
> > > [ERROR] Invalid artifact repository: null @
> > > [ERROR] Failed to determine Java version for profile jdk8 @
> > > io.dropwizard.metrics:metrics-parent:4.1.17,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/io/dropwizard/
> > metrics/metrics-parent/4.1.17/metrics-parent-4.1.17.pom,> 
> > > line 160, column 22
> > > [ERROR] Failed to determine Java version for profile
> > 
> > doclint-java8-disable
> > 
> > > @ org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 839, column 17
> > > [ERROR] Failed to determine Java version for profile
> > > compile-java8-release-flag @ org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 879, column 18
> > > [ERROR] Failed to determine Java version for profile include-jdk-misc @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 910, column 22
> > > [ERROR] Failed to determine Java version for profile java8-test @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 961, column 22
> > > [ERROR] Failed to determine Java version for profile java9-mr-build @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 998, column 22
> > > [ERROR] Failed to determine Java version for profile java9-test @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1047, column 22
> > > [ERROR] Failed to determine Java version for profile java10-mr-build @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1087, column 22
> > > [ERROR] Failed to determine Java version for profile java10-test @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1139, column 22
> > > [ERROR] Failed to determine Java version for profile java11-mr-build @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1182, column 22
> > > [ERROR] Failed to determine Java version for profile java11-test @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1237, column 22
> > > [ERROR] Failed to determine Java version for profile java12-mr-build @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1283, column 22
> > > [ERROR] Failed to determine Java version for profile java12-test @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1341, column 22
> > > [ERROR] Failed to determine Java version for profile java13-mr-build @
> > > org.jboss:jboss-parent:36,
> > 
> > /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jbos
> > s-parent/36/jboss-parent-36.pom,> 
> > > line 1390, column 22
> > > 
> > > 
> > > And this is the pom I tried to resolve:
> > > 
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <project xmlns="http://maven.apache.org/POM/4.0.0";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > 
> > >    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > > 
> > > https://maven.apache.org/xsd/maven-4.0.0.xsd";>
> > > 
> > >    <modelVersion>4.0.0</modelVersion>
> > >    <parent>
> > >    
> > >       <groupId>org.springframework.boot</groupId>
> > >       <artifactId>spring-boot-starter-parent</artifactId>
> > >       <version>2.4.2</version>
> > >       <relativePath/> <!-- lookup parent from repository -->
> > >    
> > >    </parent>
> > >    <groupId>net.dahanne</groupId>
> > >    <artifactId>maven-resolver</artifactId>
> > >    <version>0.0.1-SNAPSHOT</version>
> > >    <name>maven-resolver</name>
> > >    <description>Demo project for Spring Boot</description>
> > >    <properties>
> > >    
> > >       <java.version>11</java.version>
> > >       <maven.version>3.6.3</maven.version>
> > >       <maven-resolver.version>1.6.1</maven-resolver.version>
> > >    
> > >    </properties>
> > >    <dependencies>
> > >    
> > >       <dependency>
> > >       
> > >          <groupId>org.springframework.boot</groupId>
> > >          <artifactId>spring-boot-starter</artifactId>
> > >       
> > >       </dependency>
> > >       
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven</groupId>
> > >          <artifactId>maven-core</artifactId>
> > >          <version>${maven.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven</groupId>
> > >          <artifactId>maven-compat</artifactId>
> > >          <version>${maven.version}</version>
> > >       
> > >       </dependency>
> > >       
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven</groupId>
> > >          <artifactId>maven-resolver-provider</artifactId>
> > >          <version>${maven.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-util</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-api</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-spi</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-transport-http</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-transport-file</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-connector-basic</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       <dependency>
> > >       
> > >          <groupId>org.apache.maven.resolver</groupId>
> > >          <artifactId>maven-resolver-impl</artifactId>
> > >          <version>${maven-resolver.version}</version>
> > >       
> > >       </dependency>
> > >       
> > >       
> > >       <dependency>
> > >       
> > >          <groupId>org.springframework.boot</groupId>
> > >          <artifactId>spring-boot-starter-test</artifactId>
> > >          <scope>test</scope>
> > >       
> > >       </dependency>
> > >    
> > >    </dependencies>
> > >    
> > >    <build>
> > >    
> > >       <plugins>
> > >       
> > >          <plugin>
> > >          
> > >             <groupId>org.springframework.boot</groupId>
> > >             <artifactId>spring-boot-maven-plugin</artifactId>
> > >          
> > >          </plugin>
> > >       
> > >       </plugins>
> > >    
> > >    </build>
> > > 
> > > </project>





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to