2015-05-28 33 views
3

我想創建一個類似於這種結構的搖籃多項目無效的類路徑publish/export dependency/ouat-contract。項目條目不支持

ouat-services 
    - ouat-contract 
    - ouat-servicesImpl (web project) 

我跟着日食例子和定義我ouat服務settings.gradle爲

include "ouat-contract", "ouat-servicesImpl" 

在我ouat -servicesImpl集結gradle這個我定義

dependencies { 
    compile project(':ouat-contract') 
} 

當我嘗試運用戰爭插件在ouat-servicesImpl,I R我的問題開始在Eclipse問題視圖eceive以下消息:

Invalid classpath publish/ export dependency /ouat-contract. Project entries not supported 

我ouat服務的build.gradle

configure(subprojects) { 

    apply plugin: 'com.github.ben-manes.versions' 
    apply plugin: 'eclipse' 
    apply plugin: 'java' 

    version = '1.0' 

    sourceCompatibility = 1.8 
    targetCompatibility = 1.8 

    def defaultEncoding = 'UTF-8' 
    [compileJava, compileTestJava]*.options*.encoding = defaultEncoding 

    repositories { 

    jcenter() 
    mavenLocal() 
    mavenCentral() 
    } 

    jar { 
    manifest.attributes provider: 'Company' 
    } 
} 

configure(project(':ouat-servicesImpl')) { 

    apply plugin: 'checkstyle' 
    apply plugin: 'eclipse-wtp' 
    apply plugin: 'findbugs' 
    apply plugin: 'jacoco' 
    //apply plugin: 'jetty' 
    apply plugin: 'pmd' 
    apply plugin: 'war' 
} 

buildscript { 

    repositories { 

    jcenter() 
    mavenCentral() 
    mavenLocal() 
    } 

    dependencies { 
    classpath 'com.github.ben-manes:gradle-versions-plugin:0.10.1' 
    } 
} 

我ouat-servicesImpl的gradle構建變更爲:

dependencies { 

    compile project(':ouat-contract') 

    cxfArtifacts.each { artifact -> 
    compile "org.apache.cxf:$artifact:$cxfVersion" 
    } 

    springArtifacts.each { artifact -> 
    compile "org.springframework:$artifact:$springVersion" 
    } 

    testCompile "org.testng:testng:$testNGVersion" 
    testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion" 
    testCompile "org.springframework:spring-test:$springVersion" 

    //WAR PLUGIN 
    providedCompile "javax.servlet:javax.servlet-api:$servletAPIVersion" 
    runtime "javax.servlet:jstl:$jstlVersion" 
} 

這是一個eclipse插件問題還是我做錯了什麼?

回答

0

很久以前我也遇到過這個問題。它看起來好像是與「Gradle IDE Pack」中包含的Eclipse插件相關的問題(因爲它在命令行中工作時沒有問題)。 我的設置是可能的方式比你更復雜(我包括一個頂級項目的Gradle模塊到另一個頂級項目的gradle),但要克服此特定錯誤

Invalid classpath publish/ export dependency /my-project. Project entries not supported 

...我排除如果某些特定gradle這個屬性是缺少項目依賴:

if(project.hasProperty("myProjectRefAddedFromIDE")) { 
    println "NB! Build script started with property 'myProjectRefAddedFromIDE' - expecting that this project in IDE is configured to add the direct reference to my-project" 
} else { 
    compile project(':my-project') 
} 

,並增加只能從IDE屬性「myProjectRefAddedFromIDE」,如下我已經配置Eclipse插件: 窗口 - >首選項 - >搖籃 - >參數 - >程序參數 - >使用:'-PmyProjectRefAddedFromIDE'

只是一個警告:這可能適用於您,但是您的設置可能存在其他一些問題,例如簡單的多模塊項目(不包括另一個多模塊項目的模塊)不得不使用這種解決方法。

+0

所以你說的這實際上不適用於eclipse項目。解決方案是每次更新eclipse文件時手動添加項目作爲依賴關係。對? – ATrubka

11

下面是我發現的一些魔術步驟,可以讓它工作而不用手動搞亂項目設置。

  1. 運行命令:gradle這個cleanEclipse蝕

    • 作爲此命令的Eclipse的結果忘記了,該項目應該有一個自然的gradle。
  2. 通過執行配置 - >轉換爲Gradle項目,將gradle自然添加回項目。

    • 作爲此命令的結果,錯誤再次出現。
    • 如果出現不兼容的插件java版本錯誤,則只需刪除.settings目錄並刷新即可。
  3. 運行命令:gradle這個cleanEclipseClasspath eclipseClasspath

    • 這最後一步應該得到固定,直到下一次。
+0

這適用於我。爲了清楚起見,當我執行多項目gradle導入時,此錯誤標記始終出現在Web項目中。該錯誤似乎不會導致任何問題;這只是令人討厭的看待。 –

+0

另一個有趣的發現是,如果你不運行cleanEclipse並運行eclipse任務,那麼G標誌從項目中消失,但gradle項目的菜單選項仍然可見,你仍然可以執行gradle相關的活動。 – ATrubka

+5

我只是跑了違規項目的最後一步,它爲我工作。不需要重新輸入。 – Aaron

2

在我的情況,這是由於混合「刻面」和非面的項目。有錯誤的項目已被轉換爲分面形式,並且他們所引用的項目沒有被引用。您可以通過添加以下內容到ouat合同gradle這個文件中配置該項目通過使用eclipse-wtp插件來刻面:

eclipse{ 
    wtp{ 
     facet{} 
    } 
} 

這將使用Java和戰爭的插件時添加方面對Java和實用模塊(請參閱EclipseWTPFacet文檔以獲取有關默認值的更多信息,如果不使用war插件則手動添加構面)。公用程序模塊部分是避免錯誤的關鍵。

請注意,此塊中,你也可以直接訪問小文件進行手動處理XML,如果你需要做其他的事情,比如指定特定的Apache Tomcat運行時或或類似

一旦你做出這種改變,你可以使用Eclipse在你的工作區執行Gradle - > Refresh All ouat-contract - 一旦我這樣做了,錯誤消失了