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_suite_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.newLocalRepositoryManager(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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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/jboss-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>
