尝试理解将 Kotlin 与 Ant 结合使用
Trying to understanding using Kotlin with Ant
<target name="build">
<delete dir="classes" failonerror="false"/>
<mkdir dir="classes"/>
<javac destdir="classes" includeAntRuntime="false" srcdir="src">
<withKotlin/>
</javac>
<jar destfile="hello.jar">
<fileset dir="classes"/>
</jar>
</target>
我正在努力将 Kotlin 与我现有的 Java 项目(ivy 和 ant)集成。目前我们使用 ivy.xml 进行依赖管理,使用 ant 构建脚本。
如果我使用 IVY,指定 classpath="${kotlin.lib}/kotlin-ant.jar"
是否多余?
我得到一个错误 org/jetbrains/kotlin/ant/antlib.xml
在类路径中找不到。如何解决?
如何使用 Ivy 添加 kotlin-ant.jar & 及其所有依赖项?
如果使用Ivy,则无需指定classpath="${kotlin.lib}/kotlin-ant.jar"
关于 2 和 3。
为 ivy.xml
中的 Kotlin 依赖项创建配置
<configurations>
<conf name="kotlin" description="Kotlin Tasks"/>
</configurations>
<dependencies>
<dependency org="xxxxx" name="kotlin-ant" rev="xxxxx" conf="kotlin->default"/>
</dependencies>
在Build.xml中更新配置。
<target name="resolve">
<ivy:resolve />
<ivy:cachepath pathid="kotlin.classpath" conf="kotlin"/>
</target>
<target name="build" depends="resolve">
<typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpathref="kotlin.classpath"/>
<kotlinc .....
</kotlinc>
</target>
<target name="build">
<delete dir="classes" failonerror="false"/>
<mkdir dir="classes"/>
<javac destdir="classes" includeAntRuntime="false" srcdir="src">
<withKotlin/>
</javac>
<jar destfile="hello.jar">
<fileset dir="classes"/>
</jar>
</target>
我正在努力将 Kotlin 与我现有的 Java 项目(ivy 和 ant)集成。目前我们使用 ivy.xml 进行依赖管理,使用 ant 构建脚本。
如果我使用 IVY,指定
classpath="${kotlin.lib}/kotlin-ant.jar"
是否多余?我得到一个错误
org/jetbrains/kotlin/ant/antlib.xml
在类路径中找不到。如何解决?如何使用 Ivy 添加 kotlin-ant.jar & 及其所有依赖项?
如果使用Ivy,则无需指定classpath="${kotlin.lib}/kotlin-ant.jar"
关于 2 和 3。
为 ivy.xml
中的 Kotlin 依赖项创建配置<configurations>
<conf name="kotlin" description="Kotlin Tasks"/>
</configurations>
<dependencies>
<dependency org="xxxxx" name="kotlin-ant" rev="xxxxx" conf="kotlin->default"/>
</dependencies>
在Build.xml中更新配置。
<target name="resolve">
<ivy:resolve />
<ivy:cachepath pathid="kotlin.classpath" conf="kotlin"/>
</target>
<target name="build" depends="resolve">
<typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpathref="kotlin.classpath"/>
<kotlinc .....
</kotlinc>
</target>