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

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>

Related

Cannot access class and methods from custom jars in Maven

I have created a project in java and compiled it as a jar with the mvn clean install command. The jar is in my local .m2 folder. I am trying to import it as a dependency in a new project. The jar is successfully imported into my new project but I cannot access any classes or methods in that jar.
<dependency>
<groupId>com.test</groupId>
<artifactId>rest-methods</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
This my custom maven dependency imported in my External Libraries
And this is when I try to use these class and any method inside it in my project:
When I try to add the maven dependency manually I can find it and I can click add but nothing happens
Am I missing some steps for using this class in my project? I am working on a Ubuntu 20.04 operating system
UPDATE: After looking in the Project Structure -> Project Settings -> Libraries I see that several files from the jar are marked as excluded (sources and JavaDocs):
Did they not get build properly when I created the jar ?

Maven not importing External Library into project after adding to .pom file in Intellij

I'm having trouble correctly importing a library into a project that I'm running. I have added the library as a dependency in the .pom, refreshed the pom, run mvn clean install, and I have set auto-import up so that the project gets updated correctly, but the project does not get added as an External Library, and I can't use it in my project. I get no errors. What am I doing wrong?
Here is the relevant part of my pom
..properties
<crowd.version>2.5.0</crowd.version>
.. end properties
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atlassian.crowd</groupId>
<artifactId>crowd-integration-springsecurity</artifactId>
<version>${crowd.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
Here is the question I was following to debug my error:
Import Maven dependencies in IntelliJ IDEA
I think you missed the point of dependency management; read more in official docs. This is a feature that you can centralize common dependency information that is then shared been different projects. All by itself, this definioition will not import the dependency.
What you probably want is just a plain dependency: drop the dependencyManagement tags, and move you dependency into the correct block in the pom.

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

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).

How to attach JavaFX2 javadoc jar automcatically with maven?

I have in my pom.xml the dependency to jfxrt.jar, as a system scope one:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${java.fx.version}</version>
<scope>system</scope>
<systemPath>${javafx.abs.dir}</systemPath>
</dependency>
The problem is I would also like to attach the javadoc for this jar. So I went and downloaded the javafx2 javadoc,packed it into a jar, installed it in maven using install file and using javadoc as a classifier. The resulted jar has name javafx-2.2.4-javadoc.jar. As you know the main jar has name jfxrt.jar.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${java.fx.version}</version>
<classifier>javadoc</classifier>
</dependency>
When I call mvn dependency:resolve -Dclassifier=javadoc I get:
[INFO] The following files have NOT been resolved:
[INFO] com.oracle:javafx:java-source:javadoc:2.2.4
What am I missing?
Regards,
Aurelian
Well, you don't want the javadoc as dependency, I guess, you probably just want the IDE to show the JavaDoc. I just tried the following in NetBeans and it worked:
select a referenced JavaFX class and hit CTRL+SPACE to show the JavaDoc
The pop-up provides links to configure the JavaDoc
don't use the system dependency for binary, just install:install-file it into local repo as you did with the javadoc.. then it should start working

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