2012-08-08 35 views
2

我有Eclipse Ganymede,並且想要使用ant的自動內容輔助功能。我有我的ant-contrib-1.0b3.jar如何在eclipse中使用ant-contrib任務auto content assist

在eclipse中需要什麼配置才能使用自動內容輔助功能,其中也可以包含ant-contrib的任務?

當我使用以下ant可以識別ant-contrib的任務,但內容幫助不起作用?

<!-- Define classpath for ant-contrib tasks --> 
<path id="ant.contrib.classpath"> 
    <fileset dir="/path/to/lib/"> 
     <include name="ant-contrib-1.0b3.jar" /> 
    </fileset> 
</path> 

<!-- Task definition --> 
<taskdef resource="net/sf/antcontrib/antcontrib.properties"> 
    <classpath refid="ant.contrib.classpath" /> 
</taskdef> 

回答

4

請嘗試以下操作。

我理解爲Ant 1.6及更高版本,你需要引用antcontrib XML文件,而不是屬性的文件,像這樣:

<!-- Task definition --> 
<taskdef resource="net/sf/antcontrib/antlib.xml"> 
    <classpath refid="ant.contrib.classpath" /> 
</taskdef> 

這也是詳細here

除此之外,在Preferences -> Ant -> Editor -> Content Assist檢查Provide proposals for user defined tasks是像這樣檢查(這也是默認值):

enter image description here

如果以上兩者都在地方,你應該得到的內容輔助,如下所示(這是從您的文章,唯一的區別是,該代碼已經取代了參考antcontrib.propertiesantlib.xml):

enter image description here

使用xml替換對屬性文件的引用,使Eclipse Indigo SR2(64位)上的所有功能與衆不同。

我檢查以確保此功能(內容輔助用戶定義的螞蟻任務)自Eclipse 3.3以來可用至少。在Eclipse 3.3中,這個特性與Ant Editor中存在性能問題有關,但是現在已經解決了這個問題。

+0

似乎不適合我。如果我寫'if'或'var'否'content-assist'出現。 – SiB 2012-08-08 09:34:08

+0

然後必須與你的Eclipse版本有關。我假定你什麼時候什麼都沒有出現,你的意思是甚至在使用XML文件之後?在新的工作區中嘗試此操作。如果您使用Eclipse Indigo SR2嘗試此操作,會發生什麼情況? – 2012-08-08 09:43:43

+0

這不適用於我使用eclipse 4.2。 – prolink007 2012-10-01 18:02:50

相關問題