Maven artifact jar different name than version - java

I got a small question about Maven. I got a project my pom.xml
It has basically this repositories:
<repositories>
<repository>
<id>alfresco-mirror</id>
<name>Alfresco Public Mirror</name>
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>alfresco-snapshots</id>
<name>Alfresco Public Snapshots</name>
<url>http://maven.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>alfresco</id>
<name>Alfresco Public </name>
<url>http://pipin.bluexml.com/nexus/content/repositories/thirdparty/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
and this dependency:
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-web-service-client</artifactId>
<version>3.4.d</version>
<type>jar</type>
</dependency>
</dependencies>
I think the main problem is that jar file and version got different names.
How can I solve this?
I thank your help in advance.
PS: Just for save time, this dependency link location

Try adding a classifier node to see if that works:
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-web-service-client</artifactId>
<version>3.4.d</version>
<classifier>community</classifier>
<type>jar</type>
</dependency>
</dependencies>
You can see the reasoning behind that here. Long story short, classifiers are just appended to that artifact name right after the version number. They're not used all that often, but you do see them from time to time.

Related

Missing artifact org.springframework:spring-beans:jar:5.0.0.M4

I have a java spring mvc apication. and when i add the following dependency into the pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.0.M4</version>
</dependency>
it complains with:
Missing artifact org.springframework:spring-beans:jar:5.0.0.M4
So, what is wrong in my pom?
It is a milestones (pre released) version, which is not available in Maven. If you want to use it you can add spring milestones repository to your pom.xml.
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
However, since it's a pre-released version, it is not advisable to use it in production environment, unless you have a specific requirement/ feature that is only available in new version, since it may contain bugs.
use bellow version of dependency from current version of Spring-Beans. you can use bellow dependency :-
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.8.RELEASE</version>
</dependency>
after adding this update maven project
By default pom.xml has repository mentioned as below.
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
As 5.0.0.M4 is milestone version like alpha or beta version, mentioned dependency/jar is not present in maven central repository so error is produced.Add below lines in pom.xml and dependency will get downloaded.
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>myrepo</id>
<url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
</repository>
</repositories>

Maven refuse to download aar packaged dependency from remote repository

I want to use this android dependency in my java program:
http://jcenter.bintray.com/com/o3dr/android/dronekit-android/2.9.0/
so I added all the plugins & repositories into my maven pom file:
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<!--<snapshots>-->
<!--<enabled>false</enabled>-->
<!--</snapshots>-->
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.1.0</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
...
Then I add the dependency into the same file:
<dependency>
<groupId>com.o3dr.android</groupId>
<artifactId>dronekit-android</artifactId>
<version>2.9.0</version>
<type>aar</type>
</dependency>
But nothing happens, maven ignore it as if it doesn't exist, if I import its main package in a scala file and build it with mvn clear install -U, I get this error:
[ERROR] /home/peng/git-drone/dronespike/src/main/scala/Main.scala:1: object o3dr is not a member of package com
[ERROR] import com.o3dr.android._
[ERROR] ^
Question: What should I do to fix this problem?
Use Android packaging, e.g. <packaging>apk</packaging>.
If Maven couldn't download the artifact, it would complain much sooner in the build lifecycle. The problem is that artifact is downloaded, but not used. aar is not a standard Maven artifact, so Maven doesn't know what to do with it. Using it requires a third party plugin with extensions, hence usage of android-maven-plugin. Reading its documentation, it has some requirements to work properly. Specifically you didn't use android packaging as mentioned here:
usage of a supported packaging: apk, aar or apklib
Indeed, looking at the plugin source code it checks for android packaging before adding anything from aar to classpath.
Depending on the requirement from your maven version, based on what I faced before, you might have the need to add the configuration for release and snapshot. In my case, I was just able to get the lib once I specified these parameters:
<repositories>
<repository>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.o3dr.android</groupId>
<artifactId>dronekit-android</artifactId>
<version>2.9.0</version>
<type>aar</type>
</dependency>
</dependencies>
without it, the dependency was not downloaded.
Looking at the bintray repository from where the dependency is available, and check the repository settings via its Set me up option, your repositories coordinates are not correct, they should instead be:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-3d-robotics-maven</id>
<name>bintray</name>
<url>http://dl.bintray.com/3d-robotics/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-3d-robotics-maven</id>
<name>bintray-plugins</name>
<url>http://dl.bintray.com/3d-robotics/maven</url>
</pluginRepository>
</pluginRepositories>
And indeed the effective target file is available via the URL:
https://dl.bintray.com/3d-robotics/maven/com/o3dr/android/dronekit-android/2.9.0/
Which respects the repository URL plus its Maven coordinates (groupId, artifactId, version).
Also note: do not reuse the repository id central, unless for specific reason, otherwise you would override the central (default) repository of your Maven build and all of your dependencies (and plugins) would only be fetched by the newely declared one.
sbt-android can handle this configuration.
build.sbt
androidBuildJar
name := "yourproject"
organization := "yourorganization"
platformTarget := "android-24"
libraryDependencies +="com.o3dr.android" % "dronekit-android" % "2.9.0"
project/plugins.sbt
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.7")
Add publishing and resolver rules as necessary.

