Compile specific files only

79 views
Skip to first unread message

Ethan Hon

unread,
Jul 2, 2016, 8:23:28 AM7/2/16
to GWT Contributors
Hi guys,

Without any background, the question is how can I add a compiler option so that the source inside a module is compiled without resolving its dependency? For example, a module as simple as below

<module>
 
<inherits name="com.google.gwt.user.User" />
 
<source path="utils"/>
</module>

Only the .java files inside utils folder are translated into javascript.

Background
I am working on supporting mock components for AppInventor's component development kit (aka CDK, link). Basically, I need to inject javascript representing a mock on-the-fly. But before injecting, I need to get hold of what to inject.

AppInventor and components
AppInventor is written with GWT enabling users to edit their apps on the web before running on android. What they edit on the web is actually mock components, mocking the genuine visible components (e.g. TextBox, Spinner, etc) on android. So the mocks are developed with GWT.

AppInventor and CDK
Before CDK, all components are developed by the team. CDK allows other developers to make and use components. This requires loading necessary code at runtime. Currently, only the code of the component on the android side can be done so but not the code for the mock. In other word, it now only supports components without a mock (aka non-visible components).

Goal
To support mocks, we need to know the part of the GWT code that is written by the author which will then be injected on-the-fly. So I need to only compile those specific files but not all files. That's why I post this question. And I want to make use of GWT's compiler for this purpose.

The info above may be over-simplified but it may take very long to explain every detail. Let's see if it's already enough.

Thank you very much. Any direction or advice would be appreciated. I am running out of solutions. Hope this is the right one.

Jens

unread,
Jul 2, 2016, 9:39:30 AM7/2/16
to GWT Contributors

Without any background, the question is how can I add a compiler option so that the source inside a module is compiled without resolving its dependency? For example, a module as simple as below

<module>
 
<inherits name="com.google.gwt.user.User" />
 
<source path="utils"/>
</module>

Only the .java files inside utils folder are translated into javascript.


Not sure if I understand you. If the code inside the utils folder references a GWT button then the code of the GWT button must be available somehow, otherwise your utils code simply won't work. Given that GWT requires whole world knowledge during compilation the GWT button code is pulled in from the inherited User module (or more specific the indirectly inherited UI module). If you are saying you want to link against some pre-existing GWT button code, then thats not possible and I would assume you would need to write a new compiler instead of just adding a compiler option.

From what I understand you want some plugin system for AppInventor to circumvent the mentioned "whole world knowledge" requirement of GWT. The usual way to solve this is to have AppInventor publish a JavaScript API using GWT JSNI or JsInterop and then let 3rd party developers write their component mocks against this stable JavaScript API. In general this would also allows 3rd party developers to use something different than GWT to build their component mocks. If done correctly the AppInventor app can then import these 3rd party component mocks at runtime by adding an additional <script> tag pointing to the 3rd party component.

-- J.

Ethan Hon

unread,
Jul 2, 2016, 4:03:36 PM7/2/16
to GWT Contributors


Without any background, the question is how can I add a compiler option so that the source inside a module is compiled without resolving its dependency? For example, a module as simple as below

<module>
 
<inherits name="com.google.gwt.user.User" />
 
<source path="utils"/>
</module>

Only the .java files inside utils folder are translated into javascript.


Not sure if I understand you. If the code inside the utils folder references a GWT button then the code of the GWT button must be available somehow, otherwise your utils code simply won't work. Given that GWT requires whole world knowledge during compilation the GWT button code is pulled in from the inherited User module (or more specific the indirectly inherited UI module). If you are saying you want to link against some pre-existing GWT button code, then thats not possible and I would assume you would need to write a new compiler instead of just adding a compiler option.

The code for GWT button (using your example) is already available on the web (AppInventor site) so that when the code inside utils is plugged in, the button should work. This is what I hope to achieve.

Ok so the compilation requires whole world knowledge. But can we somehow (e.g. as simply as adding a compilation option) restrict the output to just the javascript of utils? Then the permutations only store the code for utils only. I know time may be wasted but let's see if it's even possible.

 
From what I understand you want some plugin system for AppInventor to circumvent the mentioned "whole world knowledge" requirement of GWT. The usual way to solve this is to have AppInventor publish a JavaScript API using GWT JSNI or JsInterop and then let 3rd party developers write their component mocks against this stable JavaScript API. In general this would also allows 3rd party developers to use something different than GWT to build their component mocks. If done correctly the AppInventor app can then import these 3rd party component mocks at runtime by adding an additional <script> tag pointing to the 3rd party component.

Wow this is another way to do it. I will think about that.

Thank you very much. I now have a better understanding of how it works.
Reply all
Reply to author
Forward
0 new messages