1

我在文檔中看到的所有示例都告訴我如何通過build.gradle文件向Eclipse項目類路徑添加條目太常見了。他們說沒有什麼如何添加一個條目:如何通過gradle將具體的引用添加到Eclipse項目中的類路徑中?

<classpathentry exported="true", kind="con" path="GROOVY_SUPPORT"/> 

Doc或書「搖籃有效實施指南」與建議很沒用,因爲

//closure executed after .classpath content is loaded from existing file 
    //and after gradle build information is merged 
    whenMerged { classpath -> 
    //you can tinker with the Classpath here 
    } 

回答

4

你可以通過創建一個實例添加其他類路徑條目org.gradle.plugins.ide.eclipse.model.Container

eclipse { 
    classpath { 
     file { 
      whenMerged { classpath -> 
       def groovySupportContainer = new org.gradle.plugins.ide.eclipse.model.Container('GROOVY_SUPPORT') 
       groovySupportContainer.exported = true 
       classpath.entries << groovySupportContainer 
      } 
     } 
    } 
} 
+0

十分感謝(我發現瞭如何通過「withXml」改變它,但我想知道如何與classpath中直接使用)。你也可以好好說,你在哪裏得到這些信息?我找不到它。 :-( – Gangnus

+0

我不認爲這是真的記錄了一個具體的例子,我看了一下Gradle Javadocs –

+0

我也試過了,但是如果有如何將容器連接到類路徑,我什麼都沒有 – Gangnus

相關問題