1

We have a Maven extension which does some post actions at the end of build, but we want to extended its features by adding some flags/properties/something else in <configuration> block same as the way we do for plugin configurations in pom.xml. Is it possible to do that?

We tried adding it in pom.xml but it is throwing exceptions during build, also didn't managed find it in the docs.

Want to have something like below in the pom.xml:

<build>
  ...
  <extensions>
    ...
    <extension>
      <groupId>org.apache.maven.extensions</groupId>
      <artifactId>maven-test-extension</artifactId>
      <version>1.0-SNAPSHOT</version>
      <configuration>
        ....
      </configuration>
    </extension>
    ...
  </extensions>
  ...
</build>
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • I suppose there is no possibilty to pass configuration to extensions. A rarely used feature, usually you would use a plugin for that kind of tasks? – Gyro Gearless Feb 06 '18 at 14:40
  • No that's not possible at the moment (see [MNG-5897](https://issues.apache.org/jira/browse/MNG-5897)). Can you explain what your extension is doing? Maybe it would be better to implement it as a plugin? – khmarbaise Feb 06 '18 at 16:14
  • @GyroGearless @khmarbaise thanks, yes plugin is an another option. Extension is running at the end of build using `afterSessionEnd` and `MavenSession.getAllProjects(), Artifact.getArtifact()`, it list all the artifacts generated in the build. so was wondering if we convert this to plugin is it possible to run it in post same like extensions ? – Reddysekhar Gaduputi Feb 07 '18 at 04:18
  • For what purpose do you need such information? – khmarbaise Feb 07 '18 at 08:00
  • We are generating that info for Clean up process. – Reddysekhar Gaduputi Feb 07 '18 at 14:18
  • Seems like `true` is doing the trick here, extension configured as a plugin with `` block and it is working as expected. ... ... org.apache.maven.extensions maven-test-extension 1.0-SNAPSHOT true .... ... ... – Reddysekhar Gaduputi Feb 08 '18 at 03:54

1 Answers1

1

We tried it in different way, we have configured the extension as plugin using <extention>true</extension> in pom.xml and it accepts the <configuration>....</configuration> block.

  • 1
    Question: from the extension code, how do you get the configuration? – LppEdd Oct 29 '22 at 09:53
  • I think it is worth mentioning that this is only for build extensions. Core extensions are not registered via the pom.xml, so your solution will not work. – Özgün Jul 27 '23 at 12:19