Maven Help [I'm new to Maven]

Discussion in 'Spigot Plugin Development' started by ItsErik, Aug 10, 2016.

  1. Hello, everyone. I am new to maven and I am very confused. There are many threads on this topic but I keep getting lost and confused. Does someone want to dumb it down for me. What happend was that I did what the other threads said but I keep getting the error that HikariCP does not exist.

    Also there is a little red x next to the project.

    Pom.xml:
    Code (Text):
    <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>MinedGamezDev</groupId>
        <artifactId>MinedGamezAPI</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>MinedGamez API</name>
        <description>MinedGamez's API</description>
        <build>
            <sourceDirectory>src</sourceDirectory>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <configuration>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.4.3</version>
                    <configuration>
                        <!-- put your configurations here -->
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>com.zaxxer</groupId>
                <artifactId>HikariCP</artifactId>
                <version>LATEST</version>
                <scope>compile</scope>
            </dependency>
        </dependencies>
    </project>
     
  2. The src directory for one isn't src, it's src/main/java for maven as that's where your source files are.
     
  3. So I changed src to src/main/java. That x is still there. (I'm really sorry if I'm sounding stupid. I have no clue what I am doing)
     
  4. What x? Mind showing an image or something?
     
  5. Also its compiling the plugin inside of the project [​IMG] http://imgur.com/a/hNfEf
     
  6. The X is on the project folder itself.http://imgur.com/a/hNfEf
     
  7. Any message in the error log? Pretty sure eclipse has an error log (haven't used it in years)
     
  8. The closest thing to an error log is when I run the Maven Install thing.

    Code (Text):
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for MinedGamezDev:MinedGamezAPI:jar:0.0.1-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-eclipse-plugin is missing. @ line 12, column 12
    [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 MinedGamez API 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MinedGamezAPI ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\src\main\resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MinedGamezAPI ---
    [INFO] No sources to compile
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MinedGamezAPI ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\src\test\resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MinedGamezAPI ---
    [INFO] No sources to compile
    [INFO]
    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MinedGamezAPI ---
    [INFO]
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MinedGamezAPI ---
    [INFO]
    [INFO] --- maven-shade-plugin:2.4.3:shade (default) @ MinedGamezAPI ---
    [INFO] Including com.zaxxer:HikariCP:jar:2.4.7 in the shaded jar.
    [INFO] Including org.slf4j:slf4j-api:jar:1.7.21 in the shaded jar.
    [WARNING] HikariCP-2.4.7.jar, MinedGamezAPI-0.0.1-SNAPSHOT.jar define 78 overlapping classes:
    [WARNING]   - com.zaxxer.hikari.pool.ProxyPreparedStatement
    [WARNING]   - com.zaxxer.hikari.metrics.dropwizard.CodahaleHealthChecker$Connection99Percent
    [WARNING]   - com.zaxxer.hikari.hibernate.HikariConnectionProvider
    [WARNING]   - com.zaxxer.hikari.metrics.dropwizard.CodaHaleMetricsTracker$1
    [WARNING]   - com.zaxxer.hikari.util.Sequence$Java7Sequence
    [WARNING]   - com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory
    [WARNING]   - com.zaxxer.hikari.pool.PoolEntry$1
    [WARNING]   - com.zaxxer.hikari.HikariDataSource
    [WARNING]   - com.zaxxer.hikari.util.Sequence$DropwizardSequence
    [WARNING]   - com.zaxxer.hikari.util.ClockSource$Factory
    [WARNING]   - 68 more...
    [WARNING] MinedGamezAPI-0.0.1-SNAPSHOT.jar, slf4j-api-1.7.21.jar define 34 overlapping classes:
    [WARNING]   - org.slf4j.helpers.SubstituteLogger
    [WARNING]   - org.slf4j.helpers.NamedLoggerBase
    [WARNING]   - org.slf4j.helpers.NOPMDCAdapter
    [WARNING]   - org.slf4j.MarkerFactory
    [WARNING]   - org.slf4j.helpers.BasicMarker
    [WARNING]   - org.slf4j.spi.LoggerFactoryBinder
    [WARNING]   - org.slf4j.MDC$MDCCloseable
    [WARNING]   - org.slf4j.spi.LocationAwareLogger
    [WARNING]   - org.slf4j.helpers.MessageFormatter
    [WARNING]   - org.slf4j.helpers.Util$ClassContextSecurityManager
    [WARNING]   - 24 more...
    [WARNING] maven-shade-plugin has detected that some class files are
    [WARNING] present in two or more JARs. When this happens, only one
    [WARNING] single version of the class is copied to the uber jar.
    [WARNING] Usually this is not harmful and you can skip these warnings,
    [WARNING] otherwise try to manually exclude artifacts based on
    [WARNING] mvn dependency:tree -Ddetail=true and the above output.
    [WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
    [INFO] Replacing original artifact with shaded artifact.
    [INFO] Replacing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT.jar with C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT-shaded.jar
    [INFO] Dependency-reduced POM written at: C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\dependency-reduced-pom.xml
    [INFO]
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ MinedGamezAPI ---
    [INFO] Installing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT.jar to C:\Users\brend\.m2\repository\MinedGamezDev\MinedGamezAPI\0.0.1-SNAPSHOT\MinedGamezAPI-0.0.1-SNAPSHOT.jar
    [INFO] Installing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\dependency-reduced-pom.xml to C:\Users\brend\.m2\repository\MinedGamezDev\MinedGamezAPI\0.0.1-SNAPSHOT\MinedGamezAPI-0.0.1-SNAPSHOT.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 8.489 s
    [INFO] Finished at: 2016-08-10T16:10:33-04:00
    [INFO] Final Memory: 12M/180M
    [INFO] ------------------------------------------------------------------------
     
    Also I cant stop using it. Im trying to force myself to start using intellij but i cant. Im so used to eclipse now.
     
  9. You need to add the version tag to the eclipse plugin

    Yeah intellij has this all built in and makes it so much easier.
     
  10. Did that still not working.


    Code (Text):
    [INFO] Scanning for projects...
    [INFO]                                                                        
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MinedGamez API 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MinedGamezAPI ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\src\main\resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MinedGamezAPI ---
    [INFO] No sources to compile
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MinedGamezAPI ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\src\test\resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MinedGamezAPI ---
    [INFO] No sources to compile
    [INFO]
    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MinedGamezAPI ---
    [INFO]
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MinedGamezAPI ---
    [INFO] Building jar: C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT.jar
    [INFO]
    [INFO] --- maven-shade-plugin:2.4.3:shade (default) @ MinedGamezAPI ---
    [INFO] Including com.zaxxer:HikariCP:jar:2.4.7 in the shaded jar.
    [INFO] Including org.slf4j:slf4j-api:jar:1.7.21 in the shaded jar.
    [INFO] Replacing original artifact with shaded artifact.
    [INFO] Replacing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT.jar with C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT-shaded.jar
    [INFO] Dependency-reduced POM written at: C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\dependency-reduced-pom.xml
    [INFO]
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ MinedGamezAPI ---
    [INFO] Installing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\target\MinedGamezAPI-0.0.1-SNAPSHOT.jar to C:\Users\brend\.m2\repository\MinedGamezDev\MinedGamezAPI\0.0.1-SNAPSHOT\MinedGamezAPI-0.0.1-SNAPSHOT.jar
    [INFO] Installing C:\Users\brend\Desktop\Penguin\Plugins\MinedGamez API\dependency-reduced-pom.xml to C:\Users\brend\.m2\repository\MinedGamezDev\MinedGamezAPI\0.0.1-SNAPSHOT\MinedGamezAPI-0.0.1-SNAPSHOT.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 5.063 s
    [INFO] Finished at: 2016-08-10T16:27:04-04:00
    [INFO] Final Memory: 13M/178M
    [INFO] ------------------------------------------------------------------------
     
     
  11. First off the X on the project is due to you needing to right click project > maven > update project.

    Are you saying hikari isn't being shaded in your jar?

    Looking at your logs.. you are shading slf4j for some reason.. even though its already in spigot..

    You should probably check your dependency hierarchy for any duplicate depends
     
    #11 Borlea, Aug 10, 2016
    Last edited: Aug 10, 2016
  12. I read in another thread that slf4j is from Hikari itself due to Hikari needing it. But I am testing it right now.
     
  13. Are you uploading the shaded jar? Seems like you aren't.
     
  14. ??? What do you mean? Should I use the one that compiles inside of the project?
     
    #14 ItsErik, Aug 10, 2016
    Last edited: Aug 10, 2016
  15. But spigot already has it..
     
  16. So Eclipse should recognize that? I just read that even if put HikariCP in it will automagically add on slf4j.

    I used that one but the plugin.yml doesn't go with it.
     
  17. Artifacts are by default compiled into ./target. You need to take the shaded jar from there and upload it onto your server.
     
  18. Yes but it doesn't compile with the plugin.yml.
     
  19. Is your plugin.yml in ./src/main/java/resources?
     
  20. No. I guess that might be y