How to use

Brief examples on how to use the build-helper-maven-plugin's goals.

add-source

Use this example to add more source directories to your project since pom.xml only allows one source.

<project>

  ...
  <build>
   <plugins>
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>some directory</source>
                ...
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

add-test-source

<project>

  ...
  <build>
   <plugins>
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-test-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>some directory</source>
                ...
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

attach-artifact

Typically run after antrun:run to attach antrun's build outputs to the project for install and deploy.

<project>

  ...
  <build>
   <plugins>
   
     <plugin>
       <!-- add antrun configuration here -->
     </plugin>
        
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                  <artifact>
                    <file>some file</file>
                    <type>extension of your file </type>
                    <classifier>optional<classifier>
                  </artifact>
                  ...
                </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>