As soon as you start having hierarchical java models things start getting tricky.

Example: You have a base module defining some base classes (in the example below these are all in the package "de.cware.cweb.services.event.event"). Now in a second module you want to provide specializations of these classes by extending them.

The problem you will be having now is, that GraniteDS will extend your ActionScript classes form other classes if these are part of the current generation run. In this case UserLoggedinEvent extends DestinationEvent on the java side and we want to generate the ActionScript counterpart to UserLoggedinEvent. If we don't add DestinationEvent to the generation, the resulting class will not extend DestinationEvent, if we do add it the linker will complain about multiple definitions of the DestinationEvent class.

The solution for this problem that seems to be working nicely, is to simply add the other classes to the generation, but exclude them from the compilation using Flexmojos "includeClasses" directive on the compile goal (Ok ... it sounds strange to exclude by including, but think of it this way ... by setting "includeClasses" you override the default to add all/all referenced classes with all-exept-some)

Here comes a working configuration for this problem:

<plugin>
    <groupId>net.flexmojos.oss</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <includeJavaClasses>
                    <class>de.cware.cweb.services.onlineUsers.event.UserLoggedinEvent</class>
                    <class>de.cware.cweb.services.onlineUsers.event.UserLoggedoutEvent</class>
                    <!-- Needed for granite to generate the corresponding "extends" attributes -->
                    <class>de.cware.cweb.services.event.event.DestinationEvent</class>
                    <class>de.cware.cweb.services.event.event.PrivateDestinationEvent</class>
                    <class>de.cware.cweb.services.event.event.BaseDestinationEvent</class>
                    <class>de.cware.cweb.services.event.event.BasePrivateDestinationEvent</class>
                </includeJavaClasses>
                <templates>
                    <enum-template>class:de/cware/cweb/comm/blazeds/templates/enum.gsp</enum-template>
                    <base-entity-template>class:de/cware/cweb/comm/blazeds/templates/beanBase.gsp</base-entity-template>
                    <entity-template>class:de/cware/cweb/comm/blazeds/templates/bean.gsp</entity-template>
                    <base-bean-template>class:de/cware/cweb/comm/blazeds/templates/beanBase.gsp</base-bean-template>
                    <bean-template>class:de/cware/cweb/comm/blazeds/templates/bean.gsp</bean-template>
                    <interface-template>class:de/cware/cweb/comm/blazeds/templates/interface.gsp</interface-template>
                    <remote-template>class:de/cware/cweb/comm/blazeds/templates/remote.gsp</remote-template>
                    <base-remote-template>class:de/cware/cweb/comm/blazeds/templates/remoteBase.gsp</base-remote-template>
                </templates>
            </configuration>
        </execution>
        <execution>
            <id>default-compile-swc</id>
            <goals>
                <goal>compile-swc</goal>
            </goals>
            <configuration>
                <includeClasses>
                    <scan>
                        <excludes>
                            <exclude>de.cware.cweb.services.event.event.*</exclude>
                        </excludes>
                    </scan>
                </includeClasses>
            </configuration>
        </execution>
    </executions>

    <dependencies>
        <dependency>
            <groupId>de.cware.cweb</groupId>
            <artifactId>cweb-comm.blazeds.lib-non-bindable-legacy-collection-model-templates</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>
  • No labels