You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Torsten Liermann <of...@liermann-it.de> on 2021/06/28 14:27:24 UTC

change the location of pom File within maven extension

Hi,

My English is poor, but I hope for help in this place.

I am trying to manipulate an org.apache.maven.model.Model via a maven extension and at the same time create a new POM file. But unfortunately the new location of the POM file does not apply. The plugins (e.g. maven-deploy-plugin) still work with the original file location.

// Part of Model Processor
@Override
  public Model read(InputStream input, Map<String, ?> options) throws IOException {
        Model model = read(input, options);
        // This has no effect:
        model.setPomFile(new File(„new-pom.xml“);
        return model;
    }


This example here helped me a little:
https://github.com/jcgay/unique-revision-maven-filtering/blob/master/src/main/java/fr/jcgay/maven/extension/revision/UniqueRevisionFiltering.java

The maven-install-plugin uses the desired file location, but the maven-deploy-plugin uses the old file location.

At the plugin level, changing the POM file location works, as can be seen on the flatten-maven-plugin:

      this.project.setPomFile (flattenedPomFile);

But how does that work with a maven extension?

Thanks for a hint.

Regards,
Torsteen


Re: change the location of pom File within maven extension

Posted by to...@googlemail.com.INVALID, to...@googlemail.com.INVALID.
Thanks, Falko. In my question I mentioned the flatten plugin with snippets of code. Can I access MavenProject in a Maven Extension? The flatten plugin uses this Injection @Parameter (defaultValue = "$ {project}", readonly = true, required = true)
     MavenProject project;

What would the equivalent in an extension be? Thanks!

On 2021/06/28 17:33:52, Falko Modler <f....@gmx.net> wrote: 
> Hi,
> 
> I think flatten-maven-plugin is doing something like that, see: https://github.com/mojohaus/flatten-maven-plugin/blob/4efae7e8d180e838ff25a1daffab712166911328/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L224
> 
> Cheers,
> Falko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: change the location of pom File within maven extension

Posted by Torsten Liermann <of...@liermann-it.de>.
Right, Falk. But unfortunately I'm just creating the model (ModelProcessor). Therefore the attempt to set the correct POM file via model.setPomFile (), but unfortunately it does not work. There are certainly extension points that maven calls at a later point in time, but unfortunately I am not familiar with them and there is probably no documentation on this topic. (sorry, google translate)

On Mon, 28 Jun 2021 19:59:59 +0000 (UTC)
 Falko Modler <f....@gmx.net> wrote:
>Sorry, I totally missed that flatten bit in your message.
>
>You can access all projects via the MavenSession that get's passed in to your extension.
>See getProjects().
>
>Cheers,
>Falko
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: change the location of pom File within maven extension

Posted by Falko Modler <f....@gmx.net>.
Sorry, I totally missed that flatten bit in your message.

You can access all projects via the MavenSession that get's passed in to your extension.
See getProjects().

Cheers,
Falko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: change the location of pom File within maven extension

Posted by Torsten Liermann <of...@liermann-it.de>.
Thanks, Falko. In my question I mentioned the flatten plugin with snippets of code. Can I access MavenProject in a Maven Extension? The flatten plugin uses this Injection @Parameter (defaultValue = "$ {project}", readonly = true, required = true)
     MavenProject project;

What would the equivalent in an extension be? Thanks!


On Mon, 28 Jun 2021 17:33:52 +0000 (UTC)
 Falko Modler <f....@gmx.net> wrote:
>Hi,
>
>I think flatten-maven-plugin is doing something like that, see: https://github.com/mojohaus/flatten-maven-plugin/blob/4efae7e8d180e838ff25a1daffab712166911328/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L224
>
>Cheers,
>Falko
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


change the location of pom File within maven extension

Posted by Falko Modler <f....@gmx.net>.
Hi,

I think flatten-maven-plugin is doing something like that, see: https://github.com/mojohaus/flatten-maven-plugin/blob/4efae7e8d180e838ff25a1daffab712166911328/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L224

Cheers,
Falko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org