We have an XSD file along with some java src files. How can we instruct Maven to include the XSD in the jar file output? Currently it appears to ignore the file.
Put the XSD file under src/main/resources folder. This should be enough. By default all files under this directory are copied to target/classes directory and from there are picked up by maven-jar-plugin by default.
Alternative, configure project/build/resources in your pom. See this reference.
Related
I have a simple Hello World project in AnyPoint Studio. I have folder of additional files (a few jar files and some configuration files) I want to include with the project so they can get published to the cloud (CloudHub). How do I include these files into my project so when I publish my application the additional files are packaged with them.
Part 2 - Say I have a json file I want to read from my Mule application. What path do I reference the json file with after it is published?
Mule 4 projects are Maven based. You need to reference those jar files as Maven dependencies. You might need to install those projects in your local Maven repository. Search for Maven tutorials if needed. Ideally those JAR files are available in Maven repositories and you add only the dependency snippet in your pom.xml. If you are building yourself you can use mvn install command. If they are third party JAR files that you have the file only you have to use the mvn install but you need to define the coordinates (groupId, artifactId, version) yourself, which is not ideal and Maven won't be able to do automatic dependencies resolution for those JAR files. See this answer for details.
In your source project resource files should be in src/main/resources. At execution time you don't need to add a directory. If you add the file in a subdirectory of src/main/resources you need to use the subdirectory name only.
How do you change the classpath to a jar file or a different directory?
Go to File-> Project Structure-> Libraries and click green "+" to add the directory folder that has the JARs to CLASSPATH. Everything in that folder will be added to CLASSPATH. Update: It's 2018. It's a better idea to use a dependency manager like Maven and externalize your dependencies. Don't add JAR files to your project in a /lib folder anymore.
I am attempting to add an external jar to my module's build path. I've added the jar as a module dependency and as a library, and the compiler is still unable to find the jar. I'm using intelliJ 14.1. I have verified that the jar is intact and not corrupt.
JAR manifest: IntelliJ IDEA will pass a long classpath via a temporary classpath.jar. The original classpath is defined in the manifest file as a class-path attribute in classpath.jar . You will be able to preview the full command line if it was shortened using this method, not just the classpath of the temporary classpath.jar .
How to tell IVY to not download source and .txt files. I have a dependency and it downloads license.txt files with it, when i use soemthing like this
<ivy:cachepath pathid="ivy-src-classpath" conf="compile"/>
it put the .txt files in the classpath which errors out while using java task
Unable to obtain resource from /home/muthiah/Work/ivy/cache/org.apache.commons/com.springsource.org.apache.commons.logging/licenses/license-1.1.1.txt: java.util.zip.ZipException: error in opening zip file
In your ivy.xml file add a configuration mapping to the other module's "default" configuration:
<dependency org="commons-lang" name="commons-lang" rev="2.5" conf="compile->default"/>
Without this mapping you're retrieving both the default and optional dependencies of the remote module.
Another good mapping (for Maven modules) to use is:
conf="compile->master"
This will retrieve the remote artifact without it's transient dependencies.
I had the same issue with multiple java.util.zip.ZipException: error in opening zip file in my ANT output logs, because there were licence .txt files in the classpath. The solution for me was to update the ivy:cachepath entry by adding type="jar":
<ivy:cachepath pathid="ivy-src-classpath" conf="compile" type="jar"/>
This will restrict only jar files to be added to the classpath.
Assuming I have a .properties file and hibernate.cfg.xml in a standard maven web application layout where should they be placed so that they are included in my .war file when I run package?
src/main/resources
src/main/java
src/main/webapp
src/main/config
?
Application/Library resources go in src/main/resources (they will end up in target/classes first after compilation and then in WEB-INF/classes in the war after packaging).
See also
Introduction to the Standard Directory Layout
I have customized pom.xml in maven to build a war file, for which i am compiling few class files which in deed depends on some jar files. Which i have included them as dependencies.
The build was successful but end result puts me in trouble now i have those class files included in my war which i don't want it.
So can you please help me to get rid of jar getting included in lib folder of war.
Regards
Gnash-85
You just have to change the "scope" of your dependencies in the Maven pom from "compile" (by default) to "provided". The "provided" libs won't be included in the final war file.
All options are listed on the Maven documentation.