I am trying to add the following dependency to my Gradle build file:
compile 'org.eclipse.scout.sdk.deps:org.eclipse.core.resources:3.10.+'
This package depends on a lot of other packages, that are located in the same repository. The problem is that for some reason, Gradle deems them unworthy. Here's an example of the errors I've been getting:
Could not find any version that matches org.eclipse.scout.sdk.deps:org.eclipse.equinox.common:[3.7.0,3.7.1).
Versions that do not match:
3.7.0.v20150402-1709
Note that 3.7.0.v20150402-1709 does match [3.7.0,3.7.1)
Some additional technical details:
I'm working on Gradle v. 2.11.
This dependency, as well as its' dependencies, are located in the following repository:
https://repo1.maven.org/maven2/
Edit 1:
Yes, I could just exclude the transitive dependencies and add them with the correct version numbers, but it's such a horrible solution I can't bring myself to write it down. Hoping someone out there has an elegant solution.
Related
I am getting below error while running Gradle build in Unix terminal.
Could not resolve all files for configuration ':imcalmsvc-service:compileClasspath'.
Could not find javax.inject:javax.inject:1.0.
Searched in the following locations:
- https://jcenter.bintray.com/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
- https://repo.maven.apache.org/maven2/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
However, there is no error while doing Eclipse-> Gradle refresh.
The error means the dependency wasn't found in either JCenter or Maven Central. When you are usure about the exact name of dependency or which repositories it is uploaded to, I recommend a search engine like mvnrepository.com. It aggregates metadata from a lot of different Maven repositories and even shows you how to use them in Gradle.
In your case, you can find the javax.inject library here. Notice that the only published version is simply 1 and not 1.0. Change this and it should work.
When downloading dependencies using Gradle it seems to exclude optional dependencies. For example, I included Guava:
compile 'com.google.guava:guava:19.0'
and it did not download the optional dependencies listed here: https://mvnrepository.com/artifact/com.google.guava/guava/19.0
I've been learning Gradle and porting a legacy app to use Gradle. That application had a Python script wrapper that always downloaded the optional dependencies and I've kind of hit a wall here.
According to the description of the Maven's Optional Dependencies:
If a user wants to use functionality related to an optional dependency, they will have to redeclare that optional dependency in their own project.
Gradle has the same behavior as Maven, if you want to use some transitive optional dependencies - you have to declare them manually.
You can try to find some workaround, but anyway, it seems to be a little odd, to include all optional dependencies by default, don't even check, whether are they really needed. Sure, you can try to port your logic to run existent Python script with Gradle to collect all optional dependencies into local directory and declare it as file dependencies.
In a project of mine I have a dependency on a java matrix library MTJ which I specify like this in build.gradle:
dependencies {
...
compile 'com.googlecode.matrix-toolkits-java:mtj:1.0.4'
...
}
MTJ in turns depends on netlib, more concretely it would be the equivalent of explicitly adding compile 'com.github.fommil.netlib:all:1.1.2' above.
When I run the gradle build. I get the following error:
Could not expand ZIP '/Users/valentin/.gradle/caches/modules-2/files-2.1/com.github.fommil.netlib/all/1.1.2/f235011206ac009adad2d6607f222649aba5ca9e/all-1.1.2.pom'.
archive is not a ZIP archive.
So somehow gradle is confused and treats the file as been a zip file when it is just a pom that points to other dependencies.
Anyone has a fix or knows of a workaround?
Please have a look here. The dependency you specified is of type pom - this type in maven is used to aggregate projects. Gradle downloads it, tries to unzip and fails. It seems that this is not what you're looking for.
Here you can find other artifacts for group: com.github.fommil.netlib. Please find a jar you're looking for and specify the dependency directly.
Normally I would expect the dependencies task in Gradle to help me out, which it normally does. Now I have this issue when I print the dependency tree:
xml-apis:xml-apis:1.4.01 -> 2.0.2
xml-apis:xml-apis:1.3.04 -> 2.0.2
I have many of these lines where 1.3.04 and 1.4.01 get overriden, however, I have no line that explicitly shows a direct or transitive dependency to 2.0.2 version.
Where can 2.0.2 come from if there is no line with xml-apis:xml-apis:2.0.2 in the dependency tree?
How is that possible?
It's in there somewhere, try running gradle dependencyInsight --dependency xml-apis to find out.
This could be Gradle custom ResolutionStrategy working: https://docs.gradle.org/2.4/userguide/dependency_management.html#N15583, https://docs.gradle.org/2.4/dsl/org.gradle.api.artifacts.ResolutionStrategy.html. It can be instructed to use arbitrary version of any library, even if that version wouldn't otherwise be present anywhere in the dependency tree. It can also replace one library with another (log4j with log4j-over-slf4j, for example).
In build section of my effective pom there is a Maven plugin that I don't want to use (it was used before, but now I want to remove it).
I removed this plugin from every parent of my project, but is is still applied.
How do I find out where this plugin declaration come from?
UPDATE:
It turns out this plugin was an implicit dependency of another one. It was not declared as such, but referenced from plugin's components.XML leading to runtime dependency injection. The problem was found by pure luck. I think the question is still relevant - it should be possible to find implicit plugin dependencies without wasting a day or two.
Have you run
mvn install
on the parent pom when you deleted the plugin from there?
When you run mvn from submodule it actually looks into your local repository for parent/siblings modules (jars, poms), not to filesystem (compared to maven using the result of the build when you run whole parent project build with submodules).
If it doesn't help, have a look if it's not coming from super pom. You can see super pom on maven website:
http://maven.apache.org/ref/3.0.5/maven-model-builder/super-pom.html