2011-01-07 3 views
1

通常、以下のpom configが動作します。 jarファイルのソースを自分のプロジェクトに依存関係として追加することに成功しましたか?Maven - ソースの依存関係を追加します。 JavaソースファイルはGWTコンパイルのためにeclipseで利用できません

私はそうのように定義された2つの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ファイルは表示されません

私はmavenビルドをeclipseまたはoutsideの内部で実行するかどうかにかかわらず、 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

私はようやく私の問題だった考え出しました。それは私の.gwt.xmlファイルでした。 GWTクラスを正しく参照していませんでした。これを解決したわけではありませんが、ソースjarファイルを使ってソースライブラリを参照していた元のやり方がうまくいくと思います。ありがとう。

2

GWTは、コンパイル済みの クラスファイルと同じJAR内の依存関係ソースを探します。ライブラリはあなたのコントロール下にあるので、 もちろん、同じJARファイル にクラスファイルとソースファイルを含めることです。そうするために POM(標準Mavenの元のレイアウトを想定)の<build>セクションに<resource>を追加します。

<project> 
    <build> 
    <resources> 
     <resource> 
     <directory>src/main/java</directory> 
     </resource> 
    </resources> 
    </build> 
</project> 
+0

まずオフ、あなたが答えるために私はあなたに感謝しましょう。大変感謝しています! –

+0

私のpom.xmlでリソースタグを使用すると、私のためには機能しませんでした。この時点で、私はもはやsrcファイルがEclipseのMaven Dependenciesツリーに表示されない理由について懸念しなくなりました。また、srcとクラスが同じjarになければならないという要件を満たすために、私はソースとクラスの両方を含む単一のjarを作成するためにmaven-assembly-pluginを使用しました。しかし、私はまだ上記と同じエラーメッセージがあります。だから私は、GWTはクラスパス上にないソースを他のどこかで利用できるようにすることを要求していると結論づけます。私は本当にこの問題に合格するのを助ける必要があります。だから助言は良いです。ありがとうございました。 –

2

GWTは、コンパイルされたクラスファイルと同じJAR内の依存関係ソースを探します。クラスファイルとソースファイルを同じJARファイルに含める必要があります。そのためにはPOMの<build>セクションに<resource>を追加します。

<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> 
関連する問題