8

I would like to include scripts files as part of packaging test files using maven. I ma using the below plugin configuration however config and jython files the files are not package in the test jar

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>**/config/*</include>
                            <include>**/jython/*</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

is there anyway to include the files which are not in src/test/java and src/test/resources in test-jar?

Venkat
  • 91
  • 1
  • 4

1 Answers1

9

Specify additional test resource folders using:

<build>
    <testResources>
        <testResource>
            <directory>src/test</directory>
            <includes>
                <include>**/config/*</include>
                <include>**/jython/*</include>
            </includes>
        </testResource>
    </testResources>
</build>

You should then find that no config is required for the maven-jar-plugin.

The build-helper-maven-plugin may also be used. See: Maven - Add directory to classpath while executing tests

jwilner
  • 6,348
  • 6
  • 35
  • 47
Chris Beach
  • 4,302
  • 2
  • 31
  • 50
  • 5
    Great answer. The only thing I'd like to add is: should be src/test/ (no leading /) instead of / which will scan the entire hard drive. – Christopher Yang Sep 23 '14 at 20:21