How to organize GWT project with multiple modules and shared server? - gwt

I have three GWT modules that will have some code in common - typically domain classes - and also share the same server instance. My first thought was to organize it like this:
app1/client/
app2/client/
app3/client/
server/
shared/
The modules would then have in their descriptors:
<source path = "client"/>
<source path = "../shared"/>
But it seems like that the ../shared path is not working.
Is this the way to go, or are there better ways?

I found at least on solution that works: Have all the modules in the same package, like this:
client/app1/App1.java
client/app2/App2.java
client/app3/App3.java
app1.gwt.xml
app2.gwt.xml
app3.gwt.xml
server/
shared/
I still kept subpackages app1, app2 and app3, but that's off course optional.
With this organization the module descriptors should say:
<source path = "client"/>
<source path = "shared"/>

Related

GWT module xml source element to specify single class

I have a GWT application (FooGwtApp) and a library module (FooLib) used as a dependency in FooGwtApp. The package structure of FooLib looks like this:
packageFoo.ImportantClass
packageFoo.UnimportantClass
packageBar.OtherClass
I want ImportantClass (and only ImportantClass) to be compiled to JS by the GWT compiler. Moving ImportantClass to another package is not an option.
I created ImportantClass.gwt.xml within packageFoo with the following content:
<module>
<inherits name="com.google.gwt.user.User"/>
<source path="" includes="**/ImportantClass*"/>
</module>
Next I put an inherited reference to the ImportantClass module definition in FooGwtApp.gwt.xml (this seems to work: the IDE recognizes it, and is able to parse the reference to ImportantClass.gwt.xml).
Now If I put references to ImportantClass into FooGwtApp's client code, the GWT compiler fails, because it does not find ImportantClass on the source path:
No source code is available for type packageFoo.ImportantClass; did you forget to inherit a required module?
I likely messed up sommething in the source path / includes attribute in ImportantClass.gwt.xml - either defining the current package as root package with path="" is not a valid notation or something's wrong with the includes attribute. Or both. Or neither.
Can you give me a clue about where it all went wrong?
It turns out the problem was not in ImportantClass.gwt.xml, but in other Maven related stuff:
ImportantClass.gwt.xml should be placed under src/main/resources/packageFoo, not src/main/java/packageFoo, otherwise it won't be packaged into the binary jar.
GWT compiler compiles from Java source to Javascript source. This means we don't just need ImportantClass.class in FooLib.jar, but also its source. Best solution for this is to use maven-source-plugin in FooLib's pom.xml and also to import the FooLib dependency into FooGwtApp with sources classifier.
On the latter topic, see the following SO answers:
Maven: Distribute source code with with jar-with-dependencies
How to properly include Java sources in Maven?
After fixing the above problems, the source path declaration present in the question works.

Setting module name to be different from directory name in SwiftPM

I have a Swift library with a core module plus optional bonus modules. I would like to use the following directory layout, mapping to exported Swift package names as shown:
Taco/
Source/
Core/ → import Taco
Toppings/ → import TacoToppings
SideDishes/ → import TacoSideDishes
To my eyes, that’s a sensible-looking project layout. However, if I’m reading the docs right, this will pollute the global module namespace with unhelpful names like “Core”. It seems that SwiftPM will only export a module whose name is identical to the directory name, and thus I have to do this:
Taco/
Source/
Taco/
TacoToppings/
TacoSideDishes/
Is there a way to configure Package.swift to use the tidier directory layout above and still export the desired module names?
Alternatively, is it possible to make the Core, Toppings, and SideDishes modules internal to the project, and export them all to the world as one big Taco module?
There is not currently a clean way to do this, but it seems like a reasonable request. I recommend filing an enhancement request at http://bugs.swift.org for it.
There is one "hacky" way you can do this:
Create your sources in the desired internal layout:
Sources/Core
Sources/Toppings
Add additional symbolic links for the desired module names:
ln -s Core Sources/Taco
ln -s Toppings Sources/TacoToppings
Add an exclude directive to the manifest to ignore the non-desired module name:
let package = Package(
name: "Taco",
exclude: ["Sources/Core", "Sources/Toppings"]
)
is it possible to make the Core, Toppings, and SideDishes modules internal to the project, and export them all to the world as one big Taco module?
No, unfortunately there is no way to do this currently, and it requires substantial compiler work to be able to support.

Play change default packaging system

I am on play 2.5.2
I know that the default packaging system do expect something like :
app/
controllers/
models/
views/
But I would like it to be :
app/
foo/
controllers/
models/
views/
How can I achieve this ?
Over there : https://www.playframework.com/documentation/2.5.x/Anatomy
They do say that :
Note that in Play, the controllers, models and views package name conventions are now just that and can be changed if needed (such as prefixing everything with com.yourcompany).
But that doesn't tell me how.
Thanks
You can just place your controllers, models and views in the desired package. No additional configuration is needed. When writing your routes file you will have to prefix the entries with the package though. So instead of writing
/foo controllers.FooController.bar()
You'll have to write:
/foo foo.controller.FooController.bar()

What is the physical path of Odoo webserver?

I'm building a custom odoo module that will be using several Javascript libraries.
I need to add references to those libraries (local references) but I don't know exactly where to place those libraries and how to refer to their location.
What I tried:
- I created the new module and placed the libraries inside the module directory but it didn't work.
- I also placed the libraries in the home directory of odoo.
As I understand, the problem would be solved if I could get the default directory of the webserver that odoo runs on.
If module is using js files, then you must put these files inside your module. And still if you cant reach these files from your module its your technical error and you have to fix it yourself, also note that odoo has its js libraries already
I found this page: how to add css and js files in Openerp 7 / Odoo module maybe can help you.
Below is the content.
Store files correctly:
CSS and JS files should be reside under 'static' directory in the module(the rest of subdirectory tree under 'static' is an optional convention):
static/src/css/your_file.css
static/src/js/your_file.js
Add files in manifest (v7.0) or in XML(v8.0)
Openerp v7.0 way is to add following entries in manifest (in openerp.py):
...
'css': ['static/src/css/your_file.css'],
'js': [static/src/js/your_file.js'],
...
Odoo v8.0 way is to add corresponding record in the XML:
Add XML to the manifest (openerp.py):
...
'data': [ 'your_file.xml'],
...
Then add following record in 'your_file.xml':
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/>
<script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script>
</xpath>
</template>
....
....
</data>

Defining modules in GWT with non-default source directories

Let's say that I want to define a module "Pair" in com.mycompany.common such that the source is located in com.mycompany.common (and not com.mycompany.common.client). How would I do this? Alternatively, let's say that I have the flexibility of defining the module "Pair" in com.mycompany instead while still having the source in com.mycompany.common.
Thanks to a quick search on google, I found the answer myself. One can add a source path tag to the module xml file to define the source directory instead of leaving it to the default "client." For example, Pair.gwt.xml would look something like this:
<module>
...
<source path="."/>
...
</module>
... if we wanted the gwt.xml file to be in the same directory as the source.
But when compiling this module, we get a "Non-canonical source package: ./" warning. Is this ok to ignore?