You could use the build-helper-maven-plugin
and its attach-artifact
goal.
For instance, given the file.txt
file as part of a maven project and at the same level of its pom.xml
file, you could have the following pom:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>sample-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/file.txt</file>
<type>txt</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Note the configuration of the plugin: basically it is attaching as an additional artifact of the project the file.txt
file.
One note: as per default artifacts (in this case a jar
), also additional attached artifacts will follow a naming convention. In this case the file.txt
file will be renamed to sample-project-0.0.1-SNAPSHOT.txt
(to make it unique). Its content would not change though.
When installing (mvn clean install
), you would hence have the following artifacts created:
sample-project-0.0.1-SNAPSHOT.jar
> the default project artifact, based on project packaging
sample-project-0.0.1-SNAPSHOT.pom
> the pom.xml
file renamed with .pom
extension, used by dependency mediation above all to check transitive dependencies in case of libraries
sample-project-0.0.1-SNAPSHOT.txt
> the additional attached artifact