通常下面的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?
有人知道为什么会这样吗?
答案 0 :(得分:2)
GWT在与编译的JAR相同的JAR中查找依赖项源
类文件。由于图书馆是你最好的控制之下
当然是包含类文件和源文件
同样的JAR。为此,请向<resource>
部分添加<build>
POM(假设标准的Maven源布局):
<project>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
</project>
答案 1 :(得分:2)
GWT在与编译的类文件相同的JAR中查找依赖项源。您应该在同一个JAR中包含类文件和源文件。为此,请在POM的<resource>
部分添加<build>
:
<project>
<build>
<resources>
<!-- include the source files in our main jar for use by GWT -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
</resource>
<!-- and continue to include our standard resources -->
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
</project>
答案 2 :(得分:0)
我终于弄明白我的问题了。这是我的.gwt.xml文件。它没有正确引用GWT类。不是我解决了这个,我相信我想通过源jar文件引用我的源库的原始方式将起作用。感谢。