0

I am trying to create an executable jar with all of its dependency along with the spring's configuration xml file.

Here is the definition of the maven-assembly-plugin in the pom.xml:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>service.coucou.Main</mainClass>
            </manifest>
        </archive>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <descriptors>
                     <descriptor>assembly.xml</descriptor>
                 </descriptors>
    </configuration>
</plugin>

This is the assembly.xml:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <includes>
                <include>/src/main/resources/cxf.xml</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

I am trying to include /src/main/resources/cxf.xml file in the created jar. But it is not including the xml. How can I include it in the jar?

Tapas Bose
  • 28,796
  • 74
  • 215
  • 331

1 Answers1

0

Replace the <fileSets/> with:

<fileSet>
  <directory>${basedir}/src/main/resources</directory>
  <includes>
    <include>cxf.xml</include>
  </includes>
</fileSet>
carlspring
  • 31,231
  • 29
  • 115
  • 197