Hello
Sorry if the question was answered already.
I’m having a problem running my project when depending on external JARs and other Eclipse projects.
The desktop version works fine. However the GWT/HTML projects seems unable to see dependencies
I can’t run the html version - it crashes with this message like:
[ERROR] Line 6: The import com.jfixby.red cannot be resolved
[ERROR] Line 7: The import com.jfixby.red cannot be resolved
[ERROR] Line 8: The import com.jfixby.red cannot be resolved
...
while the referred lines are:
import com.jfixby.red.mp.TheGame; // inside other project
import com.jfixby.red.triplane.fokker.starter.gwt.FokkerStarterGwt; // inside other project
import com.jfixby.red.triplane.fokker.starter.gwt.FokkerStarterGwtConfig; // inside other project
...
Here is what I did:
- I removed all required my (external) dependencies from the gradle-produced projects build path. So it shows red (“unable to compile”) flags.
- I compiled all my dependencies (eclipse projects) to *.JAR files
- I edited the build.gradle file in the root project of the gradle-produced projects by adding the following text:
compile fileTree(dir: 'D:/[DATA]/[DEV]/libs/red-triplane', include: '*.jar')
compile fileTree(dir: 'D:/[DATA]/[DEV]/libs/red-triplane/examples', include: '*.jar')
compile fileTree(dir: 'D:/[DATA]/[DEV]/libs/apache-commons', include: '*.jar')
compile fileTree(dir: 'D:/[DATA]/[DEV]/libs/spine', include: '*.jar')
in each of these sections: html and desktop
- Then I clicked Gradle->Refresh All and it removed all the red flags from the (1). Also it added my jars into the Gradle Dependencies section of the gradle-produced projects build pathes.
Now it all perfectly works for the Desktop gradle-produced backend.
However it doesn’t work for the HTML backend. Still the same problems as described above.
Assuming I need source code of the jar to compile the GWT. (Not sure that is correct assumption)
I did the following:
-
I unpacked the first jar apache-commons-io.jar into the newly created eclipse project. Now I have the jar’s source code.
-
I created ApacheCommonsIO.gwt.xml and placed it near the GdxDefinition.gwt.xml and GdxDefinitionSuperdev.gwt.xml files:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<source path="/org/apache/commons/codec" />
</module>
- Then I add the following line: into the GdxDefinition.gwt.xml and GdxDefinitionSuperdev.gwt.xml
so it looks like
<module rename-to="html">
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
<inherits name='com.badlogic.gdx.physics.box2d.box2d-gwt' />
<inherits name='com.jfixby.redtriplane.fokker.gradle.GdxDefinition' />
...
<inherits name='com.jfixby.redtriplane.fokker.gradle.ApacheCommonsIO' />
...
</module>
- Then I edited ApacheCommonsIO.gwt.xml and explicitly wrote the source folder location:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<source path="D:/[DATA]/[DEV]/commons-io-2.4/src/org/apache/commons/io" />
</module>
I did the same steps for all other JARs. It passed successfully compiling all steps until reaching the same result “The import cannot be resolved”.
I have no ideas what else I can do.
So… again: how to import external Eclipse projects/JARs into the GWT-HTML backend?