ivy: prevent downloading sources and .txt files - ivy

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.

Related

Adding External Files to Mulesoft AnyPoint Studio

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 class path to a jar file on intellij idea?

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 .

Configure IDEA to deploy using ivy

I have a project that uses IVY. My build script resolves the dependencies well.
I have a library (lets call it Project_libs) configured in IntelliJ iml file so that when I deploy the application the jars get published to the server.
I have an ant task ide-setup which copies the necessary jars from Ivy local repo to Project_libs so these jars are available to IDEA during deployement.
Lets say I make changes to a common library like utils.
Build the common library.
Go to the projects that declared this common library as a dependency and run ide-setup
Then start the server.
Is there a direct way in which I can configure IDEA to read the dependencies from the ivy.xml file instead of doing this convoluted process of setting up the whole thing.
I don't know anything about InelliJ IDEA, but I believe you could accomplish what you want using ant and IVY. From the IVY documentation
<ivy:buildlist reference="build-path" ivyfilepath="ivy/ivy.xml" leaf="mymodule">
<fileset dir="projects" includes="**/build.xml"/>
</ivy:buildlist>
Builds a list of build.xml files sorted according to the ivy.xml files found in an
ivy directory relative to those build files. Only build.xml files of modules which
have dependencies (direct or transitive) on mymodule are put in the result list.
So if you set leaf equal to utils, it could return you a list of build.xml files that depend on utils in dependency order. Then all you would have to do is go through those build.xml files in order and invode their build process (probably through a subant call)

maven install file manually without version

How do I add a jar file to my local repository without appending the version number to the jar file?
Lets say I have a jar file named abc.jar and run the following command, it will create abc-1.0.jar and if I bundle this artifact in a war file, the resulting file name will be abc-1.0.jar. If I remove the -Dversion, the command fails. If I mention blank value -Dversion="", then abc-.jar is created. How do I keep the original jar's filename(abc.jar)?
mvn install:install-file -Dfile="d:\abc.jar" -DgroupId=grp1 -DartifactId=art1 -Dversion=1.0 -Dpackaging=jar
How do I add a jar file to my local repository without appending the version number to the jar file?
You can't.
This works for war packages. I haven't tried it for jars.
<build>
<!-- Ensures that the version number is not included in the packaged file name -->
<finalName>myrenamedpackage</finalName>
</build>
You can not change the name of the arifact in your maven repository, but you can configure the war plugin to use a specific nming scheme for the libs it bundles in WEB-INF/lib using the outputFileNameMapping option. To remove version information and classifiers the mapping pattern would be #{artifactId}#.#{extension}#. If the artifact id matches the original filename this should give the wanted result.

Include XSD in Jar with Maven?

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.