In GWT 2.0 CssResource, how I can turn off obfuscation for all my css classes?
Asked Answered
S

4

22

I have a CssResource where I want to have some of the css classes "mapped" to methods:

@ClassName("top-table")
String topTable();

But I want to turn off the obfuscation GWT does (while developing at least, for better debugging in firebug, etc).

Is there an easy way to achieve this? I know I can use @external in my css file but then I have to define all my css classes like @external .c1, .c2, .c3, etc...

Something like @external .* would solve my problem but that doesn't seem to be available at least in gwt 2.0.x

My current solution is to use:

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

But that doesn't turn off the obfuscation, just makes it prettier :) I know obf is needed to avoid collisions but I don't have that in my case and would really like to turn off obfuscation

Sagacity answered 12/5, 2011 at 1:8 Comment(2)
Where exactly did you put that line <set-configuraion-property>?Cracker
This should be reopened as the linked q&a was created after my initial question and my question contains more and better answers... Doesn't make sense to close the older question as duplicate....Sagacity
D
2

According to the GWT documentation it is possible to disable ofbuscation in general. From CssResource section "levers and knobs":

The configuration property CssResource.style may be set to pretty which will disable class-name obfuscation as well as pretty-print the CSS content. Combine this with a ClientBundle.enableInlining value of false to produce a CSS expression which is amenable to client-side editing.

In my work GWT project, I can see this property is actually set in Resources.gwt.xml (included in gwt-user.jar):

  <!-- This can be used to make CssResource produce human-readable CSS -->
  <define-configuration-property name="CssResource.style" is-multi-valued="false" />
  <set-configuration-property name="CssResource.style" value="obf" />

What is unclear to me is how to override this value, since it is already set. Did you manage to figure that out?

Doityourself answered 20/9, 2011 at 9:11 Comment(0)
S
6

To disable obfuscation for all of you legacy classes at once, you can exploit what is said here

In short, in the legacy css file, which you are binding using CssResource bundle, put this declaration: @external .*;

All the classes in the file that has this declaration file will not be obfuscated.

Shig answered 15/10, 2013 at 12:15 Comment(0)
D
2

According to the GWT documentation it is possible to disable ofbuscation in general. From CssResource section "levers and knobs":

The configuration property CssResource.style may be set to pretty which will disable class-name obfuscation as well as pretty-print the CSS content. Combine this with a ClientBundle.enableInlining value of false to produce a CSS expression which is amenable to client-side editing.

In my work GWT project, I can see this property is actually set in Resources.gwt.xml (included in gwt-user.jar):

  <!-- This can be used to make CssResource produce human-readable CSS -->
  <define-configuration-property name="CssResource.style" is-multi-valued="false" />
  <set-configuration-property name="CssResource.style" value="obf" />

What is unclear to me is how to override this value, since it is already set. Did you manage to figure that out?

Doityourself answered 20/9, 2011 at 9:11 Comment(0)
W
2

To have not obfuscated class names you simply need to add following line to your gwt.xml file:

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

When set to stable class names will consist of qualified class name followed by method name in your resource interfaces (of course with all . replaced by _)

All possible values for CssResource.style (for gwt 2.7) are:

  • pretty
  • debug
  • stable
  • stable-shorttype
  • stable-notype

To verify values available for your gwt version look at com.google.gwt.resources.rg.CssObfuscationStyle javadoc (or source code) for gwt version you're using.

Wiser answered 30/3, 2016 at 4:55 Comment(0)
T
1

You can use the @external directive to prevent a css classname from being obfuscated.

In your case, your css file might contain

@external top-table;
.top-table {
  some: rule;
}
Tufted answered 14/5, 2011 at 2:15 Comment(1)
"Is there an easy way to achieve this? I know I can use @external in my css file but then I have to define all my css classes like @external .c1, .c2, .c3, etc..." Doing that for all classes is too time-consuming :(Sagacity

© 2022 - 2024 — McMap. All rights reserved.