Add Javadoc/source to Joda-Time when imported as Maven dependency - maven

I'm new to Maven and the Joda-Time library.
Is there a simple way to add Javadoc/source code to the Joda-Time library when I import it with Maven?
This is what I added to the pom.xml:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
Thanks.

If you are using Eclipse with the Maven Plugin you'll find this setting under: Preferences / Maven / Download Artifact Sources and Download Artifact JavaDoc

For Netbeans8 IDE In Your maven project:
Choose services folder.
Click 'Maven Repositories'.
Click 'Central Repository'.
Find joda-time.
Double click joda-time artifact group.
Double click the joda-time artifact.
Choose your version number.
Right click and add dependency.
It will then be added to your pom.xml and be
downloaded and compiled into your project.

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>

Adding external JAR to Maven project in NetBeans

When I right click on my Maven project and choose the Add dependency option and I type my external jar's name in query, it is not found. How to add external jar to a Maven project?
From the NetBeans forum:
Open the Projects tab.
Right-click on Dependencies.
Select Add dependency.
Set groupId to: group.id (can be anything)
Set artifactId to: artifact.id (can be anything)
Set version to: 1.0 (can be anything)
Click Add to continue.
Dependency is added to pom.xml and appears under the Libraries node of Maven project. Continue:
Expand Dependencies.
Right-click on library (e.g., group.id).
Select Manually install artifact.
Set Artifact to install with the Java Archive (.jar) file path.
Click Install locally.
Library is installed locally with dependency attributes (coordinates) entered in steps 4 - 6.
I found those instructions helpful when going through the NetBeans GUI. Basically when right clicking to add a dependency, the group id, version, and name must be populated with anything. Then that "dependency" will be listed in the dependency drop down. Right click on that newly created dependency and right click to install locally and navigate to the appropriate jar file.
You can follow this tutorial:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Example:
Install the jar to your local maven repository:
mvn install:install-file -Dfile=cxf-2.7.3.jar -DgroupId=org.apache.cxf -DartifactId=cxf-bundle -Dversion=2.7.3 -Dpackaging=jar
Edit the pom.xml file in your project to include the newly added dependency:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.3</version>
</dependency>
This should work regardless of the IDE you are using.
In Netbeans, the approach to adding dependencies that are not in repository is reversed. First come up with maven coordinates in the Add Dependency dialog. Then right click on the new dependency node and trigger "Manually install Artifact" action.
This answer is for jars that are in the maven repo
Let's say I want to add log4j-1.2.17.jar to my project, all I have to do is find it in maven repository
Step 2 is to copy that and place it inside the dependencies tag of your pom.xml` file:
<dependencies>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
....
....
<dependencies>
Step 3 Build and clean your project. The jar file will be in your dependencies folder afterwards
one trick is in the netbeans main menu select: profile->options->java->maven put in the global execution options the parameters example: -Dfile=C:\Users\anonym\Desktop\commons-pool-1.6.jar -DgroupId=commons-pool -DartifactId=commons-pool -Dversion=1.6 -Dpackaging=jar
where de parameter -Dfile is the location of the jar file
-Dfile=routeToJar
after that select your project. then rigth clic on the select project. and then select Run Maven->Goal. when the wizard appear type in as Goals install:install-file .. and then clic OK buttom

Importing org.quartz and org.slf4j in Netbeans Maven Project

I'm looking to import support for org.slf4j and org.quartz in a maven project in Netbeans. However, I'm not able to figure out the exact steps. I'm unclear as to how should I configure these two packages (through their jar files) as artifacts.
My present Netbeans structure looks like this :
Rightclick on the dependency node, select Add dependency. In the query field, type org.quartz-scheduler. In the list that appears in Search Results fold open the node org.quartz-scheduler : quartz and click on the version you want (I'd go with 2.1.6 for now).
For org.slf4j the sequence is comparable.
Why don't you want to add them as maven dependencies in pom.xml?
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>1.7.2</version>
</dependency>
Netbeans has excellent integration with Ant and Maven and will pick the dependencies up by itself.

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

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.

Resources