Maven and db4o dependency - java

I'm intrigued to test new frameworks in the Java world, and decided to create a new project that takes advantage of Maven and db4o. I'm starting to get a hang of Maven, but I have a hard time adding db4o as a dependency to the project. First problem is that db4o doesn't exist in the official Maven repositories. Next up comes the problem that db4o seem to have recently restructured their whole site's URI:s, so I'm getting 'site not found' messages all the time when I try to navigate their site.
I found somewhere a potential Maven repository that should be at https://source.db4o.com/maven but I get all the time "Error reading archetype catalog https://source.db4o.com/maven Unable to locate resource in repository" when I try to access it.
So, any suggestions on how I'll get db4o up through Maven? I've managing Maven through Eclipse with the M2Eclipse plugin.

Works for me with the following snippet:
<project>
<repositories>
<repository>
<id>source.db4o</id>
<url>http://source.db4o.com/maven</url>
</repository>
</repositories>
...
<dependencies>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-full-java5</artifactId>
<version>8.1-SNAPSHOT</version> <!-- latest version -->
</dependency>
...
</dependencies>
</project>

You won't see a dependency in m2eclipse unless the Maven repository has been indexed with the Nexus indexer...very few 3rd party repositories are.

Related

Add jnetpcap to maven fails

I try to add jnetpcap as a dependency to maven. I found on the internet the following that should be added to the pom file:
<dependency>
<groupId>jnetpcap</groupId>
<artifactId>jnetpcap</artifactId>
<version>1.4.r1425-1g</version>
</dependency>
I tried this with multiple version numbers, but maven can't find the version:
Dependency 'jnetpcap:jnetpcap:1.4.r1425-1g' not found (the version
is colored red).,
Also I tried to add the library via the project structure in IntelliJ. The Maven repository can find the jnetpcap library but when I try to import it i get:
No files were downloaded for jnetpcap:jnetpcap:1.4.r1425-1g.
The library can be manually imported via the jnetpcap.jar file but I need it as a maven dependency in my pom for creating a jar file of my project. Otherwise I get a jar file which can't execute since it is missing the dependency.
Does somebody know how I can include the dependency or otherwise how I can create a jar file of my project without missing this dependency?
The artifact is correct, however you are missing one little detail which is obvious, looking at the info page at mvnrepository.com:
https://mvnrepository.com/artifact/jnetpcap/jnetpcap/1.4.r1425-1g
Especially look at the table line Repositories. There you will see that this artifact is only listed in the "Clojars" repository, a non-standard repository you most likely have not added to your project.
Therefore adding the dependency is not enough, you also have to add the following section:
<repositories>
<repository>
<id>Clojars</id>
<name>Clojars</name>
<url>https://clojars.org/repo/</url>
</repository>
</repositories>
The version of the jar you are requesting is not published to the maven repository.
This would work
<dependency>
<groupId>jnetpcap</groupId>
<artifactId>jnetpcap</artifactId>
<version>1.4.r1425-1g</version>
</dependency>

GitLab AutoDevops with Oracle artifacts

