I'd like to use the Guava collection com.google.common.graph.ImmutableDirectedGraph, documented here, with Maven. I can't find the Maven dependency name and version including this particular class/API on the usual repositories.
What would be the correct Maven dependency/ies ?
It doesn't look like this API has been published to Maven central yet, but I see it in the latest snapshot, 20.0-SNAPSHOT on Github:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0-SNAPSHOT</version>
</dependency>
Related
io.micrometer:micrometer-core:micrometer-core-1.10.0.M1-redhat-00001.pom defines a dependency on io.micrometer:micrometer-commons:micrometer-commons-1.10.0.M1-redhat-00001
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-commons</artifactId>
<version>1.10.0.M1-redhat-00001</version>
<scope>compile</scope>
</dependency>
And io.micrometer:micrometer-commons:micrometer-commons-1.10.0.M1-redhat-00001.pom does not specify <packaging> to be pom. Therefore it is using default packaging type of jar.
However, there is no micrometer-commons-1.10.0.M1-redhat-00001.jar available here.
Is there anything wrong in Micromere 1.10.0.M1-redhat-00001?
The repo that you are using is not the official repo of Micrometer.
Check the docs and the readme, Micrometer artifacts can be found here:
Stable: https://search.maven.org/search?q=g:io.micrometer
Milestone: https://repo.spring.io/ui/native/milestone/io/micrometer
Snapshot: https://repo.spring.io/ui/native/snapshot/io/micrometer
If you want to use the non-official redhat repo, please contact redhat support.
I know there are a lot of questions answered for dependency exclusion with maven. Sadly I couldn't find an answer for my situation, since I don't want to replace the excluded lib with another version of my own.
Let me describe the exact problem.
We are using swagger for our REST endpoint documentation. Hence, swagger is declared a dependency in the pom file.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
Swagger itself declares google guava as compile dependency like this:
springfox-swagger2
-> springfox-spi
-> springfox-core
-> guava
Now guava is available in our project and people start using it, which we want to prevent. I tried to exclude guava from the swagger dependency like this:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
Now Eclipse tells me that swagger is referencing a lib from guava that is not on the classpath. Isn't it possible to tell maven I don't want to have the transitive dependency in my project but let swagger use it as it may.
You can use the Maven dependency plugin with the analyze-only goal:
https://maven.apache.org/plugins/maven-dependency-plugin/analyze-only-mojo.html
Here, you can fail the build if someone directly uses a transitive dependency (without declaring it explicitly). This would especially fail the build if someone uses guava without putting guava into the pom.
You could try static code analysis tools. Possible answer for your question: https://stackoverflow.com/a/7475862/7550277
Or via Maven plugins: here and here.
Added the following dependency in pom.xml.
<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-data-spreadsheet-v3</artifactId>
<version>1.0.10-alpha</version>
</dependency>
But it doesn't seem to work. It doesn't contain any of the required classes. For example, SpreadsheetService, SpreadsheetFeed, SpreadsheetEntryetc.
Is there any other maven repository for Google Spreadsheet?
Also, in this documentation, they haven't mentioned any maven repository. So, do I have to manually download the required JARs and add them to my project?
After some searching and experimentation, I finally found the dependency which contains the required classes to work with Google Spreadsheets. Here it is -
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
<version>1.47.1</version>
</dependency>
To test this, I used the code given here.
As far as getting authorization is concerned, look at this answer.
I want to try kafka 0.8 (as I understand it is already released). But where can I find the kafka maven repository.
And what additional repository url should I add?
I've found some blogs with
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.8.0</artifactId>
<version>0.8.0-SHA</version>
</dependency>
but it is not works. I'm looking for proper maven dependency. Or should I checkout it from git and deploy in our internal artifactory?
UPDATE
Since November 2013 official Kafka releases can be found on public Maven repository, the latest version in March 2015 being 0.8.2.1:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.1</version>
</dependency>
If you created the not.released:kafka artifact detailed below any more you can remove it from the local repository.
Original Answer
Kafka is not released yet to a public Maven repository, but you can add it to your local Maven repository by hand with the install-file command:
mvn install:install-file -Dpackaging=jar -DgroupId=not.released
-DartifactId=kafka -Dversion=0.8.0 -Dfile=kafka.jar
The command line above expects kafka.jar file in the current working directory.
Once installed you can use it with:
<dependency>
<groupId>not.released</groupId>
<artifactId>kafka</artifactId>
<version>0.8.0</version>
</dependency>
Once they release Kafka you can just change the dependency in your POMs and remove / uninstall this file from your local repository.
As of December 2013, Kafka 0.8 Final was released and is available under the following definition:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.0-beta1</version>
</dependency>
Even though this is already answered, I think future readers might benefit from a complete simple example that works out of the box. I put one together here >
https://github.com/buildlackey/cep
Like the o.p., I have been fighting to find a Maven pom.xml recipe that will allow me to pull in an official version of Kafka from a public Maven repository. I did manage to get my example working, but for now I have had to hack
my dependencies so that the version of Kafka I use is pulled from a work-in-progress version of a
storm-kafka integration project. I'm concerned the 'wip' versions below will be deprecated.
Then this project will lose its dependencies and fail to build properly. Also, I
really shouldn't be introducing storm for this simple Kafka example at this point in any case.
storm
storm
0.9.0-wip17
storm
storm-core
0.9.0-wip17
storm
storm-kafka
0.9.0-wip16a-scala292
If someone could provide me with a patch for 'the right way' to do this with Maven I will update my project accordingly.... Hopefully it will serve as a useful resource for other beginning Kafka developers.
Just go to http://mvnrepository.com/artifact/org.apache.kafka and choose from the list kafka repository matching to your version.
You can find all the realease version here:
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.kafka%22
Here is another clue:
<dependency>
<groupId>com.sksamuel.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.0-beta1</version>
</dependency>
I added some jars as dependencies in pom.xml, but it seems that some of them are useless because those jars were already downloaded using dependencies mechanism...
Is there a way to see those "built-in" dependencies, so that I could add only the needed dependencies in my pom.xml?
For example if I add a hibernate dependency in pom.xml one for cglib is not needed.
Don't do that - list every dependency of your code, but not of the libraries you use; Maven will do its transitive dependency thing and take care of them.
you can run mvn dependency:tree to get the whole tree including the transient dependencies that get included in your project.
There you can start looking
Hope that helped
First, check out Transitive Dependencies:
Transitive dependencies are a new
feature in Maven 2.0. This allows you
to avoid needing to discover and
specify the libraries that your own
dependencies require, and including
them automatically.
Then, a good dependency analyzer will help...
The mvn command-line is your first aid:
mvn dependency:tree
Sometimes you have to figure out where the version numbers came from (See also: Dependency Management). Here you'll have to unveil the parent relationships, and the 'effective-pom' command can help with that:
mvn help:effective-pom
Tool support is helpful as well...
m2eclipse has a Dependency Tree tab that shows how the different hierarchies collapse::
alt text http://www.sonatype.com/books/m2eclipse-book/reference/figs/web/eclipse_pom-editor-depend-tree.png
IntelliJ has another interesting view that lets you detect the conflicts:
(source: jetbrains.com)
If you are using Eclipse then you are see a visual dependency tree which is automatically generated. While adding a dependency if you do not want it to automatically pull some transitive dependencies use the exclusions tag like so
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
</exclusion>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
</exclusions>
</dependency>
There are some known conflicts when using certain versions of hibernate and AOP due to cglib.
Is there a way to see those "built-in" dependencies, so that I could add only the needed dependencies in my pom.xml?
There are no built-in dependencies. However, when declaring a dependency on a given artifact, Maven will also retrieve the dependencies of this dependency, transitively. Such dependencies are called 3.4.4. Transitive Dependencies:
A transitive dependency is a dependency of a dependency. If project-a depends on project-b, which in turn depends on project-c, then project-c is considered a transitive dependency of project-a. If project-c depended on project-d, then project-d would also be considered a transitive dependency of project-a.
So if you need a dependency in your project, just declare it (and the dependencies of this dependency will come transitively).
To visualize the dependency tree of a project, the best tool is mvn dependency:tree (or any fronted offered by your favorite IDE). This is a must use tool to analyze your dependencies and check them for proper convergence and potential conflicts resulting in expected version being used.
For example if I add a hibernate dependency in pom.xml one for cglib is not needed.
Actually, this is a bad example, cglib is an optional dependency of Hibernate Core which declares in its pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-cglib-repack</artifactId>
<version>2.1_3</version>
<optional>true</optional><!-- think of it as "excluded by default" -->
</dependency>
Hibernate gives you the choice between javassist and cglib, it's up to you to decide which one to use and to declare it explicitly, hence the optional status.
See also
Introduction to the Dependency Mechanism
The whole section 3.4. Project Dependencies in the Maven Reference Guide