Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package resources only as jar using maven

Tags:

maven

jar

I want to package only resources under directory src/main/resources into the jar published by maven. Is there a way to do that?

like image 836
zihaoyu Avatar asked Jan 08 '13 14:01

zihaoyu


People also ask

How do I add resources to my jar Maven?

To include a resource, we only need to add an <includes> element. And to exclude a resource, we only need to add an <excludes> element. For example, if we want to include all text and RTF files under our src/my-resources directory and in all its subdirectories, we can do the following: <project>

What is packaging jar in Maven?

Overview. The packaging type is an important aspect of any Maven project. It specifies the type of artifact the project produces. Generally, a build produces a jar, war, pom, or other executable. Maven offers many default packaging types and also provides the flexibility to define a custom one.


1 Answers

Try following:

<build>
  <resources>
     <resource>
       <directory>src/main/resources</directory>
       <filtering>false</filtering>
    </resource>
  </resources>
  <plugins>
    <plugin>
       ...
    </plugin>
  </plugins>
  ...
</build>

As far as I can understand, it could be what you asked for.

like image 194
Reporter Avatar answered Oct 19 '22 19:10

Reporter