Maven artifact not found in central [duplicate] - java

This question already has answers here:
Maven Could not resolve dependencies, artifacts could not be resolved
(17 answers)
Closed 6 months ago.
I'm trying to use this Maven dependency for a project https://mvnrepository.com/artifact/org.eclipse.ecf.protocol/bittorrent/0.3.0
I used the declaration in my pom.xml, when I update the project it could not resolve dependency from this https://repo.maven.apache.org/maven2/ URL.
So I looked up the page and there was no Bittorent jar there. Can anyone explain me why this jar is missing from the maven2 repo and how to resolve this error. I tried other answers but nothing works for this one.

There are other ways for an author to host their jars in their public website. But I'm not sure why dependency resolving error occurs in this repo, when I figure out I'll edit this answer to include it.
Until then You can download the jar from files section of the repository page and include it in your class path to solve this issue for now.
here's the link to file

This artifact is not hosted on the maven central repository (https://repo.maven.apache.org/maven2/), but rather on: https://www.jabylon.org/maven/
You can double-check this by navigating to: https://mvnrepository.com/artifact/org.eclipse.ecf.protocol/bittorrent
In your case, the solution is to add the repository to your pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- ... -->
<dependencies>
<dependency>
<groupId>org.eclipse.ecf.protocol</groupId>
<artifactId>bittorrent</artifactId>
<version>0.3.0</version>
</dependency>
<!-- ... -->
</dependencies>
<repositories>
<repository>
<id>Jabylon</id>
<url>https://www.jabylon.org/maven/</url>
</repository>
</repositories>
</project>

Related

How do I include a maven package that has invalid/outdated POM?

I want to use a package named sourcemap in my project. It's not available in maven central, but in Atlassian's public maven repository. I therefore set up my pom.xml like this:
<repositories>
<repository>
<id>atlassian</id>
<name>Atlassian</name>
<url>https://packages.atlassian.com/content/repositories/atlassian-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.atlassian.sourcemap</groupId>
<artifactId>sourcemap</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
Now, the POM file for sourcemap references another POM file from a package named public-pom:
<!-- POM for sourcemap (NOT my pom.xml!) -->
<parent>
<groupId>com.atlassian.pom</groupId>
<artifactId>public-pom</artifactId>
<version>3.0.84</version>
</parent>
The problem: the POM file references version 3.0.84 of public-pom, but Atlassian's repo no longer provides 3.0.84. Currently, the oldest available version of public-pom is 5.0.0, as you can see here. Because of this, maven complains when I attempt to build the project:
Could not find artifact com.atlassian.pom:public-pom:pom:3.0.84 in atlassian (https://packages.atlassian.com/content/repositories/atlassian-public/)
How can I fix the POM and use this package in my project?
Mvnrepository lists com.atlassian.pom:public-pom:pom:3.0.84 but when selecting the link to it:
status: 404
message: "Could not find resource"

Adding external jar to maven repository not working [duplicate]

This question already has answers here:
How to add local jar files to a Maven project?
(35 answers)
Closed 2 years ago.
I've installed my jar in my local repo as said in maven docs :
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<dans>
-DartifactId=<dans-lib>
-Dversion=<1.0.0>
-Dpackaging=<jar>
-DgeneratePom=true
I can see in my /home/.m2/repository that the location is created and in the dans/dans-lib/1.0.0 there is my jar file.
Unfortunately when I'm trying to add maven dependency in my pom.xml
<dependency>
<groupId>dans</groupId
<artifactId>dans-lib</artifactId>
<version>1.0.0</version>
</dependency>
I got error Dependency dans:dans-lib not found. I've got no idea what might be the problem
First solution is to add local repo to pom.xml something like this
<repositories>
<repository>
<id>local-maven-repo</id>
<url>file:///${project.basedir}/local-maven-repo</url>
</repository>
</repositories>
2nd solution woudld be to load jar file
<dependency>
<groupId>dans</groupId
<artifactId>dans-lib</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/Name_Your_JAR.jar</systemPath>
</dependency>

How to correctly add Maven dependency from mvnrepository

I'm having an issue adding a maven dependency, it's for a Twitter API dependency but I'll try and keep the question as generic as possible.
The dependency is located onthe maven site here
It states that the repo is here:
Note: this artifact it located at Spring Plugins repository (http://repo.spring.io/plugins-release/)
So I have created a pom with the specified dependency and repo:
<repositories>
<repository>
<id>maven_twitter</id>
<name>twitter</name>
<url>http://repo.spring.io/plugins-release/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.twitter.sdk.android</groupId>
<artifactId>twitter</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
The repository ID and Name weren't given so I've given them a suitable name - is this wrong?
The error received is:
[ERROR] Failed to execute goal on project java: Could not resolve dependencies for project com.project.java:java:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.twitter.sdk.android:tweet-composer:jar:3.1.1, com.twitter.sdk.android:twitter-core:jar:3.1.1, com.twitter.sdk.android:twitter:jar:3.1.1, com.twitter.sdk.android:tweet-ui:jar:3.1.1, com.android.support:support-v4:jar:23.1.1, com.android.support:recyclerview-v7:jar:23.1.1: Could not find artifact com.twitter.sdk.android:tweet-composer:jar:3.1.1 in maven_twitter (http://repo.spring.io/plugins-release/) -> [Help 1]
So my question is: is simply adding the repo and dependency details of the Maven site enough? Am I missing something?

Adding maven local dependecies without mvn install:install-file

I have some local jar files in a folder /src/main/resources/foobar under my basepath.
I have them included as dependencies in my POM.xml:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.4-SNAPSHOT</version>
</dependency>
Now i tried to add them with a local repository:
<repositories>
<repository>
<id>resource-repository</id>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
Now still i get the error message that the jars inside this reposirtory not found:
The following artifacts could not be resolved: bar... in file://.../repo was cached in the local repository, resolution will not be reattempted until the update interval of resource-repository has elapsed or updates are forced -> [Help 1]
I have not used the
mvn install:install-file
command for this. And i would be happy if there is a solution where i dont need to do this.
Edit:
The folder structure is:
repo\io\swagger\swagger-models\1.5.4-SNAPSHOT
and Jar inside:
swagger-models-1.5.4-SNAPSHOT.Jar
Funny though i get a warning about a missing POM from this file when running maven install.
You can declare a Repository for your third party dependencies.
The dependencies must be placed inside the repoBase path and the directory for the jar must follow the pattern: "{groupId}/{artifactId}/{artifactVersion}". Inside this folder the jar has to be named "{artifactId}-{artifactVersion}.jar".
Example:
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>resource-repository</id>
<url>file:${project.basedir}/repo</url>
</repository>
I have this in my pom (and of course the project-tag and group-id etc.)
I then have a directory repo in my project-directory.
In the path "repo\foo\bar\1.0" i then have a "bar-1.0.jar" file inside this directory. This compiles for me (ok, the jar is empty but this does not matter for an example).
Please note that the url for the repository does not contain the two slashes after the "file:".
I hope this example is a little bit more understandable for anyone who tries to this.
I suggest you to use system tag in your dependency tag. Hope it will work.

Loading Maven dependencies from GitHub [duplicate]

This question already has answers here:
Can I use a GitHub project directly in Maven?
(3 answers)
Closed 2 years ago.
How do I add a Java library from its GitHub repo (the library uses Maven as a build system) as a dependency to my Maven project? Can I do that without downloading and compiling the library?
Now you can import a Java library from a GitHub repo using JitPack.
In your pom.xml:
Add repository:
<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>
It works because JitPack will check out the code and build it. So you'll end up downloading the jar.
If the project doesn't have a GitHub release then its possible to use a commit id as the version.
At the moment there is no way you can do this unless the maintainer of the library provided a way to do this.
So on the title page of the library the should be an instruction containing the repository address like:
<repositories>
<repository>
<id>YOUR-PROJECT-NAME-mvn-repo</id>
<url>https://raw.github.com/YOUR-USERNAME/YOUR-PROJECT-NAME/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
And a dependency name:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</dependency>
This means that all artifact of your project including your dependency will be searched in this repo.
You could also have a glance at pom.xml to check if there was an effort made to deploy artifacts to a remote repo. Typically the keywords are oss.sonatype.org or raw.github.com like in this case.
FYI, here is a way to provide a repo for your gihub artifact: Hosting a Maven repository on github.
Github now supports packages https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages
You can follow the steps above to deploy Jar files to github properly.
Another very nice thing about Jitpack is, it has a lookup button on the main page. And if you type the URL of your GitHub repository, it displays different commits of the source code, and you can select which commit/tag you want. The Jitpack creates pom dependencies for you.
It became dead simple.

Categories

Resources