Spigot Maven

Discussion in 'Wiki Discussion' started by jtaylor69, Dec 8, 2014.

  1. jtaylor69

    Moderator Wiki Team

    Spigot Maven

    Spigot Maven Repository

    Information on what to add to your pom.xml for Spigot-api and Bukkit



    Maven Repository(top)

    Spigot has a maven repository if you use it to build your plugins.
    https://hub.spigotmc.org/nexus/#view-repositories;snapshots~browsestorage

    If you want to use Spigot API, in addition to Bukkit, you should use just the Spigot API. If you want to use NMS, you must run BuildTools found here: https://www.spigotmc.org/wiki/buildtools/. BuildTools handles creating Bukkit, CraftBukkit, Spigot, and the Spigot-API.

    pom.xml(top)

    This is an example of what to put in your pom.xml to get the API's from the repository.
    You should only use one of them, either bukkit or spigot-api as the spigot-api dependency includes everything that the bukkit one does.
    Just add the following code in your pom file.
    Code (XML):
    <repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>
    <dependencies>
        <!--Spigot API-->
        <!--You only need one of the two, don't put both. Spigot is recommended.-->
        <dependency>
               <groupId>org.spigotmc</groupId>
               <artifactId>spigot-api</artifactId>
               <version>1.13-R0.1-SNAPSHOT</version>
               <scope>provided</scope>
        </dependency>
        <!--Bukkit API-->
        <!--You only need one of the two, don't put both. Spigot is recommended.-->
        <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.13-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
        </dependency>
    </dependencies>

    build.gradle(top)

    Add this to your repositories block to use the spigot-api module:
    Code (Text):
    maven {
       url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
    }
    Or, to use the spigot module, just add your local maven repository (using mavenLocal()).

    Then, add this to your dependencies block:
    Code (Text):
    compileOnly "org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT"
    A full build.gradle would look like this:
    Code (Text):
    group 'your.group'
    version '1.0-SNAPSHOT'

    apply plugin: 'java'

    repositories {
        mavenCentral()
        maven {
            url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
        }
    }

    dependencies {
        compileOnly "org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT"
    }
     
    • Like Like x 2
    • Informative Informative x 1
    • Useful Useful x 1
  2. Code (Text):

    * What went wrong:
    Could not resolve all dependencies for configuration ':compile'.
    > Could not resolve org.bukkit:bukkit:1.8-R0.1-SNAPSHOT.
      Required by:
          de.albionco:Highlighter:1.0.0
       > Unable to load Maven meta-data from https://hub.spigotmc.org/nexus/content/groups/public/org/bukkit/bukkit/1.8-R0.1-SNAPSHOT/maven-metadata.xml.
          > Could not GET 'https://hub.spigotmc.org/nexus/content/groups/public/org/bukkit/bukkit/1.8-R0.1-SNAPSHOT/maven-metadata.xml'.
             > Connection to https://hub.spigotmc.org refused
     
    Hmm, any thoughts?
    Using a third party repo currently, tried switching and this happened.

    I use Gradle by the way.

    Code (Text):
    repositories {
        mavenCentral()
        maven {
            url 'https://hub.spigotmc.org/nexus/content/groups/public/'
        }
    }

    dependencies {
        compile group: 'org.bukkit', name: 'bukkit', version: '1.8-R0.1-SNAPSHOT'
        testCompile group: 'junit', name: 'junit', version: '4.10'
    }
     
    #2 smrkn, Dec 10, 2014
    Last edited: Jul 15, 2015
  3. Fully working with Gradle now.
    Thanks for the continued work.
     
  4. I get this error.. after i write down the spigot dependcency and doesnt work.

    Code (Text):
    Failure to transfer net.md-5:bungeecord-chat:jar:1.8-20150606.084332-80 from https://oss.sonatype.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-nexus-snapshots has elapsed or updates are forced. Original error: Could not transfer artifact net.md-5:bungeecord-chat:jar:1.8-20150606.084332-80 from/to sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots): The operation was cancelled.

    org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer net.md-5:bungeecord-chat:jar:1.8-20150606.084332-80 from https://oss.sonatype.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-nexus-snapshots has elapsed or updates are forced. Original error: Could not transfer artifact net.md-5:bungeecord-chat:jar:1.8-20150606.084332-80 from/to sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots): The operation was cancelled.
        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
        at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:215)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:188)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:119)
        at org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:636)
        at org.eclipse.m2e.core.internal.project.registry.DefaultMavenDependencyResolver.resolveProjectDependencies(DefaultMavenDependencyResolver.java:63)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:529)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:491)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:495)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:350)
        at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:297)
        at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.getProjectFacade(MavenBuilder.java:154)
        at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:89)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
        at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
        at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
        at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
        at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
        at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
        at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
        at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
        at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
     
     
  5. dependency org.bukkit works though.. does this mean i have to use only that and not the org.spigotmc
     
  6. Go to your local maven repository and delete the folder org/spigotmc/spigot-api
     
  7. Doesn't work for the class reference MinecraftServer
     
  8. have you added craftbukkit as a dependency?
     
  9. You can't use this repository then, you would have to use the dependencies BuildTools installs to your local repository (which happens to be spigot and craftbukkit) and these ones have the NMS code in it. If you have used BuildTools you should be able to use these dependencies without any repositories.

    This is the dependency of spigot
    Code (Text):
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot</artifactId>
        <version>1.10.2-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
     
    • Like Like x 1
  10. I copied the repository and dependency information from here into my pom.xml, but I receive the following error. I am new to Maven and to plugin development. What might I be doing wrong?

    Code (Text):
    ArtifactDescriptorException: Failed to read artifact descriptor for org.spigotmc:spigot-api:jar:1.10.2-R0.1-SNAPSHOT: ArtifactResolutionException: Failure to transfer org.spigotmc:spigot-api:pom:1.10.2-R0.1-SNAPSHOT from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigot-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:pom:1.10.2-R0.1-SNAPSHOT from/to spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
     
  11. electronicboy

    IRC Staff

    What are you trying to build that on? Looks like your cacerts are busted
     
    • Like Like x 1
  12. Run it with the `-U` flag for one time. e.g `mvn clean install` -> `mvn clean install -U` to force updates. Also if this fails, compile Spigot from build tools and run this command again.
     
  13. Which pom.xml file is meant in the article?

    Thats how my build directory looks:
    Code (Text):
    apache-maven-3.2.5  BuildTools.log.txt  craftbukkit-1.10.2.jar  work
    BuildData           Bukkit              Spigot
    BuildTools.jar      CraftBukkit         spigot-1.10.2.jar
    And those are all the pom.xml files:
    Code (Text):
    ./Bukkit/pom.xml
    ./CraftBukkit/pom.xml
    ./CraftBukkit/dependency-reduced-pom.xml
    ./Spigot/pom.xml
    ./Spigot/Spigot-Server/pom.xml
    ./Spigot/Spigot-Server/dependency-reduced-pom.xml
    ./Spigot/Spigot-API/pom.xml
    ./Spigot/Bukkit/pom.xml
    ./Spigot/CraftBukkit/pom.xml
     
  14. electronicboy

    IRC Staff

    the pom for your project, you don't need to touch the poms' from the repos for buildtools. I would suggest reading up on how to use maven, worth noting that IntelliJ makes maven nicer, and even has a plugin that will help setup a maven project folder for bukkit plugins, as well as a few other popular systems ^^
     
  15. Craftbukkit doesn't work.
     
  16. Now it's working. I forget the Buildtools :D
     
  17. FrostedSnowman, why did you revert the formatting I set? <dependencies> and <repositories> are supposed to be on the same level in the pom... they shouldn't be indented like that.
     

Share This Page