Maven Help

Discussion in 'Plugin Development' started by wesley27, Jul 15, 2014.

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

    wesley27

    Hello, I'm newer to using Maven with plugins for dependencies. I'm trying to update and work on one of my servers plugins(we wrote it, though not me). There are a bunch of errors from the pom.xml and dependencies, and it won't compile. I've looked all over the web and forums, checking to see if the pom is correct. It should be, and it should work because the writer of the plugin used the same pom.xml to compile the outdated(and semi-broken) plugin that is currently running on our server. The only thing that I've changed in it is some of the versions, from old version to "LATEST."

    I'm not really sure what's wrong.. any help would be appreciated.

    Here's my pom.xml:
    HTML:
    <!--
      Copyright (c) 2012 - All Rights Reserved
    //-snip-, stuff you guys don't need to see, this copyright and such is from our server
    -->
    <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>
     
        <!-- Project information -->
        <groupId>com.don4of4</groupId>
        <artifactId>ObsidianUtilities</artifactId>
        <version>${m.version}-${p.version}</version>
        <name>ObsidianUtilities</name>
        <url>http://obsidiancraft.com/</url>
     
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <build.number>Unknown</build.number>
            <m.version>1.0</m.version>
            <p.version>R0.5</p.version>
        </properties>
     
        <!-- Source code -->
        <scm>
    //-snip- private info, you don't need it
        </scm>
     
        <!-- Continuous integration -->
        <ciManagement>
    //-snip- private info, you don't need it
        </ciManagement>
     
        <!-- Repository locations -->
        <repositories>
            <repository>
                <id>bukkit-repo</id>
                <url>http://repo.bukkit.org/content/groups/public</url>
                <releases>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
            <repository>
                <id>sk89q-repo</id>
                <url>http://maven.sk89q.com/repo/</url>
            </repository>
        </repositories>
     
        <build>
            <defaultGoal>package</defaultGoal>
            <!-- Resources -->
            <resources>
                <resource>
                    <targetPath>.</targetPath>
                    <directory>${basedir}/src/main/resources/</directory>
                </resource>
            </resources>
            <!-- Plugins -->
            <plugins>
                <!-- Compile plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <!-- JAR creation plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.3.2</version>
                </plugin>
            </plugins>
        </build>
     
        <!-- Dependencies -->
        <dependencies>
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>LATEST</version>
                </dependency>   
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>craftbukkit</artifactId>
                <version>LATEST</version>
            </dependency>
            <dependency>
                <groupId>com.sk89q</groupId>
                <artifactId>worldedit</artifactId>
                <version>LATEST</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.sk89q</groupId>
                <artifactId>worldguard</artifactId>
                <version>LATEST</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.mchange</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.2-pre4</version>
            </dependency>
            <dependency>
                <groupId>ru.tehkode</groupId>
                <artifactId>PermissionsEx</artifactId>
                <version>LATEST</version>
            </dependency>
        </dependencies>
    </project>
    And here's the build console after running a maven clean and then a maven install(Eclipse)
    Code:
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for com.don4of4:ObsidianUtilities:jar:1.0-R0.5
    [WARNING] 'version' contains an expression but should be a constant. @ com.don4of4:ObsidianUtilities:${m.version}-${p.version}, C:\Users\Wesley\Desktop\Parts\eclipse\ObsidianUtilitiesTesting\pom.xml, line 16, column 14
    [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 ObsidianUtilities 1.0-R0.5
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/maven-metadata.xml (6 KB at 12.6 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.7.10-R0.1-SNAPSHOT/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.7.10-R0.1-SNAPSHOT/maven-metadata.xml (1004 B at 5.4 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/craftbukkit/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/craftbukkit/maven-metadata.xml (6 KB at 43.3 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/craftbukkit/1.7.10-R0.1-SNAPSHOT/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/craftbukkit/1.7.10-R0.1-SNAPSHOT/maven-metadata.xml (1009 B at 7.1 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/com/sk89q/worldedit/maven-metadata.xml
    Downloading: http://repo.bukkit.org/content/groups/public/com/sk89q/worldedit/6.0.0-SNAPSHOT/maven-metadata.xml
    Downloading: http://repo.bukkit.org/content/groups/public/com/sk89q/worldguard/maven-metadata.xml
    Downloading: http://repo.bukkit.org/content/groups/public/com/sk89q/worldguard/5.9.1-SNAPSHOT/maven-metadata.xml
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.6.2-R0.1-SNAPSHOT/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.6.2-R0.1-SNAPSHOT/maven-metadata.xml (2 KB at 8.5 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/ru/tehkode/PermissionsEx/maven-metadata.xml
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 4.052s
    [INFO] Finished at: Wed Jul 16 00:53:32 EDT 2014
    [INFO] Final Memory: 5M/160M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project ObsidianUtilities: Could not resolve dependencies for project com.don4of4:ObsidianUtilities:jar:1.0-R0.5: Failed to collect dependencies for [org.bukkit:bukkit:jar:LATEST (compile), org.bukkit:craftbukkit:jar:LATEST (compile), com.sk89q:worldedit:jar:LATEST (compile), com.sk89q:worldguard:jar:LATEST (compile), com.mchange:c3p0:jar:0.9.2-pre4 (compile), ru.tehkode:PermissionsEx:jar:LATEST (compile)]: Failed to read artifact descriptor for ru.tehkode:PermissionsEx:jar:LATEST: Failed to resolve version for ru.tehkode:PermissionsEx:jar:LATEST: Could not find metadata ru.tehkode:PermissionsEx/maven-metadata.xml in local (C:\Users\Wesley\.m2\repository) -> [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
    
    Any ideas or help? Thanks!
     
  2. Offline

    fireblast709

    wesley27 it cannot find the permissionsex dependency
     
  3. Offline

    aaomidi

    Just so you know, if your pom.xml has private information, you're doing it wrong :p
     
  4. Offline

    wesley27

    aaomidi It isn't that it's really private, it's primarily just github stuff that I would prefer not to share.

    fireblast709 What did I do wrong, or forget? How can I fix that?
     
  5. Offline

    fireblast709

    wesley27 does PEX even have a repo? If not (which I think is the case) you need to install a jar to your local repo
     
  6. Offline

    wesley27

    fireblast709 While searching around, I found this http://pex-repo.zachsthings.com/ but I'm not really sure if that's it.

    If I'm adding it to my local repo wouldn't it just be easier to have PEX as a normal referenced library, not maven?

    Also, it appears to have downloaded to my local repository already when I look. However, the only thing in the folder is the version and resolver-status.properties. The maven-metadata.xml and such files aren't there.
     
  7. Offline

    fireblast709

    wesley27 that repo would work for the supplied versions. About the second part, you cannot use external libs with maven afaik (aside system dependencies, but that is not really preferred)
     
  8. Offline

    wesley27

    fireblast709 So what would the repo be? I mean the id, I couldn't find that anywhere. Only found the author give that link.
    HTML:
            <repository>
                <id>pex-repo</id>
                <url>http://pex-repo.zachsthings.com/</url>
            </repository>
    Would that work?.

    It does appear to be in my local repository, like I said above. The latest version is in there, so I don't know why it isn't working?
     
  9. Offline

    fireblast709

  10. Offline

    wesley27

    fireblast709 Ah, I think most of it was a problem with the versions being Latest. It downloaded all of the latest versions but couldn't find the jars. I changed my dependencies section in the pom.xml to this:
    HTML:
        <!-- Dependencies -->
        <dependencies>
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.7.9-R0.2</version>
                </dependency> 
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>craftbukkit</artifactId>
                <version>1.7.9-R0.2</version>
            </dependency>
            <dependency>
                <groupId>com.sk89q</groupId>
                <artifactId>worldedit</artifactId>
                <version>5.6.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.sk89q</groupId>
                <artifactId>worldguard</artifactId>
                <version>5.9</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.mchange</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.2-pre4</version>
            </dependency>
            <dependency>
                <groupId>ru.tehkode</groupId>
                <artifactId>PermissionsEx</artifactId>
                <version>1.21.4</version>
            </dependency>
        </dependencies>
    I then manually added the actual pex jar to the local repo like you said. Now there are no errors, however the build still failed because of a class issue. Here's the build log.
    Code:
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for com.don4of4:ObsidianUtilities:jar:1.0-R0.5
    [WARNING] 'version' contains an expression but should be a constant. @ com.don4of4:ObsidianUtilities:${m.version}-${p.version}, C:\Users\Wesley\Desktop\Parts\eclipse\ObsidianUtilitiesTesting\pom.xml, line 16, column 14
    [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 ObsidianUtilities 1.0-R0.5
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo.bukkit.org/content/groups/public/com/sk89q/worldguard/5.9.1-SNAPSHOT/maven-metadata.xml
    Downloading: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.6.2-R0.1-SNAPSHOT/maven-metadata.xml
    Downloaded: http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/1.6.2-R0.1-SNAPSHOT/maven-metadata.xml (2 KB at 8.0 KB/sec)
    Downloading: http://repo.bukkit.org/content/groups/public/net/gravitydevelopment/updater/updater/maven-metadata.xml
    [INFO]
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ ObsidianUtilities ---
    [debug] execute contextualize
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 966 resources to .
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ObsidianUtilities ---
    [INFO] Compiling 24 source files to C:\Users\Wesley\Desktop\Parts\eclipse\ObsidianUtilitiesTesting\target\classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] \Users\Wesley\Desktop\Parts\eclipse\ObsidianUtilitiesTesting\src\main\java\com\don4of4\obsidianutilities\listeners\main_MarketRestrictions.java:[265,0] error: class, interface, or enum expected
    [INFO] 1 error
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 8.681s
    [INFO] Finished at: Wed Jul 16 10:49:40 EDT 2014
    [INFO] Final Memory: 8M/164M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ObsidianUtilities: Compilation failure
    [ERROR] \Users\Wesley\Desktop\Parts\eclipse\ObsidianUtilitiesTesting\src\main\java\com\don4of4\obsidianutilities\listeners\main_MarketRestrictions.java:[265,0] error: class, interface, or enum expected
    [ERROR] -> [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/MojoFailureException
    
    I'm pretty sure that's nothing wrong with maven, just an error in one of my classes that I can fix. Am I correct? I'm just making sure that maven is fine so I can forget about it :p
     
  11. Offline

    fireblast709

    wesley27 seems like a standard syntax error to me ;)
     
  12. Offline

    wesley27

    fireblast709 Yup, fixed it and got it built and compiled just fine. Thank you so much for the help and putting up with a maven noob :p
     
Thread Status:
Not open for further replies.

Share This Page