I've set up a GitLab project that uses Oracle JDBC. The Oracle driver is not in Maven Central Repository, so I've added it on my project manually. That means that, locally, my builds run just fine.
The catch: I want to use GitLab's devops feature. However, my project won't build on GitLab because of this dependency issue, giving me the following error on maven build:
Could not find artifact com.oracle:ojdbc7:jar:12.1.0.2 in central
(https://repo.maven.apache.org/maven2) -> [Help 1]
I want to know how can I supply this dependency so that my project can be built successfully.
Has anyone experienced a similar issue?
POM.xml contains:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
If your pom.xml contains a dependency - then you should provide it or delete it.
If you're not trying to understand "maven" way of doing things and just want to make it work - try this "lazy" solution:
<repository>
<id>code-lds</id>
<url>https://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
Add this repository to your section. It's a widely-used third-party repository that contains several common artifacts like Oracle drivers and etc.

How to use a local maven snapshot of another local project [duplicate]

This question already has answers here:
How to add local jar files to a Maven project?
(35 answers)
Closed 5 years ago.
I feel like I must be lacking some very very basic Maven knowledge here. I have a (couple of) maven project(s) and a shared library. This library should be a separate maven project with its own life cycle. I'm trying to import the library into my project using:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>nl.whatever.com</groupid>
<artifactId>my_shared_library</artifactId>
<version>1.0-SNAPSHOT</groupid>
</dependency>
...
</dependencies>
</dependencyManagement>
But maven keeps looking in my repro instead of trying to find my local build. And worst of all, it keeps looking for a jar. I get:
Could not resolve dependencies for project my.project:ejb:1.0-SNAPSHOT: Could not find artifact nl.whatever.com:my_shared_library:jar:1.0-SNAPSHOT
What's my rookie mistake? Yes, I did do a clean install of my library project.
edit:
My .m2 directory has a settings file redirecting my local repro to
/ws/repro, which contains:
/ws/repro/nl/whatever/com/my_shared_library/1.0-SNAPSHOT/
my_shared_project-1.0-SNAPSHOT.jar.lastUpdate
my_shared_project-1.0-SNAPSHOT.pom
and some property files.
edit2:
I don't think it's a duplicate. I looked at the question linked before posting my question. There is no non-maven project or external jar involved here.
Your local repository is usually in .m2/repository below the user repository. If You do clean install on your library project, it should be installed into this repository (in nl/whatever/com/my_shared_library/...). Then you can use it from all other Maven projects on the same computer.
It is furthermore important that the <packaging> is correct, i.e. the packaging needs to match the artifact you want to build. If the packaging is pom then you only create a pom (like a parent pom or a bom). Leaving out the packaging tag implictely means that you use packaging jar.
You shall try updating your pom.xml with a tag named as repositories.
Maven repositories are the places that hold build artifacts and dependencies of varying types.
A sample maven remote repository tag with its values is:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
To configure multiple repositories you can follow the guide and make use of profile in settings.xml as well.
On a side note, unless following a hierarchy or making use of specific versions of a library. You should use <dependencies> instead of <dependencyManagement>, take a look at the differences between dependencymanagement and dependencies in maven.

Maven dependency to apache commons-text?

I would like to include a Maven dependency on the apache commons-text project.
I tried adding this dependency to my pom:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
And including the following repository:
<repository>
<id>apache_snapshots_repo</id>
<url>http://repository.apache.org/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
I took that repository from the Dependency Repository Locations section of the documentation of commons-text. However, still the dependency cannot be resolved by maven.
So which is the right dependency & repository I should configure in order to work with Apache commons-text ?
You have to pull down the source and build it yourself. It appears that no artifacts have been deployed to Maven Central or the Apache snapshots repository.
FWIW, there hasn't been any significant development on that code since May 2015.
I'm happy to write that development has resumed for Apache Commons Text, and version 1.0 was recently released.
It can now be imported normally. Keep in mind that you need to change the version from 0.1-SNAPSHOT (as in the OP's question) to 1.0.
Here is its page on Maven Central.
(full disclosure - I also contributed to this project)

Can I use a GitHub project directly in Maven?

I am interested in using a project on GitHub as a dependency in my project. The GitHub project has a pom file. Can I modify my pom file to use this project? If so, how? If not, what is my best course of action?
Try jitpack, you just need to add the dependency, jitpack will build others for you.
From home page:
jitpack
Easy to use package repository for Gradle and Maven projects
JitPack builds GitHub projects on demand and provides ready-to-use packages
HOW
Add repository first
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
Add dependency
<dependency>
<groupId>com.github.User</groupId>
<artifactId>Repo name</artifactId>
<version>Release tag</version>
</dependency>
TIPS:
You can see its build log too https://jitpack.io/com/github/NanoHttpd/nanohttpd/Release-2.1.0/build.log
Not in the way I think you mean, AFAIK.
You can use github as a Maven repository--this is not the same thing as directly referencing a project, and that it has a pom file means only that it's a Maven project.
If the project is not available in the central, or other, repository, your best bet may be to clone it, build it, and install it locally. You should confirm that it's truly not available elsewhere.
#wener's answer is very helpful, but leaves some mystery.
This real example might save some time:
<project ... >
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<!-- groupId is https://github.com/fabric8io/kubernetes-client -->
<groupId>com.github.fabric8io.kubernetes-client</groupId>
<!-- module is a directory within the repo, containing pom.xml -->
<artifactId>kubernetes-model-generator-client</artifactId>
</dependency>
</dependencies>
. . .
Make sure you are signed into GitHub.
You can also find a tag index page by cutting at the tag within the URL, like https://jitpack.io/com/github/fabric8io/kubernetes-client/. In my example, I figured out if "v" from "v6.4.1" had to be removed or not, since there is a release with the v and a tag without it.
More details: jitpack.io page

Categories