1

I am trying to export a jar with a bundled file (readme.md) via the pom.xml

I want the exported jar to look like this:

enter image description here

I tried using maven jar plugin as depicted below. However, I get a java file but no readme.md inside it.

Here is my plugin:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
    <execution>
        <goals>
            <goal>jar</goal>
        </goals>
        <configuration>
            <classesDirectory>src</classesDirectory> 
            <includes>
                <include>**/*dummy/Dummy*</include>
                <include>**/*.md</include>
            </includes>
            <finalName>mydummyjar</finalName>
        </configuration>
    </execution>
</executions>

My file-system looks like this:

enter image description here

How I get the structure in the picture above?

Thanks in advance.

Update

Thanks for Veselin Davidov, The next code worked for me:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
    <execution>
        <goals>
            <goal>jar</goal>
        </goals>
        <configuration>
            <classesDirectory>/</classesDirectory>
            <includes>
                <include>**/*dummy/Dummy*</include>
                <include>readme.md</include>
            </includes>
            <finalName>mydummyjar</finalName>
        </configuration>
    </execution>
</executions>

Hesham Yassin
  • 4,341
  • 2
  • 21
  • 23
  • 1
    Just add it into the includes part. Or you can do includes **/* to include everything. Or add it as resource like: https://stackoverflow.com/questions/28561590/howto-copy-readme-md-into-src-main-resources – Veselin Davidov Feb 27 '18 at 13:00
  • 1
    Did you try **/*.md – gargkshitiz Feb 27 '18 at 13:01
  • 1
    The simplest solution is to put the `README.md` into `src/main/resources` which is the correct way...apart from that a `README.md` inside a JAR file does not make sense cause a JAR should never contain things like that. Furthermore you should start accepting the convention in Maven to have directories like `src/main/java`, `src/main/resources` etc...otherwise you make you life even harder... – khmarbaise Feb 27 '18 at 13:05

0 Answers0