Search code examples
javagwtintellij-ideamaven-2gwt-gin

Not able to get reference to class file generated in "target" folder of Maven project in GWT


I am using Google Gin for generating an Event in my GWT project like this:

package com.lokur.motd.client.events;

import com.gwtplatform.dispatch.annotation.GenEvent;

@GenEvent
public class EditorChange {
}

Now, when I compile my project with "mvn clean install -e", it generates required classes viz. EditorChangeEvent.class, EditorChangeEvent$EditorChangeHandler.class, EditorChangeEvent$HasEditorChangeHandlers.class in the target folder of my project.

But, when I try accessing particular generated class e.g. EditorChangeEvent in my project, it gives me compilation error with message:

"package com.lokur.motd.client.events.EditorChangeEvent does not exist"

...

I don't understand this behavior. Do we need to explicitly add "target" folder of Maven in class-path or somewhere in the pom.xml or something else is causing this?

Here are the plug-ins from maven pom.xml:

<plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <version>${gwt.plugin.version}</version>
                        <configuration>
                            <runTarget>myMessage/myMessage.html</runTarget>
                            <disableCastChecking>true</disableCastChecking>
                            <disableClassMetadata>true</disableClassMetadata>
                            <!-- <logLevel>INFO" -bindAddress 0.0.0.0 -logLevel "INFO</logLevel> -->
                            <logLevel>ERROR</logLevel>
                            <style>OBF</style>
                            <!-- OBF, PRETTY, DETAILED -->
                            <noServer>false</noServer>
                            <additionalPageParameters>log_level=OFF</additionalPageParameters>
                            <extraJvmArgs>-Xmx512m -Ddev.mode=true -DuseCache=false</extraJvmArgs>
                            <extraTestArgs>-Xmx512m -Ddev.mode=true</extraTestArgs>
                            <gwtVersion>${gwtVersion}</gwtVersion>
                            <testFilter>*</testFilter>
                            <hostedWebapp>
                                ${project.build.directory}/${project.build.finalName}
                            </hostedWebapp>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>compile</goal>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>Unzip usp Config &amp; Env Modules</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.dig.configs</groupId>
                                            <artifactId>common-configs</artifactId>
                                            <version>${commonConfigs.version}</version>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${basedir}/target/tmp</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>${pom.groupId}</groupId>
                                            <artifactId>usp-env</artifactId>
                                            <version>${pom.version}</version>
                                            <type>zip</type>
                                            <outputDirectory>${basedir}/target/tmp</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>Copy Config, Env Modules</id>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <tasks>
                                        <copy todir="${basedir}/target/myMessage/WEB-INF/classes/config" overwrite="true" verbose="true" failonerror="true">
                                            <fileset dir="${basedir}/target/tmp/config">
                                                <include name="**" />
                                            </fileset>
                                            <fileset dir="${basedir}/target/tmp/env">
                                                <include name="**" />
                                            </fileset>
                                        </copy>
                                        <copy todir="${basedir}/target/myMessage/WEB-INF/classes/config" overwrite="true" verbose="true" failonerror="true">
                                            <fileset dir="../config/test" includes="**" />
                                        </copy>
                                        <copy file="${basedir}/../config/usp-app-config.xml" todir="${basedir}/target/myMessage/WEB-INF/classes/config" />
                                        <copy file="${basedir}/../usp-env/src/test/env/usp-app-config.properties" todir="${basedir}/target/myMessage/WEB-INF/classes" />
                                        <copy file="${basedir}/../usp-env/src/test/env/app-config.properties" todir="${basedir}/target/myMessage/WEB-INF/classes" />
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>

Solution

  • The issue was with the version of GWT supported by our project. It did not support @GenEvent as the project was not configured to use Gin. So, created Event and Handler classses manually instead of relying on Gin's annotations. Now, it works well. Closing this thread. Thank you all.