Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The annotation is called <code>@external</code> for a reason :) It's for external classes, whose names we can't control - this fits your situation. It so happens that your external project is also a GWT one, but that doesn't matter - unless you compile both projects at the same time, I don't see any (easy and non-hackish) way of (automagically) linking the obfuscated class name from LibraryBundle to DepProjectBundle.</p> <p><code>&lt;tech (?) rant&gt;</code><br> ClientBundle does all it's work at compile time - it knows everything about the CSS at that point and, for example, can create non-clashing class names for all the class names included in UiBinder templates (the <code>&lt;ui:style&gt;</code> elements are converted to <code>CssResource</code>s at compile time). So, you can have a CSS class named <code>.warning</code> in your <code>WidgetA</code>'a UiBinder template and a different <code>.warning</code> class in <code>WidgetB</code>'a UiBinder template. During compilation, they will get assigned different obfuscated names (since they <em>are</em> different classes). Now, let's move to your situation: you compile LibraryBundle and then you compile (independently) DepProjectBundle - it is possible (the shorter the obfuscation prefix, the more likely, and you should override the default long GWT prefix BTW) that in both projects you'll get the same named CSS classes (which of course will most likely have different purposes). So if you were to include blindly a class from LibraryBundle into DepProjectBundle, you might (at some point) introduce a name clash.<br> <code>&lt;/tech (?) rant&gt;</code></p> <p>If you really want to avoid <code>@external</code> (which is a good idea, I'll admit :)), I'd suggest the following: include your LibraryBundle into your project as a <a href="http://svnbook.red-bean.com/en/1.5/svn.advanced.externals.html" rel="nofollow noreferrer"><code>svn:externals</code></a> (you <em>are</em> using a SCM, right?) or a symlink or any other means available in your SCM or filesystem - basically, you'll be seamlessly able to share the same code of LibraryBundle amongst many projects (which I presume is the goal here), while having compile-time support from the GWT compiler.</p> <hr> <h3>Update in response to Steve's comments:</h3> <p>It seems I have misunderstood your project structure from your initial question - I was under the impression that you wanted to link to the compiled output of the LibraryBundle... But since you are working with the source (via Maven, nice :)), then my <code>svn:externals</code> idea is not needed (BTW, you can put any repository path in the <code>svn:externals</code> property, including your trunk branch).<br> Anyway, I was under the impression that one could easily combine two <code>CssResource</code>s into one but alas... <s>This is what I've tried so far, all failed, but maybe something from this list will spark some brilliant idea in someone ;) (cue a long list here...)</s> Scratch that, in the process of summing up my failures I came up with the answer :)</p> <h2>And the answer is:</h2> <p>The <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/resources/client/CssResource.Import.html" rel="nofollow noreferrer"><code>@Import</code></a> annotation (in combination with <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/resources/client/CssResource.ImportedWithPrefix.html" rel="nofollow noreferrer"><code>@ImportedWithPrefix</code></a> for a more meaningful prefix). Your <code>ProjectBundle</code> would look like this: </p> <pre><code>public interface DepProjectBundle extends ClientBundle { public static final DepProjectBundle INSTANCE = GWT.create(DepProjectBundle.class); // Need this to reference the class names // But maybe we can use the one in LibraryBundle? // Have fun testing that :) For simplicty, I'll leave it here Library library(); // The good stuff @Import({Library.class}) Main main(); } </code></pre> <p><code>Library</code> is a <code>CssResource</code> from your <code>LibraryBundle</code> (or maybe it can be the whole <code>LibraryBundle</code>? Haven't tried that). The important stuff is the <code>@Import</code> annotation (normal CSS <code>@import url(some.css)</code> doesn't work with <code>ClientBundle</code> - I've tried ;))<br> Now, you use this <code>DepProjectBundle</code> as such:</p> <pre><code>DepProjectBundle.INSTANCE.library().ensureInjected(); DepProjectBundle.INSTANCE.main().ensureInjected(); Label label = new Label("Test"); label.addStyleName(DepProjectBundle.INSTANCE.library().smallWindow()); VerticalPanel vPanel = new VerticalPanel(); vPanel.addStyleName(DepProjectBundle.INSTANCE.main().sectionA()); vPanel.add(label); RootPanel.get().add(vPanel); </code></pre> <p>Note that we are using the <code>DepProjectBundle.library()</code> CssResource to reference the names from the library.css "namespace".<br> <strong>One important change is needed however in main.css</strong> - in order to avoid name clashes, the compiler imports the class names with a prefix - it uses either the classes' name or the one provided via the <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/resources/client/CssResource.ImportedWithPrefix.html" rel="nofollow noreferrer"><code>@ImportedWithPrefix</code></a> annotation. So, your main.css will have to be changed to something like this (let's assume you used <code>library</code> as a prefix):</p> <pre><code>.sectionA .library-smallWindow { color: blue; } </code></pre> <p>Unfortunately, there's no way around this (that I've found :)). But it might be beneficial in the long run - in case you forgot which names you used in the library.css and which in main.css (which could lead to some strange CSS clashes) - this way you clearly define (in main.css) that this class name belongs to the library.css (it gets obfuscated in the end, so no additional bytes are wasted).</p> <p>Phew, hope this solution will be helpful to you (and others! :)) I'll leave my initial thoughts too, since someone else might not have been using (from the start :)) the source of the external ClientBundle, the <code>svn:externals</code> idea might be of use to someone not using tools like maven, etc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload