Maven——添加源依赖;但 eclipse 中没有可用于 GWT 编译的 java 源文件
通常下面的 pom 配置对我有用。我过去曾成功地将 jar 文件的源代码作为依赖项添加到我的项目中?
我有两个这样定义的 jar 文件:
<dependencies>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
</dependencies>
当我从 Windows 资源管理器视图中打开 myJar-4.0-sources.jar 文件时,我会看到它关联的包中的所有 java 源文件。但是,当我在 Maven 依赖项中查看 Eclipse 项目时,我只看到 xml 文件,没有 myJar-4.0-sources.jar 的 java 文件,
顺便说一句,无论我在 Eclipse 内部还是外部运行 Maven 构建,它都会抱怨没有源代码应在 myJar-4.0-sources.jar 中找到的类的代码。
顺便说一句,这是 GWT 编译。
这是实际的错误消息:
[INFO] [gwt:compile {execution: default}] [INFO] auto discovered modules [com.noesis.calendar.events.CalendarEvents] [INFO] Loading inherited module 'com.noesis.commons.Commons' [INFO] [WARN] Non-canonical source package: ./ [INFO] Compiling module com.noesis.calendar.events.CalendarEvents [INFO] Validating newly compiled units [INFO] [ERROR] Errors in 'file:/C:/dev/pouncil_projects/calendar-events/src/main/java/com/noesis/calendar/events/shared/model/Calendar Event.java' [INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher it a required module? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/BaseEntityModel.java' [INFO] [ERROR] Line 27: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri t a required module? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/DomainModelException.java' [INFO] [ERROR] Line 6: No source code is available for type com.noesis.commons.exceptions.ApplicationException; did you forget to i nherit a required module? [INFO] [ERROR] Line 14: No source code is available for type com.noesis.commons.Context; did you forget to inherit a required modul e? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/PersistableBaseModel.java' [INFO] [ERROR] Line 70: No source code is available for type com.noesis.commons.calendar.CalendarUtility; did you forget to inherit a required module? [INFO] [ERROR] Line 84: The method clone() is undefined for the type Object [INFO] [ERROR] Line 91: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri t a required module? [INFO] Finding entry point classes [INFO] [ERROR] Unable to find type 'com.noesis.calendar.events.client.CalendarEvents' [INFO] [ERROR] Hint: Previous compiler errors may have made this type unavailable [INFO] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not b e adding its source path entries properly [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR` [INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher it a required module?
有人知道为什么会出现这种情况吗?
Usually the below pom config works for me. I've been successful in the past at adding my jar file's source to my projects as a dependency?
I have two jar files defined like so:
<dependencies>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myJar</artifactId>
<version>4.0</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
</dependencies>
When I open up the myJar-4.0-sources.jar file from windows explorer view, I see all the java source files in it associated packages. But when I look in my eclipse project in my maven dependencies I only see xml files and no java files for myJar-4.0-sources.jar
BTW, regardless if I run the maven build inside eclipse or outside, it complains that there is no source code for classes that should be found in myJar-4.0-sources.jar.
BTW, this is a GWT compile.
Here is the actual error message:
[INFO] [gwt:compile {execution: default}] [INFO] auto discovered modules [com.noesis.calendar.events.CalendarEvents] [INFO] Loading inherited module 'com.noesis.commons.Commons' [INFO] [WARN] Non-canonical source package: ./ [INFO] Compiling module com.noesis.calendar.events.CalendarEvents [INFO] Validating newly compiled units [INFO] [ERROR] Errors in 'file:/C:/dev/pouncil_projects/calendar-events/src/main/java/com/noesis/calendar/events/shared/model/Calendar Event.java' [INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher it a required module? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/BaseEntityModel.java' [INFO] [ERROR] Line 27: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri t a required module? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/DomainModelException.java' [INFO] [ERROR] Line 6: No source code is available for type com.noesis.commons.exceptions.ApplicationException; did you forget to i nherit a required module? [INFO] [ERROR] Line 14: No source code is available for type com.noesis.commons.Context; did you forget to inherit a required modul e? [INFO] [ERROR] Errors in 'jar:file:/C:/Documents%20and%20Settings/Tonte%20Pouncil/.m2/repository/com/noesis/commons/noesis-commons/0.0 .1-SNAPSHOT/noesis-commons-0.0.1-SNAPSHOT-sources.jar!/com/noesis/commons/domain/models/core/PersistableBaseModel.java' [INFO] [ERROR] Line 70: No source code is available for type com.noesis.commons.calendar.CalendarUtility; did you forget to inherit a required module? [INFO] [ERROR] Line 84: The method clone() is undefined for the type Object [INFO] [ERROR] Line 91: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inheri t a required module? [INFO] Finding entry point classes [INFO] [ERROR] Unable to find type 'com.noesis.calendar.events.client.CalendarEvents' [INFO] [ERROR] Hint: Previous compiler errors may have made this type unavailable [INFO] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not b e adding its source path entries properly [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR` [INFO] [ERROR] Line 102: No source code is available for type com.noesis.commons.exceptions.CloneException; did you forget to inher it a required module?
Does anybody have any idea why this is the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GWT 在与已编译的 JAR 相同的 JAR 中查找依赖项源
类文件。由于图书馆在您的控制之下,您最好
当然是将类文件和源文件包含在
相同的 JAR。为此,将
添加到
部分POM(假设标准 Maven 源布局):
GWT looks for dependency sources in the same JAR as the compiled
class files. Since the library is under your control your best
course is to include the class files and the source files in the
same JAR. To do so add a
<resource>
to the<build>
section ofthe POM (assuming standard Maven source layout):
GWT 在与编译的类文件相同的 JAR 中查找依赖项源。您应该将类文件和源文件包含在同一个 JAR 中。为此,将
添加到 POM 的
部分:GWT looks for dependency sources in the same JAR as the compiled class files. Your should include the class files and the source files in the same JAR. To do so add a
<resource>
to the<build>
section of the POM:我终于明白我的问题是。这是我的 .gwt.xml 文件。它没有正确引用 GWT 类。并不是我解决了这个问题,我相信我想通过源 jar 文件引用我的源库的原始方式将会起作用。谢谢。
I finally figured out my problem was. It was my .gwt.xml file. It was not referencing the GWT classes correctly. Not that I solved this, I believe the original way I wanted to reference my source library via the source jar file will work. Thanks.