7

I must have a big blank in my knowledge of Maven, because I run into this problem on a regular basis...

I want to use Gson library (https://code.google.com/p/google-gson/) in my project. I added the following dependency to my pom.xml, as per the project's homepage:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.3</version>
</dependency>

That's nice. However, the dependency is not found by Eclipse. And that kinda makes sense. Where would it look for it? Which repository? I have a number of repositories declared in the pom.xml, but maybe none of them contain Gson.

And this is really a general question. I'd say most projects I've seen so far do not say which repository the artifact is stored in. They only provide the XML element for the dependency. What am I missing here? Does the main Maven repo contain all artifacts ever released by anyone? Please help me understand why so many projects do not say which repository their artifacts are stored in.

And if you could also tell me where do I find Gson artifact - I'd greatly appreciate it.

anton1980
  • 979
  • 3
  • 10
  • 20
  • Note to close voters, this question is asking for the official location of a specific resource provided by Google; it is **not** a request for tool or resource recommendations. – TylerH Apr 10 '23 at 13:48

1 Answers1

2

Maven searches by default for artifacts in Maven Central.

I can find this artifact in Maven Central: http://search.maven.org/#artifactdetails%7Ccom.google.code.gson%7Cgson%7C2.3%7Cjar

In your settings.xml you tell maven which are the repos you wanna search in, if you have "special" repos. There, you can configure username/passwords for these repos in case you need to upload JARs to your repo.

So if your maven cannot find it, paste here your settings.xml - maybe it is misconfigured.

BTW: does this help? GSON is not being imported into the maven pproject

Community
  • 1
  • 1
OhadR
  • 8,276
  • 3
  • 47
  • 53
  • When I search for Gson, I can find many artifacts. How do I know which one should I pick? – Line May 15 '17 at 13:29
  • 1
    where do you make this search? if you search Mavencentral, and you specify the group name and artifact name, you get a single result (with all its versions) – OhadR May 16 '17 at 05:22
  • In Maven Central. But the thing is I don't know group name. I just know that I want to use Gson - how to recognize which group name is good? – Line May 16 '17 at 06:33
  • as i wrote in my answer, the groupId='com.google.code.gson'. most of all gson's are similar, not to say identical... – OhadR May 16 '17 at 07:28
  • but why that and not another? How to choose, I mean if it is another software, not only Gson. – Line May 16 '17 at 08:17
  • 1
    originally, gson was presented by google. so the "original" version is google's, com.google.code. – OhadR May 16 '17 at 08:20