Search code examples
modulegwt

Compiling only part of java classess to java script with GWT using module source path


Guys I am trying to filter out some java files to not be compiled to java script. I cant make it work. I've check documentation here: https://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml

<source path="_path_" /> : Each occurrence of the tag adds a package to the source path by combining the package in which the module XML is found with the specified path to a subpackage. Any Java source file appearing in this subpackage or any of its subpackages is assumed to be translatable. The element supports pattern-based filtering to allow fine-grained control over which resources get copied into the output directory during a GWT compile. If no element is defined in a module XML file, the client subpackage is implicitly added to the source path as if had been found in the XML. This default helps keep module XML compact for standard project layouts.

but still no success.

My module file: model.gwt.xml

located in: com.company.section.app.model

with content:

<module>
    <source path="">
    </source>
</module>

takes all java files from package: com.company.section.app.model

And I would like to compile only few of them, from f.e.: package com.company.section.app.model.to.javascript

So I do change my module file content into:

<module>
    <source path="to.javascript">
    </source>
</module>

But I am getting errors, f.e.:

[INFO] [ERROR] Line 69: No source code is available for type com.company.section.app.model.to.javascript.DeviceDTO; did you forget to inherit a required module?

I've tried already many combinations like:

    <source path="com.company.section.app.model.to.javascript.*">
    <source path="to.javascript.*">
    <source path=".to.javascript.*">

Some times I am getting error:

[INFO] #
[INFO] # A fatal error has been detected by the Java Runtime Environment:
[INFO] #
[INFO] #  SIGSEGV (0xb) at pc=0x00007f09897b3986, pid=1626892, tid=1626899
[INFO] #
[INFO] # JRE version: OpenJDK Runtime Environment (17.0.1+12) (build 17.0.1+12-Ubuntu-121.04)
[INFO] # Java VM: OpenJDK 64-Bit Server VM (17.0.1+12-Ubuntu-121.04, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
[INFO] # Problematic frame:
[INFO] # V  [libjvm.so+0x6db986]
[INFO] #

I added source plugin to the project I wanna import (model)

        <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I also add source dependency to project

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>shared</artifactId>
            <version>${project.version}</version>
            <classifier>sources</classifier>
        </dependency>

I can't find any good example of such usage. Do I miss some * asterix? I just dont get it. Documentation stands that I should add part of package to path, or I miss understood. Please help.

I hope I did explain it well enough.


Solution

  • I found solution, or my mistake. In xml module file we need to put path, and not package, like I was doing, so replacing:

    <source path="to.javascript">
    

    with

    <source path="to/javascript">
    

    Do the job