I have a java project that includes a dependency using maven. With IntellyJ I can download and read the source code of this dependency, but I cannot change it.
I'm aware that any changes made to the dependency would be lost if not sent to the original repo. The changes would made only for debug/learning purpose.
Can I instruct maven to build the JAR dependency using the source code from a local path?
thanks.
Related
I am currently using the Eclipse IDE and want to import an external java project so that I can use it in something I am working on. I downloaded the directory of icePDF, found here, and would like to use the java class file "SwingViewBuilder.java" that is found in the directory I linked at "/icepdf/branches/icepdf-6.2.5/icepdf/viewer/src/org/icepdf/ri/common". I have tried some basic things like importing the folder itself, but it did not work.
I would highly suggest using a dependency management tool like Maven or Gradle to download this dependency and any other dependencies you may have into your project for you.
Here is the maven getting started guide: https://maven.apache.org/guides/getting-started/
And here is the maven dependency for you to add to your pom.xml file: https://mvnrepository.com/artifact/org.icepdf.os/icepdf-viewer/6.2.2
If you specifically need version 6.2.5, you will need to build the icePDF project yourself and configure your class path to use it as a dependency.
I have been trying to use the vget library/api to make my own youtube video downloader. The vget library can be found here: https://github.com/axet/vget
I have downloaded the zip on github and I imported the project into eclipse. However, I am confused to how I am supposed to properly use this API. Should I make a completely new project, and import the classes that I need or do I put my own source files in the project of the api?
I have read other threads concerning this problem. However, they all mention how a api is typically packaged in a JAR file, but in my case it is just files and classes. So I am confused to how I should properly use this api.
The vget project is a maven project. You can see that because it has a pom.xml file in the root folder of the project.
To use it, you don't even need to download the source, because the compiled jar files are already stored in the central maven repository. You can find more information about this here:
http://mvnrepository.com/artifact/com.github.axet/vget/1.1.23
(in general, you can use the http://mvnrepository.com/ site to search whether your library is available on the maven central repository. If it's even a mildly popular library, then chances are that it is)
What you need to do is to make your own project a maven project.
Here's a "5 minutes" starter guide that describes how to do that.
When you've done that, you just add the dependency on vget to your pom.xml file in the <dependencies> section:
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
Since you are making use of a 3rd party software, and not extending it with your own logic, the way to go is to create a new project, which references the 3rd party software.
You then construct your application and make it do whatever you need it to do. When it comes to using logic which is available within the 3rd party logic, you would then simply delegate that call to the 3rd party library.
I have seen on the link you have provided, that this is a maven project. You have to execute a maven package command, or maven install, so that the jar file will be generated.
With this jar follow the Bill's instructions, and add it as external library to your claspath.
When you do this, you will be able to invoke methods of that api.
Let us know if you need some help doing this in eclipse.
If your project is a maven project, you can solve dependencies problems just adding the dependency written on Readme file to your pom file.
The easiest and most automatic way is to use something like maven, ant, or gradle, that will automatically download and put the jars in to your classpath if they are in the central repositories. For example, in the maven configuration file(pom.xml) you can add this to the dependency list:
VGet Maven Repository
These build tools also allow you to add external jars if needed.
If
I would suggest you get familiar with Maven. At the bottom there is a Maven dependency you just have to include into your pom.xml, and then you can use the extension immediately.
Maven is a build platform which organizes your project in a technical way (convention over configuration, e.g. code is in /src/main/java, tests are in /src/test/java). The proper way is it to create a Maven project in Eclipse (you have to install the plugin and download Maven as well) and put the dependency
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
into your <dependencies> inside your pom.xml. After adding it, you project recognizes the additional package automatically.
Nobody tinkers by adding libraries manually. It's actually not professional to work without a build platform like Maven or Gradle.
I have a java maven project that has another module as a dependency.
That dependency has "-sources.jar" in the repository (and I can download the sources with mvn dependency:sources)
I now need to do some little one-line changes in the module I am using as a dependency. The ideal way would be to somehow copy this dependency as another module, with all its current sub-dependencies. Then when I build the whole project, I want to build my newly copied dependency and use it instead of the current dependency. (I hope it's clear what I want to do.)
However, I don't know at all how to do that, and if it's even possible.
edit:
To be clearer.
I have my own project. I am also using let's say com.example.dependency from a repository. There are however small bugs in the com.example.dependency module, so I want to download the source to me and fix it locally and use it as a submodule.
edit2:
I will add that the dependency is not any public project on github, etc. It is a module in a private maven repository that only I have an access to. I cannot clone the source control project. I can only use maven, and its dependency tracking, and the "dependency:sources" thing.
what you may to to do is to checkout your dependency source as new project and do the changes. Then modify your project version and do the
mvn install
to install it in your local repository, then you this version in your project as one of the dependency, you will add this dependency in usual way you have done earlier, but change the version to new version you have installed.
I'm trying to use JNI, and I'm using the maven-nar-plugin to package up the C++ code into a NAR. Now, I want to include this code in another Java project. How do I go about doing this properly?
It depends on how you want to use the dependencies created by maven nar plugin. From the documentation,
Other maven projects may specify
dependencies on these nar files using
the standard maven dependency
declaration. Nar files get downloaded,
unpacked and installed in the local
maven repository, just like jar files
are (apart from the unpacking).
The FAQ has a section on how to load the native library from java code.
Hope these help.
I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).
What I did was:
Add local repository to pom.xml
install the file into the local repository
Add dependency to pom.xml
Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)
The problem is that Eclipse still doesn't see the referenced lib, so this still fails:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
Pardon my maven newbiness, but what are changes / next steps I need to make to get to:
Have Eclipse see the library so that autocomplete works (and the import can be resolved)
Be able to compile the project
Be able to execute the jar produced by mvn package?
Thanks!
If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.
If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.
Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.