Jasper server maven repository url?

I am trying to get below dependency from jasper server.
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-api</artifactId>
<version>6.0.1</version>
</dependency>
But i am getting below error
Missing artifact com.jaspersoft.jasperserver:jasperserver-api:jar:6.0.1
Here is my POM
<project ...>
<modelVersion>4.0.0</modelVersion>
....
<name>jasperProject</name>
<url>http://www.jaspersoft.com</url>
<dependencies>
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-api</artifactId>
<version>6.0.1</version>
</dependency>
</dependencies>
</project>
With some simple googling you can get to this other answer on SO, where you can find a reference to this, which in term states you can add it like this:
<repository>
<id>JasperForge Maven Repository</id>
<!-- note: you need a <server> definition at bottom of file this file -->
<url>http://anonsvn:anonsvn#jasperforge.org/svn/repos/maven2</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
It also seems there's http://www.jasperforge.org/maven2/, which appears to be a non-browseable repository.
Another option is to put all required jars to a local maven repository. I know this is not the best solution, but it works, when you have no idea regarding correct Jasper public repository

Using SdmxSource jar files in the Nexus Repository through maven (m2eclipse)

The error Missing artifact org.sdmxsource:SdmxApi:jar:1.2.7 appears when defining dependencies in the m2eclipss.
I used this definition:
<dependency>
<groupId>org.sdmxsource</groupId>
<artifactId>SdmxApi</artifactId>
<version>1.2.7</version>
</dependency>
What may cause such a problem? Is there another way to import packages from nexus repository(eclipse IDE)?
Thanks in advance
Have you tried manually downloading the dependencies? See the sdmxsource help page: http://www.sdmxsource.org/sdmxsource-java/.
You could also use the parent tag in pom file:
<parent>
<artifactId>SdmxSourceBase</artifactId>
<groupId>org.sdmxsource</groupId>
<version>1.5.3</version>
</parent>
And the following repository in the maven settings.xml file:
<profiles>
<profile>
<id>sdmxsource</id>
<repositories>
<repository>
<id>MTRepo</id>
<url>http://sdmxsource.metadatatechnology.com/nexus/content/repositories/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sdmxsource</activeProfile>
</activeProfiles>

Adding additional repository to Maven 3

I want to add to my project some special dependeny from some repository.
For this I add the repository in my pom:
<repositories>
<repository>
<id>jenkins-repo</id>
<name>Jenkins Repository</name>
<url>maven.jenkins-ci.org/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
.. and in the same file add the dependency:
<dependency>
<groupId>org.jvnet.com4j</groupId>
<artifactId>com4j</artifactId>
<version>20120426-2</version>
</dependency>
But it doesn't work: the dependency is not found. As far as I understand this proves that the dependency exists in the right place:
http://maven.jenkins-ci.org/content/repositories/releases/org/jvnet/com4j/com4j/20120426-2/
So here are the questions:
1) Where I went wrong?
2) If I add repository to pom the default repository still be checked?
3) The link provided is really a link to Maven repo which proves I can download an artifact from it?
change <url> to include protocol
<url>http://maven.jenkins-ci.org/content/repositories/releases</url>

Categories

Resources