1.14.4 Maven

Discussion in 'Spigot Plugin Development' started by Ardno, Feb 14, 2020.

  1. Hello,
    I'm making a plugin(with Maven) first time and I have problem.
    My pom.xml:
    Code (Text):
    <?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>test</groupId>
        <artifactId>Test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
        </properties>
       
        <repositories>
        <!-- This adds the Spigot Maven repository to the build -->
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        </repositories>

        <dependencies>
        <!--This adds the Spigot API artifact to the build -->
        <dependency>
               <groupId>org.spigotmc</groupId>
               <artifactId>spigot-api</artifactId>
               <version>1.14.4-R0.1-SNAPSHOT</version>
               <scope>provided</scope>
        </dependency>

        <!--This adds the Bukkit API artifact to the build -->
        <!-- Do not include this in the pom.xml file if the Spigot API is already added -->
        <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.14.4-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
        </dependency>
        </dependencies>
    </project>
    Screen of side of program:
    upload_2020-2-14_21-17-46.png

    Screen from code:
    upload_2020-2-14_21-20-17.png

    I must download the depencies or how? Because I have in offer(if I rightclick on bukkit) offer send me a table of possibilities and first is manually install artifact. How can I resolve this problem?
     
  2. When usng Maven you add the dependencies to the pom.xml not manually.
    For example, for Guava
    HTML:
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>28.2-jre</version>
    </dependency>
    for GSON
    HTML:
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.6</version>
    </dependency>
     
    About the problem with the JavaPlugin, what does the error say, what do you have imported?
     
  3. Don't depend on Bukkit and Spigot, only Spigot is sufficient.
     
    • Agree Agree x 1
  4. I try this

    I set only the depend to pom.xml and if I go to code, there're is error light bulb and if I click, there are possibility with create the JavaPlugin class in my maven project
     
  5. md_5

    Administrator Developer

    Just build once (f11) and it will be downloaded
     
  6. Code (Text):
    Scanning for projects...
                                                                         
    ------------------------------------------------------------------------
    Building Test 1.0-SNAPSHOT
    ------------------------------------------------------------------------
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom

    ------------------------------------------------------------------------
    BUILD FAILURE
    ------------------------------------------------------------------------
    Total time: 0.369s
    Finished at: Sat Feb 15 10:20:41 CET 2020
    Final Memory: 7M/309M
    ------------------------------------------------------------------------
    Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

    To see the full stack trace of the errors, re-run Maven with the -e switch.
    Re-run Maven using the -X switch to enable full debug logging.

    For more information about the errors and possible solutions, please read the following articles:
    [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
    pom.xml
    Code (Text):
    <?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>test</groupId>
        <artifactId>Test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
        </properties>
       
        <repositories>
        <!-- This adds the Spigot Maven repository to the build -->
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        </repositories>

        <dependencies>
        <!--This adds the Spigot API artifact to the build -->
        <dependency>
               <groupId>org.spigotmc</groupId>
               <artifactId>spigot-api</artifactId>
               <version>1.14.4-R0.1-SNAPSHOT</version>
               <scope>provided</scope>
        </dependency>
        </dependencies>
    </project>
     
  7. md_5

    Administrator Developer

    You need to update Maven.
    Make sure you’re using Netbeans 11.2, that might have a working by default Maven.
    Otherwise you’ll need to download Maven 3.6.3 and point netbeans to it in settings