New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate kotlin source files instead of java when "Use Kotlin" selected in gdx-setup #4812

Open
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@haxpor
Copy link
Contributor

haxpor commented Jul 5, 2017

Most likely users want to work with pure Kotlin source files or as much as they can when they selected to use Kotlin for project in gdx-setup.

Notable changes are

  • Add kotlin template files for all launcher classes, and core's main class. These are for project generation to use.
  • Checking is based on Language for its JAVA and KOTLIN, and for HTML target, also check gwtSupported flag.
  • Change kotlin version to 1.1.3 instead of 1.1.1 as there should be no major reason to hang back and use older version of kotlin.

PS. Actually there's 1 single commit that relevant to this changes. But due to I update my forked repo to latest libgdx after my previous PR gets merged. Advice is welcome on how to squeeze it to only 1 commit before merging.

haxpor added some commits May 13, 2017

Better ignore un-needed files for iOS platform
In detail, inside .xcodeproj there are also unnecessary files which are
not needed to be included into git source tree. Those files include
local user's data (unique for each local user opening Xcode), but
particular folders are still need i.e. 'xcshareddata' (for shared scheme
in case for more complex build process of executing build command
against shared scheme for project from external tool), and of course
'project.pbxproj' project file itself.

Also ignored artifacts as they are built dynamically in native/ folder
of ios/xcode/ and ios-moe/xcode/. Each built file (.a) has a several MBs in
size, and would be much better to exclude it. In tested, for project
that includes only Box2d, native/ directory alone would be ~13MB in
size. This will make git user smoothly and effectively clone the
project without much waiting, and also no need to put it back in as it's
ignored.
Add kotlin source for kotlin project instead of java source files in
gdx-setup

When users select to generate project with kotlin language, then most
likely those users want to completely work with kotlin. So generated
project should reflect this too, thus this changes offer that.

All launcher files are in .kt file now whenever "Use Kotlin" is selected in Advanced section of gdx-setup.

Also note about HTML platform target as the code check gwtSupported flag
of Language whether it supports or not, and it's not hard-coded. Thus it
offers flexibility for devs in the future to just change the flag when
gwt could build HTML target working with kotlin.
project.files.add(new ProjectFile("core/build.gradle"));
project.files.add(new ProjectFile("core/src/MainClass", "core/src/" + packageDir + "/" + mainClass + ".java", true));

if (language == Language.JAVA) {

This comment has been minimized.

@Tom-Ski

Tom-Ski Jul 5, 2017

Member

I'd rather abstract this out now, have Language define a folder path for the src template files, and pick them up automatically from there.

I propose moving template files that are language specific into a language parent folder, where we have each language provide its own folder containing its own language specific files.

This comment has been minimized.

@haxpor

haxpor Jul 5, 2017

Author Contributor

Ok, i'm done with abstracting resource out, and also fixed a problem regarding to running ios-moe in separate commit. Please check them out. Thanks!

haxpor added some commits Jul 5, 2017

Fix ios-moe of cannot find class in DexList
In main build.gradle, it needs to have the following line inside
"ios-moe" target as well.

apply plugin: "kotlin"

if it's not there, then an error of IOSMoeLauncher class cannot be found
in DexList when running the application will be shown.
Refactor specific resource for Java and Kotlin out
Specific resource used for either Java or Kotlin language is refactored
out in _specifics/ folder in which inside there are java/ and kotlin/
folder. Inside of each language folder, intended to keep the same
structure as of generated project, thus src/ is there that contain the
same name of launcher class files.

GdxSetup.java contains an additional of private method to return out
such resource path of src according to language, and project type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment