java2typescript icon indicating copy to clipboard operation
java2typescript copied to clipboard

How to migrate a GWT project?

Open x2nie opened this issue 1 year ago • 1 comments

Hi Mr. Mike,

I need your advice. I am migrating a project that uses GWT (com.google.gwt). that is actually will running in browser, so the code are a lot of DOM (web-browser) objects involved; that is what GWT supposed to be.

My later migrated code (typescript fles) wouldn't need to be compatible with java any more. I mean will be purely in typescript for running in FireFox/Chrome. I am sure with this path, because I've downloaded the running html page somewhere, and play with them locally (without java webserver) and that is worked as identical as the online version. I mean the generated JS by compiling GWT is standalone, no need to fetching data from the webserver.

Okay. My plan was to migrate java file one by one, because I need to modify GWT's object/property line by line. Well, I think that is worse, since there are huge files needed to be inspected.

So, in case you know a better approach, that would be great to know. ?

here is the repo I am migrating with: https://github.com/x2nie/circuitts2-migration-java2ts/tree/master/src/com/lushprojects/circuitjs1/client and here is the option I am using so far:

    "sourceReplace": {
        "(native)": "/*-na-ti-ve-*/"
    },
    "targetReplace": {
        "java\\.lang\\.Enum": "Enum",
        "java\\.lang\\.String": "string",
        "\\/\\*-\\{": "{",
        "\\}-\\*\\/": "}"
    },
    "options": {
        "addNullUnionType": false
    }

x2nie avatar Aug 16 '24 19:08 x2nie

In such cases I either first translate the 3rd party lib (using java2ts) or, if that's too large, manually create a symbol table with the APIs needed by the main code. This is what I did for Java where I load the symbol table data from JSON files I extracted from the official documentation. With that you can mostly keep the original API calls, but have to come up with an own implementation.

But keep in mind UI related stuff is the most difficult code to translate, as that very often contains platform specific code.

mike-lischke avatar Aug 17 '24 08:08 mike-lischke

oh? reasonable idea. I can follow that way. Thanks you !

x2nie avatar Sep 15 '24 03:09 x2nie