Adding Java packages to GWT

前端 未结 2 1061
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 11:30

I\'ve tried searching but couldn\'t come up with a defined way on how to add your own packages to a GWT project.

My tree structure looks like this:

-com.         


        
2条回答
  •  天涯浪人
    2021-02-08 12:23

    even though, as @rustyshelf pointed out, gwt will convert everything that is under client.* automatically, there will be times when you will want to keep things outside of your client packages (reusing them in several project might be one of them) and for that the solution still resides in adding other packages to the process using the source element.

    now there is a trick, you have to decide whether you want to move the gwt.xml config file or whether you need to create a new one.

    for your case in particular (where both packages share a root in the package, com.mycompany) you can just move the .gwt.xml file to the top most common package and just add the new package as a source (and keeping the there as well) thus making your file to look like:

    
    
    

    on the other hand if the packages don't share any root, just create a new *.gwt.xml file with only the source elements and place it on a parent package to the sub-package you want to add, i.e:

    
       
    
    

    note that if you need to give compilation-access to nested sub-packages do so by separating them with a / like in "admin/client"

    hope this help you get back on track and organize your code the best way possible.

提交回复
热议问题