0

Am trying to execute below command using maven-exec plugin, but it is not recognizing the executables properly.

command am trying to execute

find . -name "pom.xml" -exec sed -i s/1.0/\$\{revision\}/g {} +

below is my plugin configuration in main pom.xml

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>3.0.0</version>
  <executions>
    <execution>
      <id>Execute Find and Sed</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>find</executable>
        <arguments>
          <argument>.</argument>
          <argument>-name</argument>
          <argument>pom.xml</argument>
          <argument>-exec</argument>
          <argument>sed</argument>
          <argument>-i</argument>
          <argument>s/1.0/${revision}/g</argument>
          <argument>{}</argument>
          <argument>+</argument>
        </arguments>
      </configuration>
    </execution>
  </executions>
</plugin>

getting below error

ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (Execute-Find-Sed) on project core: The parameter 'executable' is missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
  • Can you explain why you are trying to replace `${revision}` with `1.0` ? Is there a reason for that? – khmarbaise Jun 29 '23 at 20:32
  • we have tried implementing Maven Friendly version using ${revision}, it is working properly when we run the build from main pom. but if we run the build from any grand child pom then build is failing due to transitive dependencies. this we have noticed only on our own dependencies which has trasitive dependency on other pom.while gathering transitive dependency pom is looking for ${reivision} instead of 1.0.so we are trying to change the version using exec plugin.this issue presists only when we refer our own dependency in other pom's. pls advise if there is any better way to implement this. – Ramesh Thiyagarajan Jun 30 '23 at 04:56
  • `but if we run the build from any grand child pom then build is failing due to transitive dependencies. ` that's correct because a multi module build has a foundation using the same version. If you use a child instead of starting from the root that might cause a lot of issues. Apart from that If you really need to change the version via command line you could use https://www.mojohaus.org/build-helper-maven-plugin/parse-version-mojo.html in combination with verisons-maven-plugin makes it easier... – khmarbaise Jun 30 '23 at 11:59

0 Answers0