Ant Ivy不会设置编译类路径

问题描述 投票:0回答:1

我在网上阅读的所有内容都说我做对了,但是Ant / Ivy拒绝设置我的编译类路径。这是我的ivy.xml

<ivy-module version="2.0">
    <info organisation="com.latencyzero.missiondb" module="webapp"/>

    <configurations defaultconfmapping="runtime->*">
        <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
        <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
        <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
        <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
    </configurations>

    <dependencies>
        <dependency org="org.apache.logging.log4j"              name="log4j"                        rev="2.13.3"            conf="compile->default"/>
    </dependencies>
</ivy-module>

以及build.xml的相关部分:

    <target name="resolve" description="==> retrieve dependencies with Ivy">
        <ivy:retrieve/>

        <ivy:cachepath pathid="compile.classpath" conf="compile" />
    </target>
    <target name="compile" depends="resolve" description="==> Compile Java sources">
        <mkdir  dir="${obj}"/>

        <javac  destdir="${obj}"
                source="${sourceVersion}"
                target="${targetClassVersion}"
                encoding="UTF-8"
                deprecation="${deprecation}"
                nowarn="${suppressWarnings}"
                debug="on"
                listfiles="false"
                includeantruntime="false">
            <classpath refid="compile.classpath"/>

            <src path="${common}"/>
            <src path="${src}"/>
        </javac>
    </target>

当我运行ant -v compile时,它将下载log4j.jar文件,然后将其忽略:

[ivy:retrieve] :: Apache Ivy 2.4.0 - 20141213170938 :: http://ant.apache.org/ivy/ ::
...
[ivy:retrieve] main: module revision found in cache: org.apache.logging.log4j#log4j;2.13.3
[ivy:retrieve]  found org.apache.logging.log4j#log4j;2.13.3 in public
...
    [javac] Compiling 94 source files to .../repo/branches/v1.0/target/object
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-deprecation'
    [javac] '-d'
    [javac] '.../repo/branches/v1.0/target/object'
    [javac] '-classpath'
    [javac] '.../repo/branches/v1.0/target/object'
    [javac] '-sourcepath'
    [javac] '.../repo/branches/v1.0/lib/common/src:.../repo/branches/v1.0/src/main/java'
    [javac] '-target'
    [javac] '1.7'
    [javac] '-encoding'
    [javac] 'UTF-8'
    [javac] '-g'
    [javac] '-source'
    [javac] '1.7'
    [javac] 
    [javac] Files to be compiled:
...
    [javac] ...dao/AbstractDAOHibernate.java:23: error: package org.apache.logging.log4j does not exist
    [javac] import org.apache.logging.log4j.Logger;
    [javac]                                ^

注意,类路径只有目标目录,没有jar。我必须缺少明显的东西,但我肯定看不到。

java ant classpath ivy
1个回答
0
投票

所以,事实证明我应该指定的依赖项是:

© www.soinside.com 2019 - 2024. All rights reserved.