ant 命令行方式執行build javac編譯class出現 泛型無法轉換 無法確定 <X>X 的類型參數;對于上限為 X,java.lang.Object 的類型變量 X,不存在唯一最大實例
解決方法:
需要用到eclipse的jdt來編譯class,不能再使用javac的默認編譯方式。
在eclipse或MyEclipse的eclipse/plugin目錄中找到org.eclipse.jdt.core_3.5.2.v_981_R35x.jar里面找到jdtCompilerAdapter.jar
還有
org.eclipse.jdt.compiler.tool_1.0.100.v_972_R35x.jar
org.eclipse.jdt.core_3.5.2.v_981_R35x.jar
org.eclipse.jdt.debug.ui_3.4.1.v20090811_r351.jar
jdtCompilerAdapter.jar
并拷貝到ant_home/lib下。
在ant的build.xml腳本中加入
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<javac nowarn="false" debug="true" debuglevel="source,lines,vars" destdir="${dist.path}/classes" source="1.6" target="1.6" encoding="utf-8" fork="true" memoryMaximumSize="512m" includeantruntime="false">
或者
<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" nowarn="false" debug="true" debuglevel="source,lines,vars" destdir="${dist.path}/classes" source="1.6" target="1.6" encoding="utf-8" fork="true" memoryMaximumSize="512m" includeantruntime="false"/>
如果是用eclipse運行ant腳本,在右鍵菜單選擇從RUN as Ant 啟動build.xml時,在對話框中 選擇Runtime jRE:run in the same JRE as workspace.
記得要引入上面需要的幾個jar包
版權所有,轉載請注明出處 本文出自:
版權所有,歡迎轉載,轉載請注明出處,謝謝
posted on 2013-10-31 14:10
hoojo 閱讀(5004)
評論(2) 編輯 收藏 所屬分類:
IDE/Utils 、
JavaEE 、
Others 、
RIA 【富互聯網程序】