Search code examples
javamavenintellij-ideadependenciesminecraft

Maven dependency not found for org.bukkit:bukkit


The groudID, artifactId and version dependencies are not being found in Maven?

I followed this tutorial to set up a Minecraft plugin which uses Maven.

But I get the error

org.bukkit:bukkit:1.7.2-RO3 not found

and the text font is red where everything else in the pom file is white.

Here is the code in the pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.chrismepham</groupId>
    <artifactId>TestPlugin</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>bukkit-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.7.2-R0.3</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>

Why is the dependency not being found? EDIT:

I changed the repository and dependency version as suggested but still have the error as shown in the picture: red text


Solution

  • The reason the text is red is because that dependency you've specified can't be found in either maven central, or the additional repository you've added.

    Paste the repo link into a browser, and you'll find that the dependency is actually 1.8-R0.1-SNAPSHOT not 1.7.2-RO3 as the tutorial mentioned (maybe the tutorial is out of date, or that dependency has since been removed for some reason)

    Change the dep to

    <dependencies>
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.8-R0.1-SNAPSHOT</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    

    If you haven't already set auto-import on intelliJ, you'll get a popup in the top right hand corner asking if you want to re-import. IntelliJ then reads your pom.xml file, works out what dependencies you need and then downloads them.

    You should see org.bukkit.bukkit under external dependencies in the left hand "projects" window, along with some other libraries it depends on, such as guava and commons lang.