0

I need to pre-process some of the resource files (*.xsl) in a Java Maven project. I found the exec-maven-plugin which is able to execute shell commands and thought I can do it in 2 steps:

  1. match a list of files and write it to a file
  2. launch a Java program that pre-processes each file from the list

However I don't get any output from the find command I am trying to execute. The plugin configuration in POM looks like this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>inline-xml-entities</id>
            <phase>generate-resources</phase>
            <configuration>
                <executable>find</executable>
                <useMavenLogger>true</useMavenLogger>
                <outputFile>xsl-files.txt</outputFile>
                <arguments>
                    <argument>./src/main/webapp/static/com/atomgraph/</argument>
                    <argument>-type</argument>
                    <argument>f</argument>
                    <argument>-name</argument>
                    <argument>'*.xsl'</argument>
                </arguments>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I can see in the mvn clean install -X log that the command gets executed:

[DEBUG] Executing command line: [find, ./src/main/webapp/static/com/atomgraph/, -type, f, -name, '*.xsl']

The xsl-files.txt file gets created, but it's empty :/

If I go to the project basedir and execute find ./src/main/webapp/static/com/atomgraph/ -type f -name '*.xsl' manually, I get a list of .xsl files as expected:

./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/imports/acl.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/layout.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl
...

What am I missing?

1 Answers1

0

This seems to have worked:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>find-xsl-files</id>
            <phase>generate-resources</phase>
            <configuration>
                <executable>find</executable>
                <workingDirectory>src/main/webapp/static/com/atomgraph/</workingDirectory>
                <outputFile>xsl-files.txt</outputFile>
                <commandlineArgs>. -type f -name '*.xsl'</commandlineArgs>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>