maven assembly how to add a zip flie from nexus repository to the build - maven

I am trying to include a zip file from nexus repository to my project during packaging using the maven assembly plugin. This zip file has YAJSW and other custom scripts. The maven assembly can build a tar.gz package now, but how do I include a zip file from nexus repository. There is a pom for that zip file. Should I just include that as dependency? Is this the correct plugin or should I use another plugin.
Thanks.

Add the dependency of the zip file like the following:
The following is an example for archive which has been created by maven-assembly-plugin:
<dependency>
<groupId>the.group.id</groupId>
<artifactId>the-artifactid</artifactId>
<version>1.0</version>
<type>tar.gz</type>
<cassifier>bin-unix</classifier>
</dependency>
<dependency>
<groupId>the.group.id</groupId>
<artifactId>the-artifactid</artifactId>
<version>1.0</version>
<type>zip</type>
<cassifier>bin</classifier>
</dependency>
The classifier in those cases is comming from the assembly-decscriptor-id in the project which creates the archive. Apart from that it is important to define the type.

Add a dependency to the zip with the respective GAV (group/artifactId/version).
(Without seeing your pom.xml it's a bit hard to say more).

Related

The jar file provided by Maven repository does not include class files

I need to use BaseDetectorTest provided from one of Spotbugs extension library
I added the maven dependency from (FindBugs Test Utility)
But it does not include the BaseDetectorTest class file (Once Maven is updated, the jar file is added to the external libraries - but not the class file).
I am wondering why it happens.
My guess is "the Jar file provided by the repository is still being developed"
Could you teach me how to fix it?
find-sec-bugs/findsecbugs-test-util/src/test/java/com/h3xstream/findbugs/test/BaseDetectorTest.java is a test class. .../src/test/... and ...Test.java are indicators for that. Test classes aren't included in a project's JAR (by the jar:jar goal of the Maven JAR Plugin which is the default binding for the package phase) but in a project's ...-tests.jar which is created by the jar:test-jar goal.
On MvnRepository select a version tag, e.g. 1.9.0, then Files jar (2 KB) View All to find the ...-tests.jar. Use it with:
<dependency>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findbugs-test-util</artifactId>
<version>1.9.0</version>
<classifier>tests</classifier>
</dependency>
On Maven Central you can get a later version (1.11.0), select it and then Browse 📁 to find it. Use it with:
<dependency>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-test-util</artifactId>
<version>1.11.0</version>
<classifier>tests</classifier>
</dependency>

Refer a jar which is inside a zip folder in Maven

I am working on maven multi module project and the maven version is 3.0.3.
The parent pom needs a particular jar which is inside a zip folder in Nexus.
So, I have included the dependency as below in the parent pom file.
<properties>
<standalonejar_version>5.5.0</standalonejar_version>
</properties>
<dependency>
<groupId>org.abc</groupId>
<artifactId>standalonejar</artifactId>
<version>${standalonejar_version}</version>
<type>zip</type>
</dependency>
Looks like it is not working and also, there are other modules in the same project which require that particular jar.
So, can you please help how to refer that particular jar which is inside the zip folder. Thanks a lot for your help.

Copy war dependency mentioned in maven jar module

The war dependency mentioned in jar project just to get copied from copy-dependency plugin/assembly plugin to use for some custom packaging. But plugin skip the war dependency , Is this plugin behaviour?
or need something else?
<dependency>
<groupId>com.external.modules</groupId>
<artifactId>war-jboss</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
Maven assembly plugin works on include and exclude. You would not be including your war file correctly. Check if you are using the correct regular expressions to include the war file in assembly plugin.

Can I download a jar file from maven central using maven?

I have a dependency problem with maven. I used to have saxon 8.7 that is located on maven central. Then, I had to upgrade to the latests saxon-b 9.1.0.0 which is only partially on maven central.
This is a snippet of my dependencies:
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon-dom</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
The first artifact 'saxon' is available on maven central, but the secon 'saxon-dom'. Here is the artifact I want.
Can I tell maven to download the "jar" file or am I obliged to download the jar and publish it locally on my maven repo to use it as a dependency?
Did not expect to resolve this so easily :
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<classifier>dom</classifier>
</dependency>
Basically, I can get the dependencies that are "attached" to the 'saxon' artifact using the classifier tag. Did not know about this and I found out that the tag existed when I searched for 'saxon' on Sonatype repository (which is quite good). It gave me the dependency snippet above.
Reference : http://maven.apache.org/pom.html
If the required version is not in the repo, then yes you need to do one of the following alternatives
Search for a public repo containing the required version of jar. And add the repo to your pom.xml file. OR
Download it manually, and install it locally on your machine, to help the project build completely.

Maven - Unable to resolve dependencies

Im trying to compile a Maven project. The compile fails however due to a "Failure to find xx.xxx.jar" in the repository i have specified in my settings.xml. I have access to this repository and when i navigate to the Url of the repository maven is trying to use i can see a pom file with the name of the jar but no jar. When i open the pom it contains the correct groupid and artificatid and jar name however the jar is not in the same directory.
Maven gives another error saying that "resolution will not be reattempted until the update interval of my repo-server has elasped or updated are forced".
What is happening here?
When maven goes to the repo i specify in settings.xml and finds a pom for the jar does it then try and go out to some external site to resolve the dependency or should the jar exist in the same folder as the pom?
What module are you attempting to download?
I discovered something similar with the following Maven central module:
http://search.maven.org/#artifactdetails|net.sf.json-lib|json-lib|2.4|jar
The Maven POM packaging declaration was jar, but no jar in Maven called "json-lib-2.4.jar"
When I looked at the files actually stored, I discovered that the author is providing two versions of the jar, each compiled for different versions of the JVM:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk13</classifier>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>

Resources