Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven pom's resource element

Tags:

maven

pom.xml

i am new to maven and came across the resources section. The reference for the maven project descriptor (version 4.0) states that "this element describes all of the classpath resources associated with a project or unit tests" (link). However this description i do not understand/seems to abstract for me. Why would i want to describe classpath resources? How does it affect the projects lifecycle?

matthias

like image 937
Matthias Avatar asked Jul 03 '12 09:07

Matthias


People also ask

Where do I put the resource tag in POM?

Via the resources area in the pom you can filter files from their way src/main/resources to the target/classes folder. The lifecycle of Maven is not influenced by this. I have added resources successfully in . Jar file.

How do I add a resource to a Maven POM?

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 the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.


1 Answers

usually you have the src/main/resources folder which contains resources which will be packaged into a jar. This everything which is in the above folder will automatically be packaged into a jar and is accessible via getResource... Via the resources area in the pom you can filter files from their way src/main/resources to the target/classes folder.

<project>
  ...
  <name>My Resources Plugin Practice Project</name>
  ...
  <build>
    ...
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      ...
    </resources>
    ...
  </build>
  ...
</project>

The lifecycle of Maven is not influenced by this.

like image 68
khmarbaise Avatar answered Sep 30 '22 18:09

khmarbaise