How do I obtain a fully resolved Model of a pom file?

前端 未结 6 493
时光取名叫无心
时光取名叫无心 2021-01-30 11:40

How do I obtain a fully resolved Model of a pom file?

This is basically a rephrasing of How can i programmaticaly build the effective model of a pom file?

I\'m b

6条回答
  •  难免孤独
    2021-01-30 12:42

    Maybe is too late for you but if it can help others in the future. So I did it like that:

    @Component
    private RepositorySystem repositorySystem;
    
    @Component
    private MavenProjectBuilder mavenProjectBuilder;
    
    @Parameter(property = "project.remoteArtifactRepositories")
    protected List remoteRepositories;
    
    @Parameter(property = "localRepository")
    protected ArtifactRepository localRepository;
    
    ...
    Artifact pomArtifact = repositorySystem.createProjectArtifact(groupId, artifactId,version);
    MavenProject project = mavenProjectBuilder.buildFromRepository(pomArtifact
                              , remoteRepositories, localRepository);
    

    And that's it. It should work. If you have some special packaging (e.g. bundle...) In the target pom project make sure the plugins associated to those packaging are installed in your current project.

提交回复
热议问题