1

I have directory with 100 files under it. I just want to print it. Please find below the plugin I have written. I am getting following error:

[ERROR] PluginConfigurationException: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.apache.maven.plugins:maven-antrun-plugin:1.7:run for parameter outputDirectory: Cannot find 'outputDirectory' in class org.apache.maven.plugin.antrun.AntRunMojo at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:605) at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:537) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:120) at com.soebes.maven.plugins.iterator.ExecutorMojo.executeMojo(ExecutorMojo.java:302)

The code is as below:

<plugin>
            <groupId>com.soebes.maven.plugins</groupId>
            <artifactId>iterator-maven-plugin</artifactId>
            <version>0.3</version>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>iterator</goal>
                </goals>
                <configuration>
                  <folder>${user.home}/${dasmo.storage}</folder>
                  <pluginExecutors>
                    <pluginExecutor>
                      <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                      </plugin>
                      <goal>run</goal>
                      <configuration>
                        <tasks>
                            <echo message="base dir is ${item}" />
                        </tasks>
                      </configuration>
                    </pluginExecutor>
                  </pluginExecutors>
                </configuration>
              </execution>
            </executions>
          </plugin>
Yeshwant KAKAD
  • 279
  • 1
  • 6
  • 16
  • Note: Depending on your OS, there are probably better ways to print the contents of a folder. – Aaron Digulla Feb 24 '15 at 09:01
  • What is your intention for using iterator-maven-plugin? – khmarbaise Feb 24 '15 at 09:13
  • Aaron Digulla and Khmarbaise, basically I have 100 zip file in my directory. I want to unzip each one of these files. I do not want to specify hardcoded value of zip file. So, that is the reason I am using iterator. – Yeshwant KAKAD Feb 24 '15 at 10:08
  • Are those zip files generated by a maven build? Create a maven-assembly-descriptor and you don't need to defined all zip files.. – khmarbaise Feb 24 '15 at 10:31
  • Khmarbaise, thanks. No, those 100s of zipped files are created by me. Its not created by Maven Build. Thanks. – Yeshwant KAKAD Feb 25 '15 at 02:44

1 Answers1

2

Maven uses DefaultMavenPluginManager.populatePluginFields() to copy values from the POM into fields of the plugin. In your case, the manager has decided that the plugin org.apache.maven.plugins:maven-antrun-plugin:1.7:run (implemented by org.apache.maven.plugin.antrun.AntRunMojo) must know the value of outputDirectory and tries to set it.

I don't see a reason why DefaultMavenPluginManager thinks that the mojo (plugin) would need this property since it's not mentioned in the POM. My next step would be to start my debugger and step through the code to see where DefaultMavenPluginManager gets the list of properties to configure in a mojo. Maybe you can influence this or there is a configuration error elsewhere (like in the parent POM).

[EDIT] If you want to unzip many files at once, Maven is probably the wrong tool. Try Ant which can be configured to do the task with just a few lines in build.xml. See this question for a solution: How do you use ant to unjar multiple JAR files and rebuild them into one JAR file?

Alternatively, you can use PowerShell on Windows to do the job in a script or use this script on Linux:

for f in *.zip ; do
    unzip "$f"
done
Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820