【问题标题】:Trying to understanding using Kotlin with Ant试图理解在 Ant 中使用 Kotlin
【发布时间】:2019-03-07 01:17:09
【问题描述】:

<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 Website

我正在努力将 Kotlin 与我现有的 Java 项目(ivy 和 ant)集成。目前我们使用 ivy.xml 进行依赖管理,使用 ant 构建脚本。

  1. 如果我使用 IVY,是否会导致指定 classpath="${kotlin.lib}/kotlin-ant.jar" 多余?

  2. 我在类路径中找不到错误org/jetbrains/kotlin/ant/antlib.xml。如何解决?

  3. 如何使用 Ivy 添加 kotlin-ant.jar & 及其所有依赖项?

【问题讨论】:

    标签: java kotlin ant ivy


    【解决方案1】:

    如果使用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>
    

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-06
      相关资源
      最近更新 更多