Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Correctly building dependencies from a POM

Graeme Rocher wrote:

         if (readPom) {
             def pomFile = new File(basedir, "pom.xml")

             final modelRequest = new DefaultModelBuildingRequest()
             modelRequest.setPomFile(pomFile)
             ModelBuildingResult modelBuildingResult =
modelBuilder.build(modelRequest)
             final mavenDependencies =
modelBuildingResult.getRawModel().getDependencies()

[...] The problem I'm running in to is that properties are not correctly
evaluated.

This is to be expected when using getRawModel(), cf. its javadoc which reads "the raw model has not undergone any updates by the model builder, e.g. reflects neither inheritance nor interpolation".

Is there a correct way to convert the Maven model into the Aether model
that deals with this issue?

I suggest to peek at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor() to get an idea of the required bits.

For things like parent POMs or imported POMs to work, you probably also want to pass a ModelResolver into the ModelBuildingRequest.


Benjamin


Back to the top