williamahartman / Jamepad

A better way to use gamepads in Java
Other
110 stars 30 forks source link

Gradle incompatability caused by package namespace conflict #10

Closed Gamebuster19901 closed 5 years ago

Gamebuster19901 commented 5 years ago

When gradle downloads the project from release 1.3, it is missing libjdx in its entirety, with the exception of this class. This is most likely caused by the fix to #4 (https://github.com/williamahartman/Jamepad/commit/90eecf930c4675b168f11c8f34135eb8d03a0ff2).

I suspect gradle is seeing that the package 'com.badlogic.gdx.jnigen' exists within Jamepad-1.3.zip so it believes that it already has libgdx included within it. So then gradle proceeds to skip downloading libgdx.

I don't know why it took this long for it to affect me.

image

Crash Log: https://pastebin.com/YvhfuVZg

electronstudio commented 5 years ago

Gradle shouldn't be using package names to decide what to download. What version of Gradle are you using? (I'm using 4.10.2 and it works.) . Have you tried deleting all the gradle caches? It could also be some problem with jitpack.io since I haven't tested that at all.

electronstudio commented 5 years ago

Have you got in your build.gradle:

dependencies {
    compile "com.badlogicgames.gdx:gdx-jnigen:1.9.9"
}
Gamebuster19901 commented 5 years ago

I'm using ForgeGradle 2.3 which appears to be using Gradle 2.12.

Cleaning the Cache and redownloading everything had no effect.

Gamebuster19901 commented 5 years ago

No, I'll add that now

electronstudio commented 5 years ago

It looks like previous releases bundled all of Jnigen inside the Jamepad jar. Release 1.3 doesn't do that. So either I need to bundle it, or update the documentation to tell people they need to add that dependency. Not sure which is best.

Gamebuster19901 commented 5 years ago

Adding the dependency had no effect.

Gamebuster19901 commented 5 years ago

Nevermind, I had to clean the cache again. Adding the dependency did work.

Thanks for your help.

electronstudio commented 5 years ago

It's strange though. I just built the latest version of MineJoy (from 2 days ago) and got this ouput

Download https://jitpack.io/com/github/williamahartman/Jamepad/1.3/Jamepad-1.3.pom
Could not resolve: net.minecraftforge:forgeBin:1.12.2-14.23.5.2769
Download https://jitpack.io/com/github/williamahartman/Jamepad/1.3/Jamepad-1.3.jar
Download https://jitpack.io/com/github/williamahartman/Jamepad/1.3/Jamepad-1.3-sources.jar
Download https://jitpack.io/com/github/williamahartman/Jamepad/1.3/Jamepad-1.3-javadoc.jar
Download https://jcenter.bintray.com/com/badlogicgames/gdx/gdx-jnigen/1.9.9/gdx-jnigen-1.9.9-javadoc.jar
Download https://jcenter.bintray.com/com/github/javaparser/javaparser-core/2.3.0/javaparser-core-2.3.0-javadoc.jar
Download https://jcenter.bintray.com/com/google/guava/guava/18.0/guava-18.0-sources.jar
Download https://jcenter.bintray.com/com/google/guava/guava/18.0/guava-18.0-javadoc.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.6/commons-codec-1.6-javadoc.jar

So it was downloading Jnigen already.

electronstudio commented 5 years ago

Wait, no, it was downloading the javadoc for Jnigen

Gamebuster19901 commented 5 years ago

It looks like previous releases bundled all of Jnigen inside the Jamepad jar. Release 1.3 doesn't do that.

It looks like version 1.3 does have it bundled though?

image

Gamebuster19901 commented 5 years ago

That's why I was assuming gradle was downloading the .zip release file instead of the .jar release file. The .zip file only has 1 file in that directory.

electronstudio commented 5 years ago

You're right 1.3 does include all the Jnigen classes. I don't think Gradle would know where to download the zip file, that's something generated by Github.

The POM file from jitpack.io contains this:

 <dependency>
      <groupId>com.badlogicgames.gdx</groupId>
      <artifactId>gdx-jnigen</artifactId>
      <version>1.9.9</version>
      <scope>compile</scope>
    </dependency>

I guess the scope should be 'runtime' not 'compile'. That might be affecting it.

Gamebuster19901 commented 5 years ago

I bet its jitpack using the zip file. I'm still able to get Jamepad 1.2 even though the release doesn't have a jar file.

electronstudio commented 5 years ago

OK, so when building Jamepad it does deliberately add all the class files for all dependencies to the jar file when you run 'gradle dist'. (When you run 'gradle jar' it doesnt do that). My inclination is that they shouldn't be bundled. Gradle knows about the dependencies from the POM and should download them separately.

Possibly this bundling was done because jitpack.io doesn't produce correct POM files. I'm not sure. I guess I should switch to Bintray.

electronstudio commented 5 years ago

btw you might like to try https://github.com/electronstudio/sdl2gdx It was originally based on Jamepad. I was going to remove all the Jamepad stuff and make it a completely separate project, but currently the Jamepad API is still in there and should be usable.