Download jar from maven repository without using Maven - maven

I am looking for a library that can help me with K-means Vector Quantization. I found a website that offered hope.
http://www.lab4inf.fh-muenster.de/lab4inf/Lab4Drools/dependencies.html
The Lab4Math-1.0.5.jar has the required KmeansQuantization class.
But as see you from the first link, there is no direct download link for the "Lab4Math-1.0.5.jar".
Instead a maven repository is specified.
http://www.lab4inf.fh-muenster.de/lab4inf/maven-repository
Since iam a mobile app developer, i dont use Maven. I am looking for a way to download the jar in any other way. Please help.

Looks like there is a problem with the repository:
[ERROR] Failed to execute goal on project demo: Could not resolve dependencies for project com.demo:demo:jar:1.0-SNAPSHOT:
Failed to collect dependencies for [de.lab4inf:Lab4Math:jar:1.0.5 (compile)]:
Failed to read artifact descriptor for de.lab4inf:Lab4Math:jar:1.0.5:
Could not transfer artifact de.lab4inf:Lab4Math:pom:1.0.5 from/to
Lab4Inf (http://www.lab4inf.fh-muenster.de/lab4inf/maven-repository):
Access denied to: http://www.lab4inf.fh-muenster.de/lab4inf/maven-repository/de/lab4inf/Lab4Math/1.0.5/Lab4Math-1.0.5.pom ,
ReasonPhrase:Forbidden. -> [Help 1]
Tried to retrieve the module metadata file and got a HTTP 403 error....
I was trying to follow the instructions for integrating Math4Lab and discovered it's out of date. Maven 3 forces the specification of a dependency version number and there is a little note at the bottom:
... This way you will have always the newest versions, if snapshots are enabled. At present no final Lab4Math version is available.
My conclusion is that this software is abandonware...
Example
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>de.lab4inf</groupId>
<artifactId>Lab4Math</artifactId>
<version>1.0.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Lab4Inf</id>
<url>http://www.lab4inf.fh-muenster.de/lab4inf/maven-repository</url>
</repository>
</repositories>
</project>

I was able to download the mentioned jar using the following pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tf</name>
<description>Testing Lab4Math</description>
<repositories>
<repository>
<id>Lab4Inf</id>
<url>http://www.lab4inf.fh-muenster.de/lab4inf/maven-repository</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>de.lab4inf</groupId>
<artifactId>Lab4Math</artifactId>
<version>2.0.5-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Note that the only important difference with the accepted answer is the version of the library. (2.0.5-SNAPSHOT instead of 1.0.5)

Related

Inherit child-dependencies from maven dependency

I have two separate maven projects.
Project A contains utility classes and similar stuff. It also uses jetbrains annotations in some interfaces to mark parameters as Nullable and NotNullable.
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
</dependency>
Project B uses some of the Utilities of Project A. It includes it as a dependency from my repository.
<dependency>
<groupId>org.test.group</groupId>
<artifactId>Utilities</artifactId>
<version>1.0</version>
</dependency>
I can access the classes from my utilities dependency just fine. But i do not see any of the annotations on the parameters. I also can't access the jetbrains annotations in project B in any of my classes there. I'd have to add the jetbrains dependency in project B as well to do so.
Is there any way to inherit the dependencies of another dependency?
I looked at other questions and found this similar one. Tho his solution was to set the optional-parameter to false which i am not even using. Perhaps also something that needs to be configured in the maven build? Currently im running my build with goals clean package deploy without any special additional configuration.
I know gradle builds allow for implementation and api dependencies, where one of them forwards the dependency to other projects that include it and the other doesn't.
Edit: Here the full configuration of my projects
Local nexus running under localhost:8081 containing my artifacts. Local TeamCity running under localhost:8080 used for the builds and deployment to the repository.
Project A pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test.group</groupId>
<artifactId>Utilities</artifactId>
<version>1.0</version>
<name>Utilities</name>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<distributionManagement>
<repository>
<id>local_nexus</id>
<name>Deployment</name>
<url>http://localhost:8081/repository/org.test.group/</url>
</repository>
</distributionManagement>
</project>
Project B pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test.group</groupId>
<artifactId>TestProject</artifactId>
<version>1.0</version>
<name>TestProject</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.test.group</groupId>
<artifactId>Utilities</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>local_nexus</id>
<name>Deployment</name>
<url>http://localhost:8081/repository/org.test.group/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>local_nexus</id>
<name>Deployment</name>
<url>http://localhost:8081/repository/org.test.group/</url>
</repository>
</distributionManagement>
</project>
Edit 2:
I've made some progress. Since i didn't change Project A's version after adding the annotations my local repository didn't fetch the new version. After a purge using mvn dependency:purge-local-repository the updated state of version 1.0 was available.
mvn dependency:tree prints now
[INFO] org.test.TestProject:jar:1.0
[INFO] \- org.test:Utilities:jar:1.0:compile
[INFO] \- org.jetbrains:annotations:jar:20.1.0:compile
Tho my IDE (Intellij) still doesn't recognize the annotation classes inside TestProject. Any idea why this is failing now?
You inherit annotations automatically, no configuration needed.
You don't inherit it, if it is of scope provided. Look at mvn dependency:tree to find out about the place and scope of the annotations library.
BTW: mvn clean package deploy is a waste of time, just use mvn clean deploy.
The issue was caused by my local maven repository. Since i didn't change the version of Project A's artifact (always 1.0) my local repository kept providing me with the old state of version 1.0.
Using mvn dependency:purge-local-repository i was able to cleanse the old 1.0 and load the new 1.0. Tho still my IDE refused to imports annotations dependency. At this point it was listed by mvn dependency:tree tho.
After tempering with the IDE for a while i decided to update my version to 1.1. Once Project A's 1.1 was built and Project B's dependency was updated to 1.1 it worked.
So basically it resulted from poor versioning of my projects, which interfered with my local maven repository.

POM for my own repo is missing, no dependency information available

I am currently learning software development and working on an assignment based on using a release from one project in another using jitpack.
The first project, which I want to add as a dependency in my second, simply has three classes and a JUnit test for each. I changed several things so I am at V5.0 release now.
https://github.com/MohamedMoustafaNUIG/assignment1/releases/tag/V5.0
My second project is not yet pushed, but this is the pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nuig</groupId>
<artifactId>assignment1_driver</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.github.MohamedMoustafaNUIG</groupId>
<artifactId>assignment1</artifactId>
<version>v5.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
</project>
When I try to build with dependencies (in netbeans), I get this error:
Failed to execute goal on project assignment1_driver:
Could not resolve dependencies for project com.nuig:assignment1_driver:jar:1.0-SNAPSHOT:
Failure to find com.github.MohamedMoustafaNUIG:assignment1:jar:v5.0 in
https://jitpack.io was cached in the local repository,
resolution will not be reattempted until the update interval of jitpack.io has
elapsed or updates are forced -> [Help 1]
I also get this warning:
The POM for com.github.MohamedMoustafaNUIG:assignment1:jar:v5.0 is missing, no dependency information available
Even though the zip file (from linked release) has the pom file.
Any help appreciated as I have no idea how to resolve this the issue
You either need to:
build assignment1 on the same machine with clean install to make it available in the local repository.
deploy assignment1 to a Maven repository with clean deploy and then use this as a <repository>.

pom.xml with Jitpack loads wrong version of dependency

I am using JitPack to share a private Github release that I manage.
I have uploaded a new release version to github successfully - when I download it as jar from Github, I see the correct files.
But when I use pom.xml to download it as a dependency via the pom.xml file, it downloads an earlier release version.
I ran mvn dependency:list to see what is actually being downloaded and it says that the correct version is the one being downloaded.
[INFO] com.github.myGroupId:my-artifact-id:jar:THE_CORRECT_VERSION:compile
But when I browse in the jar classes I see that it is still the old version.
The solutions I tried so far:
-submitting another new release
-cleaning my maven local repository
All didn't work. I still get the old version.
The pom.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shai.test</groupId>
<artifactId>sandbox</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.github.myGroupId</groupId>
<artifactId>my-artifact-id</artifactId>
<version>MY_LATEST_VERSION</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
</project>

I got "Could not resolve dependencies" error when I run maven install command

I added private nexus repository urls in pom.xml to install some dependencies from inhouse nexus repository.
But eclipse still shows "Missing artifact error" messages in pom.xml file
here is command line error messages when I run mvn install command
[ERROR] Failed to execute goal on project diffapi: Could not resolve dependencies for project com.my:diffapi:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.aaa.bbb.poi.jar:poi:jar:5.14.4, com.aaa.bbb.poi.jar:poi-skp-search-client-util:jar:5.14.4, com.aaa.bbb.poi.jar:poi-util:jar:5.14.4, com.aaa.bbb.frame:ndds-log:jar:1.4.6, com.aaa.bbb.frame:ndds-util:jar:1.4.6, com.aaa.bbb.frame:ndds-monitor-agent:jar:1.5.0, com.aaa.bbb.frame:ndds-web-utility:jar:1.5.0, com.aaa.bbb.frame:ndds-context:jar:1.5.0: Failure to find com.aaa.bbb.poi.jar:poi:jar:5.14.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
it seems maven only access maven central instead of private nexus repositores
And this is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.my</groupId>
<artifactId>diffapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>diffapi</name>
<description>diff api server for rmi and rest result</description>
<properties>
<java.version>1.8</java.version>
<ndds.frame.version>1.5.0</ndds.frame.version>
</properties>
<dependencies>
<dependency>
<groupId>com.aaa.bbb.poi.jar</groupId>
<artifactId>poi</artifactId>
<version>5.14.4</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.poi.jar</groupId>
<artifactId>poi-skp-search-client-util</artifactId>
<version>5.14.4</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.poi.jar</groupId>
<artifactId>poi-util</artifactId>
<version>5.14.4</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.frame</groupId>
<artifactId>ndds-log</artifactId>
<version>1.4.6</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.frame</groupId>
<artifactId>ndds-util</artifactId>
<version>1.4.6</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.frame</groupId>
<artifactId>ndds-monitor-agent</artifactId>
<version>${ndds.frame.version}</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.frame</groupId>
<artifactId>ndds-web-utility</artifactId>
<version>${ndds.frame.version}</version>
</dependency>
<dependency>
<groupId>com.aaa.bbb.frame</groupId>
<artifactId>ndds-context</artifactId>
<version>${ndds.frame.version}</version>
</dependency>
<distributionManagement>
<repository>
<id>AAA-releases</id>
<name>AAA-releases</name>
<url>http://IP:PORT/nexus/content/repositories/AAA-releases/</url>
</repository>
<snapshotRepository>
<id>AAA-snapshots</id>
<name>AAA-snapshots</name>
<url>http://IP:PORT/nexus/content/repositories/AAA-snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>
You seem to be confusing repositories where your project will be deployed after building with repositories which are used as sources for the dependencies in your project. You haven't actually specified a custom 3rd party repo, so Maven is giving up after failing to find the artifacts in the central repo. From the Maven documentation:
Whereas the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed. The repository elements will be used for snapshot distribution if the snapshotRepository is not defined.
So, try adding a <repositories> element which contains the extra repos which you want available for the custom JARs in your build:
<project>
...
<distributionManagement>
<repository>
<id>AAA-releases</id>
<name>AAA-releases</name>
<url>http://IP:PORT/nexus/content/repositories/AAA-releases/</url>
</repository>
<snapshotRepository>
<id>AAA-snapshots</id>
<name>AAA-snapshots</name>
<url>http://IP:PORT/nexus/content/repositories/AAA-snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<!-- fill in with the actual details of your repo here -->
<repository>
<id>REPO ID</id>
<name>REPO NAME</name>
<url>YOUR URL GOES HERE</url>
</repository>
</repositories>
</project>

Non-resolvable parent POM

I am trying to develop a custom connector for mule by following http://www.mulesoft.org/documentation/display/current/Creating+a+Connector+Project tutorial.
As shown in the tutorial, I am creating the project through command line by executing
mvn archetype:generate
-DarchetypeGroupId=org.mule.tools.devkit
-DarchetypeArtifactId=mule-devkit-archetype-cloud-connector
-DarchetypeVersion=3.4.3
-DgroupId=org.hello
-DartifactId=hello-connector
-Dversion=1.0-SNAPSHOT
-DmuleConnectorName=Hello
-Dpackage=org.hello
-DarchetypeRepository=http://repository.mulesoft.org/releases
After importing the project to mule studio I am getting following error in my pom.xml file near the parent tag.
Project build error: Non-resolvable parent POM:
Could not transfer artifact
org.mule.tools.devkit:mule-devkit-parent:pom:3.4.3 from/to
mulesoft-releases (http://repository.mulesoft.org/releases/):
connection timed out to
http://repository.mulesoft.org/releases/org/mule/tools/devkit/mule-devkit-parent/3.4.3/mule-devkit-parent-3.4.3.pom
and 'parent.relativePath' points at wrong local POM.
Here is my pom.xml file.
<?xml version="1.0" encoding="UTF-8"?>
project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>hello-connector</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>mule-module</packaging>
<name>Hello Connector</name>
<parent>
<groupId>org.mule.tools.devkit</groupId>
<artifactId>mule-devkit-parent</artifactId>
<version>3.4.3</version>
</parent>
<properties>
<junit.version>4.9</junit.version>
<mockito.version>1.8.2</mockito.version>
<jdk.version>1.7</jdk.version>
<category>Community</category>
<licensePath>LICENSE.md</licensePath>
<devkit.studio.package.skip>false</devkit.studio.package.skip>
</properties>
<scm>
<connection>scm:git:git://github.com:mulesoft/hello-connector.git</connection>
<developerConnection>scm:git:git#github.com:mulesoft/hello-connector.git</developerConnection>
<url>http://github.com/mulesoft/hello-connector</url>
</scm>
<repositories>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshots Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
</project>
I have changed the jdk version to 1.7. it was 1.6 in the auto generated pom.
ignore any error in the heading, some formatting issue.
I have tried various solutions mentioned on here but am not able to resolve the issue.
There is probably a firewall between your computer and the internet. You either have to configure Java to use this proxy.
Or you must download the parent POM manually and install it yourself into the local m2 repo. See this question how to do that: How to manually install an artifact in Maven 2?
Since you only need to install a POM, you need to trick mvn install:install-file:
mvn install:install-file -Dfile=<path-to-pomfile> -Dpackaging=pom -DpomFile=<path-to-pomfile>
This command will just install the POM itself.

Resources