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 sour开发者_运维百科ce 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?
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 of
the POM (assuming standard Maven source layout):
<project>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
</project>
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:
<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>
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.
精彩评论