Re: Possible bug in the ProjectBuilder (3.5.4) ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in the ProjectBuilder (3.5.4) ?

Cristiano Gavião
Ok, I found where the problem was... :-)

Certainly I do not set necessary objects to new instance of
ProjectBuildingRequest  that I was doing.

Once I have reused the instance provided by the MavenSession instance,
the errors gone !

> ProjectBuildingRequest request = session.getProjectBuildingRequest();

best regards,

Cristiano


On 24/09/2018 21:17, Cristiano wrote:

>
> Hello, I need some assistance in order to identify whether the issue
> I'm facing is a bug or a missing feature.
>
> I'm adding a goal to my plugin that must read a POM project from a
> repository and get details about the dependencies declared on it.
>
> In order to build the POM object I've created the method below that
> are using Core's org.apache.maven.project.ProjectBuilder:
>
>
>             public MavenProject loadProject(Artifact artifact,
>         MavenSession session,
>                     boolean pResolveDependencies) throws
>         ProjectBuildingException {
>                 ProjectBuildingRequest request = new
>         DefaultProjectBuildingRequest();
>         request.setLocalRepository(session.getLocalRepository());
>                 request.setRemoteRepositories(
>         session.getCurrentProject().getRemoteArtifactRepositories());
>         request.setResolveDependencies(pResolveDependencies);
>         request.setRepositorySession(session.getRepositorySession());
>                 request.setInactiveProfileIds(
>         Arrays.asList("when-building-java-using-java8"));  ---> I
>         added this in order to try no get one of the errors reported.
>                 return projectBuilder.build(artifact,
>         request).getProject();
>             }
>
>
>     In order to test it I'm trying to read this [pom]
>     https://search.maven.org/classic/#artifactdetails%7Cbr.com.c8tech.releng%7Cfpom-deps-felix%7C2.1%7Cpom.
>
>     This POM has declared a POM fragment:
>
>>         <dependencyManagement>
>>             <dependencies>
>>                 <dependency>
>>     <groupId>br.com.c8tech.releng</groupId>
>>                     <version>2.1</version>
>>     <artifactId>fpom-deps-osgi</artifactId>
>>                     <scope>import</scope>
>>                     <type>pom</type>
>
>     And I'm using this code:
>
>         {
>
>          pom = loadProject(
>                             new
>         DefaultArtifact("br.com.c8tech.releng:fpom-deps-felix:pom:2.1"),
>                             true);
>
>         }
>
>     The error I'm getting from ProjectBuilder is about not being able
>     to get the versions declared in the imported POM ( declared in its
>     dependencyManagement) and also not being able to determine the
>     Java version of a profile activated by <jdk> property.
>
>
>>     Caused by: org.apache.maven.project.ProjectBuildingException:
>>     Some problems were encountered while processing the POMs:
>>     [ERROR] Failed to determine Java version for profile
>>     when-building-java-using-java8 @
>>     br.com.c8tech.releng:maven-parent-java:2.1,
>>     /home/cvgaviao/.m2/repository/br/com/c8tech/releng/maven-parent-java/2.1/maven-parent-java-2.1.pom,
>>     line 658, column 22
>>     [ERROR] 'dependencies.dependency.version' for
>>     net.java.dev.jna:jna:jar is missing. @
>>     br.com.c8tech.releng:fpom-deps-felix:[unknown-version],
>>     /home/cvgaviao/.m2/repository/br/com/c8tech/releng/fpom-deps-felix/2.1/fpom-deps-felix-2.1.pom,
>>     line 329, column 21
>>     [ERROR] 'dependencies.dependency.version' for
>>     ch.qos.logback:logback-core:jar is missing. @
>>     br.com.c8tech.releng:fpom-deps-felix:[unknown-version],
>>     /home/cvgaviao/.m2/repository/br/com/c8tech/releng/fpom-deps-felix/2.1/fpom-deps-felix-2.1.pom,
>>     line 337, column 21
>
> could someone tell me if its a missing feature, a bug or maybe am I
> missing something ?
>
>
> thanks a lot,
>
>
> Cristiano
>