I have a maven project with the following structure:
project
-src
--main
---java
----(All my .java files are here in their packages)
---resource
----(All my resources are here)
-database (HSQLDB files)
--db.script
--db.properties
--db.data
-target
--Maven build directory
pom.xml
I want the maven jar plugin to package in the database folder when it builds a JAR file. I've tried including as outlined here: https://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html, but it doesn't find the directory "../database" (or ../../database OR ../../../database!), and also it now doesn't include any of the classes or resources (It was including them before).
So what should I have in the configuration of the maven jar plugin? Which is the correct path to include and how do I keep the files it was including before?
Thanks
In order to compile the project into an executable jar, please run Maven with mvn clean package command. Hopefully, this article gives you some more insights on the topic and you will find your preferred approach depending on your needs. One quick final note – make sure the licenses of the jars you're bundling don't...
What you tried to do by configuring the maven-jar-plugin defines only the filetset to exclude or include in the built JAR. But these files still have to be located in a resources folder where Maven looks for resources. move database in the standard directory : src/main/resources.
There are multiple ways we can install local dependencies into maven projects Adding local dependencies systemPath in pom.xml install-file goal is a maven commands used to install local jar files This is easy and simple way to install jar from local repository or path of jar file.
This is easy and simple way to install jar from local repository or path of jar file. mvn install:install-file \ -Dfile=jar-file-path> \ -DgroupId=com.company.feature \ -DartifactId=feature \ -Dversion=version \ -Dpackaging=packaging \ -DgeneratePom=true -DcreateChecksum=true
By default, only resources located in src/main/resources
are added in the JAR.
What you tried to do by configuring the maven-jar-plugin
defines only the filetset to exclude or include in the built JAR.
But these files still have to be located in a resources folder where Maven looks for resources.
So, you have two ways to solve your requirement:
move database
in the standard directory : src/main/resources
.
specifies two resource
folders for resources :
To do the latter, in the pom.xml add in the build
tag :
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>database-resources</directory>
</resource>
</resources>
Then add the database
folder that you want package inside the database-resources
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With