I want to use Sikulix in my maven project but it doesn't work, I tried to add the repository like it says (http://sikulix-2014.readthedocs.org/en/latest/faq/030-java-dev.html#a-comment-on-projects-using-maven) and when I do "mvn install" it says "Could not find artifact com.sikulix:sikulixapi:jar:1.1.0-SNAPSHOT in nexus" where nexus is our repository.
My pom contains that:
...
<repositories>
<repository>
<id>com.sikulix</id>
<name>com.sikulix</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
...
Any idea why maven does not find the artifact in the correct repo?
The problem is solved. In the settings.xml we had a so maven always used the same repo.
I just removed the mirror because we didn't use it anymore, but I think that adding the additional repository there it would work too.
Related
I'm currently changing a docker image. The docker image creates a server that allows running some experiments. To adapt its functionality for my purpose, I have to change a class that is contained in a dependency jar file. In the pom.xml file, such jar dependency is downloaded with its dependencies from a nexus repository. I presume that a possible solution is to create a repository in the nexus repository (localhost) and then upload the jar file with its dependencies, right? Anyway, I would have no idea how I can do it. Below is the code concerning it.
Could someone help me up, please?
<repositories>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.liveontologies</groupId>
<artifactId>pinpointing-experiments</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
Yeah you're on the right track. What you're asking about is called a "deploy" in maven. So to deploy your jar generally you'll need to:
Create your nexus instance
Add your new repository to your pom file
Add the maven-deploy-plugin to your pom
Make your code changes
Deploy your jar with the mvn deploy command
Two good resources for lots of details on the steps and the exact content to add to your pom.
https://www.baeldung.com/maven-deploy-nexus
https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
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.
I am trying to import Ripple Effect library by using maven https://github.com/traex/RippleEffect.
It says "The lib is available on Maven Central, you can find it with Gradle, please". I have no idea what Gradle, please is and it's information (http://gradleplease.appspot.com/#rippleeffect) didn't help me at all.
I found how to import it by using maven. I added this dependency to my POM:
<dependency>
<groupId>com.github.traex.rippleeffect</groupId>
<artifactId>library</artifactId>
<version>1.3</version>
</dependency>
and made sure that I have Maven central repository:
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
However, when I try to run the project, it says:
Failed to execute goal on project ProjectName: Could not resolve dependencies for project lt.adnera:ProjectName:apk:0.0.1-SNAPSHOT: Failure to find com.github.traex.rippleeffect:library:jar:1.3 in http://repo1.maven.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
Any ideas?
According to http://repo1.maven.org/maven2/com/github/traex/rippleeffect/library/1.3/library-1.3.pom the packaging is aar so there is no jar which can be downloaded.
Try:
<dependency>
<groupId>com.github.traex.rippleeffect</groupId>
<artifactId>library</artifactId>
<version>1.3</version>
<type>aar</type>
</dependency>
additional Infos: http://simpligility.github.io/android-maven-plugin/aar.html
I have a snapshot maven repo defined:
<repositories>
<repository>
<id>tmp-repo</id>
<url>https://my-snapshot-repo</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
The problem is, for some reason, maven is looking for the following two dependencies:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-core</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-client</artifactId>
<version>4.4</version>
</dependency>
In the snapshot repo rather than the stable maven repo. Each compile gives this error:
[ERROR] Failed to execute goal on project myProject: Could not resolve
dependencies for project com.myGroupId:myArtifact:jar:1.0-SNAPSHOT:
The following artifacts could not be resolved:
org.apache.httpcomponents:httpcomponents-core:jar:4.4,
org.apache.httpcomponents:httpcomponents-client:jar:4.4: Could not
find artifact org.apache.httpcomponents:httpcomponents-core:jar:4.4 in
tmp-repo (https://my-snapshot-repo)
How do I force maven to not look for this dependency in the snapshot repo?
Before your edit, your original configuration said:
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
You said that this repo holds releases, as well as snapshots, so Maven is looking there.
Now you've removed <releases>, it shouldn't be doing that. Make sure you don't have any other repository definitions taking effect.
The problem is that I'm trying to make somelike the helloworld with Activiti but I have an error here
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>5.1</version>
</dependency>
the error is the following: 'Description Resource Path Location Type
Missing artifact org.activiti:activiti-engine:jar:5.1 pom.xml /IllMakeThisTestApp line 29 Maven Dependency Problem
Trying to resolve it I've found the following recomendation here: "The download contains all the libraries that you need to work with Activiti. But for developers that prefer to use Maven, add the following reposiory"
<repositories>
<repository>
<id>Alfresco Maven Repository</id>
<url>https://maven.alfresco.com/nexus/content/groups/public/</url>
</repository>
</repositories>
But where shall I place it? To the file called settings.ini placed in M2_HOME/conf? This file is full of comments with no any sign of repositories. So I have no idea how to do this and ask you for help
You should place that in your pom.xml - see the Maven reference on the subject:
<project xmlns="http://maven.apache.org/POM/4.0.0"...
...
<repositories>
<repository>
<id>Alfresco Maven Repository</id>
...
You will only need to tinker with the Maven config if you need to setup a mirror for the repo, eg. in case your organisation has it's own Nexus/other repo mirroring the outside "world".
Cheers,
You can place right under project. For example
<project>
....
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
In default maven will try to download all the artifacts from maven central. You can add any number of added repositories using tag given above. Alfresco is yet another open maven repository.