Solved I can't compile my 1º plugin

Discussion in 'Plugin Development' started by MadeinWare, Dec 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MadeinWare

    i followed the guide "Plugin Tutorial" for make a basic plugin (Called "ayuda").

    So I've these files:

    The file Pom.xml:
    Code:
    <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.mi.email</groupId>
      <artifactId>ayuda</artifactId>
      <version>0.0.1-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>spigot-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.8-R0.1-SNAPSHOT</version>
               <type>jar</type>
               <scope>provided</scope>
           </dependency>
       </dependencies>
    </project>
    The principal Class:
    Code:
    package com.miemail.ayuda;
    import org.bukkit.plugin.java.JavaPlugin;
    public class ayuda extends JavaPlugin{
        public void onEnable(){
            getLogger().info("Se ha activado el plugin");
            this.getCommand("ayuda").setExecutor(new EjecutarComando(this));
        }
        public void onDisable(){
            getLogger().info("Se ha desactivado el plugin");
        }
    }
    
    And another Class (CommandExecutor):
    Code:
    package com.my.email.ayuda;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.entity.Player;
    public class EjecutarComando implements CommandExecutor {
        private final ayuda plugin;
        public EjecutarComando(ayuda plugin){
            this.plugin=plugin;
        }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("ayuda")){
                if(sender instanceof  Player){
                    Player player = (Player) sender;
                    sender.sendMessage("Bien");
                }else{
                    sender.sendMessage("¡Este comando es para jugadores!");
                }
                return true;
            }
            return false;
        }
    }
    
    Then i've the plugin.yml:
    Code:
        name: ayuda
        main: com.my.email.ayuda.ayuda
        version: 1.0
        commands:
          ayuda:
            description: Ver comandos disponibles.
            usage: /ayuda <pagina>
            permission: sm.ayuda
            permission-message: No puedes hacer eso.
    And the error when i do "Run as>7 Maven generate-sources:
    Code:
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for com.my.email:ayuda:jar:0.0.1-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 8, column 19
    [WARNING]
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING]
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING]
    [INFO]                                                                       
    [INFO] ------------------------------------------------------------------------
    [INFO] Building ayuda 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.125 s
    [INFO] Finished at: 2015-12-20T14:25:51-03:00
    [INFO] Final Memory: 4M/15M
    [INFO] ------------------------------------------------------------------------
    
    What does it mean?

    Solved
    I needed to add the <version> in the pom.xml file:
    Code:
    <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>2.3.2</version>
                  <configuration>
                      <source>1.8</source>
                      <target>1.8</target>
                  </configuration>
              </plugin>
          </plugins>
     
    Last edited: Dec 20, 2015
  2. Offline

    Lightspeed

    Instead of getLogger you can use(If is easier)> System.out.println("Any text here to print to console.");
    Please follow java naming conventions(Main class doesn't start with a capital).
    I can't help you with building as I just export my plugins.
     
    MadeinWare likes this.
  3. Offline

    MadeinWare

    Thanks you for the advice.
     
  4. Offline

    LucasEmanuel

    Um, it says "BUILD SUCCESS" right there in the maven output. The rest is just maven being cranky.
     
  5. Offline

    Irantwomiles

     
  6. Offline

    LucasEmanuel

    That is just Maven being cranky that the OP didn't specify a version for the compiler plugin. You can generally ignore those, unless you create some very hacky crap code that requires a special version of a maven plugin.
     
Thread Status:
Not open for further replies.

Share This Page