Fork me on GitHub

Iterator Maven Plugin

Using Folder

The iterator-maven-plugin can be used to iterate over folders which might be helpful in some situations cause it's dynamic and not fixed in the pom file.

.
src/
├── main
│   ├── java
│   │   └── com
│   │       └── soebes
│   │           └── maven
│   │               └── multiple
│   │                   ├── first
│   │                   ├── second
│   │                   └── third

Let us think you would like to iterate over the folders first, second and third.

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<plugin>
  <groupId>com.soebes.maven.plugins</groupId>
  <artifactId>iterator-maven-plugin</artifactId>
  <version>0.5.1</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>iterator</goal>
      </goals>
      <configuration>
        <folder>src/main/java/com/soebes/maven/multiple/</folder>
        <pluginExecutors>
          <pluginExecutor>
            <plugin>
              <groupId>com.soebes.maven.plugins</groupId>
              <artifactId>maven-echo-plugin</artifactId>
            </plugin>
            <goal>echo</goal>
            <configuration>
              <echos>
                <echo>This is a message: @item@</echo>
              </echos>
            </configuration>
          </pluginExecutor>
          <pluginExecutor>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <goal>jar</goal>
            <configuration>
              <includes>
                <include>com/soebes/maven/multiple/@item@/**</include>
              </includes>
              <classifier>@item@</classifier>
            </configuration>
          </pluginExecutor>
        </pluginExecutors>
      </configuration>
    </execution>
  </executions>
</plugin>

During the execution the values for item will be first, second and third.