【发布时间】:2022-07-30 02:53:44
【问题描述】:
我正在尝试编写这样的目标
<!-- Properties that must be set when invoking via antcall:
DestinationDir Directory to compile classes to.
ReleaseVer Java version this is being compiled for (i.e. 8, 9, etc). Must be at least 8.
Debug Whether to compile with debug information. Either 'on' or 'off'.
-->
<target name="java-support-compile" description="compile JavaSupport source">
<mkdir dir="${DestinationDir}"/>
<condition property="ModulesSupported">
<not>
<equals arg1="${ReleaseVer}" arg2="8" />
</not>
</condition>
<!-- Compile GSSUtilWrapper separately, since we can't use the 'release' option when referencing the sun.security.jgss.GSSUtil package,
and we need to add an --add-exports option to access the java.security.jgss module for ${ReleaseVer} > 9 -->
<javac srcdir="${javasupport.src.dir}" source="1.${ReleaseVer}" target="1.${ReleaseVer}" debug="${Debug}" destdir="${DestinationDir}">
<include name="${GSSUtilWrapperFile}"/>
<compilerarg if="${ModulesSupported}" line="--add-exports java.security.jgss/sun.security.jgss=ALL-UNNAMED" />
</javac>
<javac srcdir="${javasupport.src.dir}" release="${ReleaseVer}" debug="${Debug}" destdir="${DestinationDir}">
<exclude name="${GSSUtilWrapperFile}"/>
</javac>
</target>
我得到的错误是compilerarg doesn't support the "if" attribute。我需要它是有条件的,就好像我传入 ReleaseVer=8,我收到错误 error: option --add-exports not allowed with target 8
我从 http://ant-contrib.sourceforge.net/compilerarg.html 获得了该语法,但我没有意识到这不在核心 ant 中(如果可能的话,我不想安装任何其他东西)。
如何在标准蚂蚁中做到这一点?
【问题讨论】:
标签: ant