I have an Android library dependency which I pull in from my own Maven repository (Artifactory based):
compile "com.jmolsmobile.mylibrary:mylibrary:1.0.4"
This dependency depends on another library, which is located in another Maven repository with a custom URL:
repositories {
maven { url 'https://mint.splunk.com/gradle/' }
}
What I want to do is to include my Android library in another project, without having to add the repository URL explicitly to my Gradle files, but rather have my project inherit the repository URL via the Maven pom.xml.
But Gradle does not search in the custom repository URL:
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.splunk.mint:mint:4.2.1.
Searched in the following locations:
https://jcenter.bintray.com/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
https://jcenter.bintray.com/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
http://10.0.190.250:8081/artifactory/android-snapshot-local/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
http://10.0.190.250:8081/artifactory/android-snapshot-local/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
file:/Applications/Android-SDK/extras/android/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
file:/Applications/Android-SDK/extras/android/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
file:/Applications/Android-SDK/extras/google/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
file:/Applications/Android-SDK/extras/google/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
Even though the repository is explicitly defined in 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>
<groupId>com.jmolsmobile.mylibrary</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0.4</version>
<packaging>aar</packaging>
<repositories>
<repository>
<id>splunk</id>
<url>https://mint.splunk.com/gradle/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.splunk.mint</groupId>
<artifactId>mint</artifactId>
<version>4.2.1</version>
</dependency>
</dependencies>
</project>
Any ideas why this is going wrong?
Related
I am trying to add log4j-rolling-appender library as a dependency in my application. The jar is available here:
https://mvnrepository.com/artifact/uk.org.simonsite/log4j-rolling-appender/
I have added the following 2 things( repository and jar specification) in pom.xml. snippet below:
<?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>
...
...
<repositories>
<repository>
<id>log4j-appender</id>
<name> Repository for log4j-rolling-appender</name>
<url>https://mvnrepository.com/artifact/</url>
</repository>
</repositories>
<dependency>
<groupId>uk.org.simonsite</groupId>
<artifactId>log4j-rolling-appender</artifactId>
<version>20131024-2017</version>
</dependency>
...
...
</project>
Upon building, maven generates the following URL to download the dependency which is incorrect( Though as per the standards, it is correct however incorrect in my case):
https://mvnrepository.com/artifact/uk/org/simonsite/log4j-rolling-appender/20131024-2017/log4j-rolling-appender-20131024-2017.pom
Notice how the package mentioned in groupId(uk.org.simonsite) is converted to package hierarchy in the URL (../uk/org/simonsite/).
The URL where the JAR can be found and i want maven to generate is:
https://mvnrepository.com/artifact/uk.org.simonsite/log4j-rolling-appender/20131024-2017/log4j-rolling-appender-20131024-2017.pom
Can someone provide any suggestion on how do i instruct maven to skip this conversion while generating the URL ?
Maven repositories have a fixed format for resolving Maven coordinates.
After the starting URL, there is the groupId with / instead of ., then the artifactId, then the version, and then a filename that contains artifactId, version, classifier if present and the extension.
If you want to draw a jar from a different URL, then this URL is not a Maven repository. You should download the jar first and install it into your company repository (or your own local repository, if nothing else is available).
If you have using multiple dependencies then you should try using annotation wrapping all dependencies.
Also follow the pattern :
<project>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
<version>1.0</version>
<type>bar</type>
<scope>runtime</scope>
</dependency>
<repositories>
<repository>
<id>my-internal-site</id>
<url>http://myserver/repo</url>
</repository>
</repositories>
...
</project>
Dependencies with the scope system are always available and are not looked up in repository. Always use dependencies first before repository in order.
I have two projects - A and B, where A is dependent on B. I package B as jar and deploy it on a maven server (artifactory), and then include that jar as a normal dependency on project A in pom file. jar file of B shows up in the Maven Dependencies of project A, but dependencies of project B are not shown in dependency hierarchy. It is causing class not found exception for dependencies of B.
However, my project A and B and in same eclipse workspace. When I open project B, project A starts referencing the project B from the workspace instead of remote repository and everything works well.
This question - Maven. Transitive dependencies was closest to my problem, but dependencies of my project B are NOT optional.
Whats going wrong here?
POM for project B
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>utils</artifactId>
<version>1.0.0-RELEASE</version>
<packaging>jar</packaging>
<name>utils</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- Following doesn't get added to project A -->
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
POM for project A
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>core-app</artifactId>
<version>1.0.0-RELEASE</version>
<packaging>jar</packaging>
<name>core-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.myapp</groupId>
<artifactId>utils</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>
</dependencies>
</project>
I am using maven quickstart archetype. Project structure of my projects is (which I package as jar):
project-name
src/main/java
src/test/java
pom.xml
To successfully resolve transitive dependencies, project B's jar and pom.xml must be accessible in the Maven repository. When deploying artifacts to a remote repository, be sure both the jar and pom.xml are deployed and available for download.
With the requisite files deployed to the remote repository, use the command line to build project A. Specify a build Maven target to trigger the downloading of all dependencies into the local Maven repository. Something like mvn compile or mvn package will trigger the downloads and successfully build project A.
Once, project B's jar and pom.xml are in the local Maven repository, update the Maven projects in Eclipse and they will rebuild and resolve the dependencies correctly.
I have a project that depends on hibernate-core 3.6.4.Final, lets call it "MyDatabaseProject".
I have a second project which is a spring-cloud project, it depends on MyDatabaseProject.
The spring cloud project uses spring-cloud-starter-parent Brixton.RELEASE as it's parent pom.
When I check the dependencies (using "mvn dependency:list") I see that I now have a dependency on hibernate-core:4.3.11.Final, not 3.6.4.Final.
If I switch the spring-cloud-starter-parent version back to Angel.SR6, and I check the dependencies (using "mvn dependency:list") I see that I have a dependency on hibernate-core:3.6.4.Final, as I would expect.
It appears to me that something changed in the Brixton.RELEASE that overrides the hibernate-core version.
My question is, is this a bug, or unintentional change in the Brixton.RELEASE?
If it is intentional, what it the correct way to deal with this?
I have tried adding a dependencyManagement section to the spring cloud project pom with the hibernate-core:3.6.4.Final, and that did work, but I don't know if that is the correct way to deal with the problem. It doesn't seem right for the top level project to care about what hibernate version the lower level project uses.
Here are the minimal maven poms for the spring cloud project and the database project:
<?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>example</groupId>
<artifactId>MySpringCloudProject</artifactId>
<version>1.0.0</version>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.RELEASE</version>
<!-- <version>Angel.SR6</version> -->
</parent>
<dependencies>
<dependency>
<groupId>example</groupId>
<artifactId>MyDatabaseProject</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
And the database project:
<?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>example</groupId>
<artifactId>MyDatabaseProject</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.4.Final</version>
</dependency>
</dependencies>
</project>
This is the first time I've used maven, I am trying to integrate zopim sdk and I followed the tutorial and converted my project to a maven project and added the repository and dependencies, but now eclipse does not compile and gives me the following error :
Description Resource Path Location Type
Missing artifact com.android.support:appcompat-v7:jar:23.0.0 pom.xml /4SaleApp line 2 Maven Dependency Problem
Missing artifact com.android.support:design:jar:23.0.0 pom.xml /4SaleApp line 2 Maven Dependency Problem
Missing artifact com.android.support:recyclerview-v7:jar:23.0.0 pom.xml /4SaleApp line 2 Maven Dependency Problem
What should I do ?
EDIT
my pom.xml file
<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>4SaleApp</groupId>
<artifactId>4SaleApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<repositories>
<repository>
<id>chatsdk-repo</id>
<name>Chat SDK Repo</name>
<url>https://zendesk.artifactoryonline.com/zendesk/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.zopim.android</groupId>
<artifactId>sdk</artifactId>
<version>1.1.0</version>
<type>aar</type>
</dependency>
</dependencies>
</project>
This seems like a conflicting issue when changing from Gradle to Maven. This questions provides a lot more info on the issue.
But it looks like you are missing the android support dependencies in the pom. Maybe try adding the missing support libraries to the pom. For example as shown here for appcompat-v7:
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>${compatibility.version}</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>${compatibility.version}</version>
<type>jar</type>
</dependency>
I'm trying to use a SimpleMongoBolt from storm-contrib. I downloaded the source, entered the storm-contrib-mongo directory and ran mvn package and mvn install. Everything worked fine and IntelliJ was able to resolve things while coding. When I try to build my project, however, it tries to find a pom for this library on an external repository. When it can't find it, it fails. What do I need to do to fix this?
<?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>StormTest</groupId>
<artifactId>StormTest</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>StormTest</name>
<repositories>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.7.2</version>
<scope>Test</scope>
</dependency>
<dependency>
<groupId>com.rapportive</groupId>
<artifactId>storm-amqp-spout</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.rapportive</groupId>
<artifactId>storm-json</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>storm</groupId>
<artifactId>storm-contrib-mongo</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
You can try to check if you have proper dependencies defined in your project pom and compare them to storm artifact one. groupId, artifactId and version must be the same or Maven will try to download it from external repository and probably failed as it has never been installed on any public Maven repo.
When you install your artifact, it goes to user-directory/.m2/repostiory/group/id/path/*artifact/id/path*/version.
For your storm-amqp-spout you should have it in:
user-directory/.m2/repository/com/rapportive/storm-amqp-spout/0.1.1 folder.
There you should have few files:
jar itself (if it was packaged as jar file).
pom.xml file (the same you created for your project and you used to built and install it).
optionally sha1 files for both above.
If you don't have them, you probably made some mistake installing the artifact into repository. You can try to install it again or manually create pom just copying it from artifact source directory.
If there's correct pom.xml, I don't really have idea as I have never worked with IntelliJ (idea? ;)).
SimpleMongoBolt in Storm-Contrib was actually out of date. I updated the module myself and submitted a pull request, which has yet to be merged. Currently you can retrieve the updated code from my Storm-Contrib fork.