Maven Build Plugin: Excluding Files Using the Standard Ref Descriptor

I am developing a simple standalone Java command line application. The project is managed by Maven. I would like to build a shipped one that you can copy and run on the client machine.

The maven-assembly plugin with the standard jar-with-dependencies type is suitable for me, but I do not want to pack the log4j.properties file into a jar. I would prefer it in a separate "res" folder.

I managed to put the class header in the manifest file for the res folder, but I had problems excluding the log4j.properties file from the generated jar.

I am trying to exclude this file without writing a custom assembly descriptor. I would like to configure a default solution, for example:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>**/log4j.properties</exclude>
        </excludes>
      <archive>
            <manifest>
              <mainClass>com.my.App</mainClass>
            </manifest>
            <manifestEntries>
                <Class-Path>res/</Class-Path>
            </manifestEntries>
      </archive>
      <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration></plugin>

. ?

+3
1

doc, , , <plugin>.

<excludes> , , .

+2

Source: https://habr.com/ru/post/1792810/


All Articles