Gson causing Maven building to error

Discussion in 'Spigot Plugin Development' started by eirikh1996, Jan 7, 2020.

  1. Hello. I have recently encountered a problem when trying to build a Maven project with Gson as a dependency. Everytime I run mvn clean install in the terminal in my IDE (I am using IntelliJ), this shows up instead of succeeding:
    Code (Text):
    Downloading from codemc-snapshots: https://repo.codemc.io/repository/maven-snapshots/com/google/code/gson/gson-parent/2.8.6/gson-parent-2.8.6.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  2.021 s
    [INFO] Finished at: 2020-01-07T20:52:59+01:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project (name hidden): Could not resolve dependencies for project io.github.eirikh1996:(name hidden):jar:1.0.0: Could not transfer artifact com.google.code.gson:gson-parent:jar:2.8
    .6 from/to codemc-snapshots (https://repo.codemc.io/repository/maven-snapshots/): Failed to transfer file https://repo.codemc.io/repository/maven-snapshots/com/google/code/gson/gson-parent/2.8.6/gson-parent-2.8
    .6.jar with status code 400 -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
     
    Here is the <repositories> in pom.xml:
    Code (Text):
    <repositories>
           <repository>
             <id>spigot-repo</id>
             <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
           </repository>
           <repository>
               <id>gson-repo</id>
               <url>https://repo1.maven.org/maven2/</url>
           </repository>
           <repository>
                <id>sk89q-repo</id>
                <url>http://maven.sk89q.com/repo/</url>
            </repository>
           <repository>
               <id>vault-repo</id>
               <url>http://nexus.hc.to/content/repositories/pub_releases</url>
           </repository>
           <repository>
               <id>ess-repo</id>
               <url>https://ci.ender.zone/plugin/repository/everything/</url>
           </repository>
           <repository>
               <id>placeholderapi</id>
               <url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
           </repository>
           <repository>
               <id>codemc-snapshots</id>
               <url>https://repo.codemc.io/repository/maven-snapshots/</url>
           </repository>
       </repositories>
    Here is the depencies:
    HTML:
    <dependency>
               <groupId>com.google.code.gson</groupId>
               <artifactId>gson</artifactId>
               <version>2.8.6</version>
           </dependency>
           <dependency>
               <groupId>com.google.code.gson</groupId>
               <artifactId>gson-parent</artifactId>
               <version>2.8.6</version>
           </dependency>
    How can I get around this problem?
     
  2. Pretty sure you dont need to use Gson-Parent. I believe it works with just gson as a depend. Make sure your .m2 directory is not corrupt too.
     
  3. You can also just depend on NMS spigot as it already has gson shaded.
     
  4. Doesn't the spigot api also have gson?