简体   繁体   English

使用模块源路径使用 GWT 仅将 java 类的一部分编译为 java 脚本

[英]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.伙计们,我正在尝试过滤掉一些 java 文件以不编译为 java 脚本。 I cant make it work.我不能让它工作。 I've check documentation here: https://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml我在这里查看了文档: 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. <source path="_path_" /> :标签的每次出现都会通过将 package 组合到源路径中添加一个 package ,其中模块 Z3501BB093D363810B671059B9CFED3F 与指定的路径找到一个子包。 Any Java source file appearing in this subpackage or any of its subpackages is assumed to be translatable.假定出现在此子包或其任何子包中的任何 Java 源文件都是可翻译的。 The element supports pattern-based filtering to allow fine-grained control over which resources get copied into the output directory during a GWT compile.该元素支持基于模式的过滤,以允许在 GWT 编译期间对将哪些资源复制到 output 目录中进行细粒度控制。 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.如果在模块 XML 文件中未定义任何元素,则客户端子包将隐式添加到源路径,就像在 XML 中找到一样。 This default helps keep module XML compact for standard project layouts.此默认设置有助于保持模块 XML 紧凑,用于标准项目布局。

but still no success.但仍然没有成功。

My module file: model.gwt.xml我的模块文件:model.gwt.xml

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

with content:内容:

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

takes all java files from package: com.company.section.app.model从 package 获取所有 java 文件: com.company.section.app.model

And I would like to compile only few of them, from fe: package com.company.section.app.model.to.javascript And I would like to compile only few of them, from fe: 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, fe:但是我遇到了错误,fe:

[INFO] [ERROR] Line 69: No source code is available for type com.company.section.app.model.to.javascript.DeviceDTO; [信息] [错误] 第 69 行:没有源代码可用于类型 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?我想念一些 * asterix 吗? I just dont get it.我只是不明白。 Documentation stands that I should add part of package to path, or I miss understood.文档表明我应该将 package 的一部分添加到路径中,否则我错过了理解。 Please help.请帮忙。

I hope I did explain it well enough.我希望我确实解释得足够好。

I found solution, or my mistake.我找到了解决方案,或者我的错误。 In xml module file we need to put path, and not package, like I was doing, so replacing:在 xml 模块文件中,我们需要放置路径,而不是 package,就像我在做的那样,所以替换:

<source path="to.javascript">

with

<source path="to/javascript">

Do the job做好工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM