Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include non Java files and resources files to test-jar using maven jar plugin

Tags:

maven

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?

like image 604
Venkat Avatar asked Jan 09 '13 09:01

Venkat


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>

Does maven include test classes in jar?

You can produce a jar which will include your test classes and resources. To reuse this artifact in an other project, you must declare this dependency with type test-jar : <project>

Which plugin is used to copy filter include and exclude non java files into your final project?

pedr0: you should utilize the resources plugin in that case to manually include/exclude non java files copy.

What is the difference between jar and plugin?

plug-in is a software component that adds a specific feature to any computer program.It specially use to customize any computer program. But . jar file is a java executable file which can only run on an environment which Java installed.


1 Answers

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

like image 107
Chris Beach Avatar answered Oct 14 '22 13:10

Chris Beach