Disable/Enable CSS obfuscating in gwt.xml ?

2,547 views
Skip to first unread message

Ed

unread,
May 27, 2010, 3:01:35 PM5/27/10
to Google Web Toolkit
How is it possible to disable/enable CSS obfuscating in the gwt.xml
file ?

This should be very handy as I have many css styles that aren't
allowed to be obfuscated during testing as they are used by Selenium.
At the moment I disable obfuscating with the annotation @external, but
that is fixed. I would love if this would be adjustable in the gwt.xml
file.

Chris Lercher

unread,
May 28, 2010, 9:29:33 AM5/28/10
to Google Web Toolkit
It can be done:

com.gwt.resources.Resources.gwt.xml defines the "CssResource.style"
property. Looking into
com.google.gwt.resources.rg.CssResourceGenerator.init() shows, that we
can set the property to "pretty" - so in your .gwt.xml file you would
write:

<set-configuration-property name="CssResource.style" value="pretty"/>

The resulting name is still complex (because it has to be unique
across multiple CSS resources), but at least it contains the original
class name at the end of the name - I'm not sure, if you can use this
in your situation?

Chris

Thomas Broyer

unread,
May 28, 2010, 9:43:30 AM5/28/10
to Google Web Toolkit


On May 28, 3:29 pm, Chris Lercher <cl_for_mail...@gmx.net> wrote:
> It can be done:
>
> com.gwt.resources.Resources.gwt.xml defines the "CssResource.style"
> property. Looking into
> com.google.gwt.resources.rg.CssResourceGenerator.init() shows, that we
> can set the property to "pretty" - so in your .gwt.xml file you would
> write:
>
> <set-configuration-property name="CssResource.style" value="pretty"/>

Note that you didn't have to digg into the code, this is a documented
switch:
http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Levers_and_Knobs

> The resulting name is still complex (because it has to be unique
> across multiple CSS resources), but at least it contains the original
> class name at the end of the name - I'm not sure, if you can use this
> in your situation?

See http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Selector_obfuscation
Though I don't know what it exactly does to change the
obfuscationPrefix.

Ed Bras

unread,
May 28, 2010, 11:35:07 AM5/28/10
to google-we...@googlegroups.com
Hi,

That sounds nice, I shall have a closer look at it.
It should be nice if it could be more fine-grained, as it normally concern a few styles that should be annotated with @external for testing.

Ed



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


karthik reddy

unread,
Jun 25, 2011, 9:36:32 PM6/25/11
to google-we...@googlegroups.com
Not to revive a old thread but wanted to add some relevant info to the discussion. In the case of <set-configuration-property name="CssResource.style" value="pretty"/>,   the code that generates the aforementioned  very  long class names is present in the 
computeObfuscatedNames  method of com.google.gwt.resources.rg.CssResourceGenerator  class:

   if (prettyOutput) {
          obfuscatedClassName += "-"
              + type.getQualifiedSourceName().replaceAll("[.$]", "-") + "-"
              + name;
        }

Retaining the original class names is a very useful tool while development. (obfuscation is ideal for only production)
Unfortunately, you can not override the above method which means we are stuck with these long names. I wish there was a way to have GWT just retain the class names as they are.  (using @external for each and every class is cumbersome and cant be used for styles within widgets)

Ed

unread,
Jun 26, 2011, 4:38:16 AM6/26/11
to google-we...@googlegroups.com
This sounds like a feature request.
You might consider posting this as a feature request in the issue tracker.

Chris Lercher

unread,
Jul 4, 2011, 11:28:22 AM7/4/11
to google-we...@googlegroups.com
@karthik: The problem is, that in general you can't simply retain the original names. A very important (probably the most important) feature of CssResources is, that each of them effectively gets its own namespace. If you remove that concept (even just for testing), you will create conflicts, if the same style class name is used in different CssResources.

If you don't care about that feature, then it's probably best, if you actually use @external on all your style classes, or if you put everything in external CSS files.
Reply all
Reply to author
Forward
0 new messages