user1947544
user1947544

Reputation: 23

Maven Build Jar with Resource in Package

I'm trying to build a Jar with Maven, and I would like to put one of my resources directly in the Java packages, but I cannot figure out how to do so. For example, if my maven project looks like this

src/main/java
--com
---company
----application
-----database


src/main/resources
--config.xml

I want a jar where config.xml ends up in com/company/application/database. Any idea how to do so? I'm using eclipse 4.5.1 with maven 3.3

Upvotes: 1

Views: 105

Answers (2)

user1947544
user1947544

Reputation: 23

I figured this out. Here is what when in my pom.xml:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.outputDirectory}/com/company/app/common/tablebeans/shared</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/main/resources</directory>
                                <includes>
                                    <include>**/*hibernate*xml</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>

Upvotes: 0

ozborn
ozborn

Reputation: 1070

If you want to put config.xml in com/company/application/database you can create that directory under resources and put config.xml in there.

cd src/main/resources
mkdir -p com/company/application/database
mv config.xml /com/company/application/database/

Upvotes: 1

Related Questions