views:

17

answers:

1

I have a property file which is not located in a classpath in Maven.

Therefore I can't reach it with:

ClassLoader.getSystemClassLoader().getResourceAsStream(PROPS_FILE);

How can I add the folder containing the property file to the classpath, so it will be available during build and test of the project?

A: 

Under the task you can add a set of resources and testResources like so:

  <resources>
    <resource>
      <directory>somedir</directory>
    </resource>
  </resources>

  <testResources>
    <testResource>
      <directory>test/unit</directory>
    </testResource>
  </testResources>

They also allow you to define exclusion and inclusion rules. This is very powerful for a legacy code base but for new code bases, you should follow the maven's standard directory layout to avoid lots of custom definitions in your POM files.

Dan