edibleday / teavm-gradle-plugin

Gradle plugin for compiling(transpiling) JVM bytecode to JavaScript using TeaVM
Apache License 2.0
17 stars 13 forks source link

How to use it with libgdx project? #3

Open haxpor opened 7 years ago

haxpor commented 7 years ago

Hi, could you guide me on how to use this with libgdx-based project?

As libgdx project might have several sub-module targeting different platform: desktop, android, ios-moe, etc. Should I put those build.gradle setting under desktop one?

The following is what I've tried.

  1. Put build.gradle setting at the top level.

Configured with mainClassName = "io.wasin.asteroids.desktop.DesktopLauncher". I got the following error after executing ./gradlew teavmc

haxpors-mbp:asteroids haxpor$ ./gradlew teavmc
Configuration on demand is an incubating feature.
Using already downloaded SDK: /Users/haxpor/.moe/moe-sdk-1.3.6
Changed strategy of configuration ':ios-moe:moeMavenSDK' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
Incremental java compilation is an incubating feature.
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:startScripts
:distTar
:distZip
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:teavmc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':teavmc'.
> Can't provide name for method as it was not found: io.wasin.asteroids.desktop.DesktopLauncher.main([Ljava/lang/String;)V

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 12.413 secs
  1. Put setting inside desktop.

With same mainClassName. I got the following error after executing ./gradlew desktop:teavmc.

haxpors-mbp:asteroids haxpor$ ./gradlew desktop:teavmc
Configuration on demand is an incubating feature.
Using already downloaded SDK: /Users/haxpor/.moe/moe-sdk-1.3.6
Changed strategy of configuration ':ios-moe:moeMavenSDK' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0

FAILURE: Build failed with an exception.

* Where:
Build file '/Volumes/Slave/Data/Projects/asteroids/desktop/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':desktop'.
> Cannot add task ':desktop:run' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.849 secs

Any suggestion on how to solve this?

konsoletyper commented 7 years ago

This Gradle plugin is unofficial, TeaVM does not provide Gradle support yet. I'm an author of TeaVM, but I'm not an author of this plugin, so I can't help you. You can ask me personally (info@teavm.org), or publish your question on forum.

Let my try to help with your problem. First, have you tried teavm-libgdx? It's outdated and no more maintained, but you can try to build it and learn it. It's in Maven, but it should not be a problem. I guess it's not that hard to invoke Maven from Gradle, right?

Execution failed for task ':teavmc'.
> Can't provide name for method as it was not found:
io.wasin.asteroids.desktop.DesktopLauncher.main([Ljava/lang/String;)V

Obviously, this means that there's no such class in your project ;-)

renatoathaydes commented 6 years ago

This plugin was incorrectly setting the classpath, that's why it was not finding the main class (it can't see it).

I fixed that in this PR: https://github.com/edibleday/teavm-gradle-plugin/pull/5

Hope that the maintainer @n3o59hf will respond (if you don't want to work on this project anymore, let me know and I can take over - I have quite some experience maintaining Gradle plugins, so I can do it for you).

sriharshachilakapati commented 6 years ago

@renatoathaydes I think you can publish it under your own maven group ID?

vic-cw commented 5 years ago

@renatoathaydes I suggest to redirect everyone to your fork, and make it the maintained version.

Thus I would approve @sriharshachilakapati's suggestion to publish it under your own maven group id.

vic-cw commented 5 years ago

@renatoathaydes do you mind enabling people to open issues on your fork?

renatoathaydes commented 5 years ago

@vic-cw done. I will try to find time to do this.

vic-cw commented 5 years ago

@renatoathaydes Awesome!!