Christian Posta bio photo

Christian Posta

Global Field CTO at solo.io, author 'Istio in Action', 'AI Gateways in the Enterprise' and other books. He is known for being an architect, speaker, blogger and contributor to AI and infrastructure open-source projects.

LinkedIn Twitter Github Stackoverflow

Sometimes your build will contain other artifacts for a build other than the pom, a jar, etc. For example, you may wish to attach data-source configurations to that are meant to deploy along with your artifacts, or include other descriptor configurations like a features.xml file to be deployed into Fuse ESB aka ServiceMix. This makes it easier to use maven, or any other provisioning tool, to also grab the attached artifacts. To do this, use the build-helper-maven-plugin and the following configuration:

[xml]
<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>target/classes/features.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
[/xml]

If you would like to also filter/tokenize the artifacts before attaching them, add the following resource plugin:

[xml]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter</id>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
[/xml]