Ludii Forum
Jar of intelliJ IDEA : bug ? - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: Jar of intelliJ IDEA : bug ? (/showthread.php?tid=22)



Jar of intelliJ IDEA : bug ? - Quentin Cohen-Solal - 01-29-2020

Following the tutorial "https://github.com/Ludeme/LudiiExampleAI" by using the java editor intelliJ IDEA does not work. Once the jar has been selected in ludii, it does not offer to choose the class. 

With the same code and eclipse, there is no problem.


RE: Jar of intelliJ IDEA : bug ? - DennisSoemers - 01-29-2020

Could you elaborate which part exactly does not work? So you can still use Ludii.jar as a dependency, write and compile your custom AI, and export it to a JAR? But only then the JAR exported from IntelliJ cannot be read correctly by the Ludii app? Or does it already fail at some earlier stage?


RE: Jar of intelliJ IDEA : bug ? - Quentin Cohen-Solal - 01-30-2020

(01-29-2020, 07:51 PM)DennisSoemers Wrote: Could you elaborate which part exactly does not work? So you can still use Ludii.jar as a dependency, write and compile your custom AI, and export it to a JAR? But only then the JAR exported from IntelliJ cannot be read correctly by the Ludii app? Or does it already fail at some earlier stage?

From what I could test, the problem comes either from the manner in which intelliJ IDEA compiles the code or creates the jar (with intellij IDEA the jar are called artifact: there is perhaps something special in their creation of jar).

For example, creating a new project and adding the sources of https://github.com/Ludeme/LudiiExampleAI and adding in library ludii.jar then exporting and finally loading it into ludii does not give the choice of the IA class.

There does not seem to be any problems before being opened by the Ludii app (a class using the library can be launched by an executable jar from intelliJ IDEA).


RE: Jar of intelliJ IDEA : bug ? - DennisSoemers - 03-06-2020

Sorry for the long delay. I just finally got around to testing it, and it does seem to work correctly on my end (using the 0.6 version of Ludii, and the matching version of the LudiiExampleAI repo, as they are currently available).

In the Project Structure > Modules setting of IntelliJ, where I added the Ludii.jar file as a dependency, I unticked the "Export" checkbox, and I set the Scope of the dependency to "Provided". I'm not sure if both of these are required, or just one... I'm not really an IntelliJ expert. Anyway, I took these steps because I wanted to ensure that the built JAR file would only include classes from the LudiiExampleAI repo, and would not include any of the classes from Ludii itself. These steps seemed to accomplish this, but I suppose the same is possible by directly tweaking things in the Project Structure > Artifacts menu. The Output Layout should really just contain the 'LudiiExampleAI' compile output (plus any non-Ludii dependencies that your custom AIs may have).

A JAR file built in this way (it should be a really small one, just 16kB here for the current LudiiExampleAI code) works just fine.

If I launch Ludii.jar, and then try to load the same Ludii.jar file itself again as a provider of third-party AIs, this does indeed cause some errors. So the same probably happens if you directly include all of the Ludii.jar contents in the new JAR you build. I'll see if this can be fixed for the next version...


RE: Jar of intelliJ IDEA : bug ? - Quentin Cohen-Solal - 03-07-2020

I had to create a new project from existing sources in addition to these modifications to make it work.

Thank you so much.