gpt4 book ai didi

java - 为什么我的 build.properties 中的值没有通过我的 ant 构建传播?

转载 作者:行者123 更新时间:2023-11-30 08:05:47 25 4
gpt4 key购买 nike

我一直在开发一个使用 ant 构建的 Java 项目,直到最近它都运行得非常完美。现在我遇到了一些我不明白的错误(我是 Ant 的新手),而且似乎有很多错误。我已经梳理出了其中之一,但潜在问题可能还有更多问题,所以如果我没有提供足够的信息,请向我询问更多信息。 =)

我已经弄清楚的问题与我的 build.properties 文件、调用它的 commonbuild.xml 以及根 build.xml 整个项目。当我从命令行运行 ant 时,如下所示:

> ant

它输出:

(除了前 10 行之外,我不会显示所有内容,但我被告知要始终显示操作的完整输出)

C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv>ant
Buildfile: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\build.xml
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

echo_name:
[echo] idl

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\idl\build.xml:55: warning: 'includeantruntime' was not set, defaulting to build.sy
sclasspath=last; set to false for repeatable builds

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

echo_name:
[echo] AddDefDbNavView

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\AddDefaultDbNavView\build.xml:7: warning: 'includeantruntime' was n
ot set, defaulting to build.sysclasspath=last; set to false for repeatable builds

make_jar:

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

echo_name:
[echo] EmvDbTrans

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvDbToOracle\build.xml:7: warning: 'includeantruntime' was not set
, defaulting to build.sysclasspath=last; set to false for repeatable builds

make_jar:

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}

echo_name:
[echo] EmvUtils

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\build.xml:7: warning: 'includeantruntime' was not set, def
aulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 10 source files to C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\classes
[javac]
[javac] WARNING
[javac]
[javac] The -source switch defaults to 1.8 in JDK 1.8.
[javac] If you specify -target 1.5 you now must also specify -source 1.5.
[javac] Ant will implicitly add -source 1.5 for you. Please change your build file.
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:41: error: package
EmvIdl does not exist
[javac] public EmvIdl.EmvSessionManager m_emv_session_manager;
[javac] ^
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:46: error: package
EmvIdl does not exist
[javac] public EmvIdl.AdminServer m_admin_server;
[javac] ^
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:51: error: package
EmvIdl does not exist
[javac] public EmvIdl.FigureToPngImage m_figure_to_png_image_server;
[javac] ^
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:189: error: package
EmvIdl does not exist
[javac] m_emv_session_manager = EmvIdl.EmvSessionManagerHelper.narrow(obj);
[javac] ^
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:219: error: package
EmvIdl does not exist
[javac] m_admin_server = EmvIdl.AdminServerHelper.narrow(obj);
[javac] ^
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\EmvConnectionManager.java:252: error: package
EmvIdl does not exist
[javac] m_figure_to_png_image_server = EmvIdl.FigureToPngImageHelper.narrow(obj);
[javac] ^
[javac] Note: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\web\DumpRequest.java uses or overrides
a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\web\DumpRequest.java uses unchecked or
unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 6 errors
[javac] 4 warnings

BUILD FAILED
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\build.xml:30: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\build.xml:6: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\build.xml:8: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\build.xml:7: Compile failed; see the compiler error output for details
.

Total time: 1 second

在这里您可以看到我的调试尝试中的一些回显。如果您查看 OUTPUT_DIR 的值,它会评估为 classesenv.EMV_VOBSJAR_OUTPUT_DIR 也是如此,但 DEBUG_ONDEBUG_LVL 没有。这就是问题所在...并非 build.properties 中的所有值都被使用。

如果我像这样运行 ant 构建:

>ant -propertyfile ./ant/build.properties

它输出:

    C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv>ant -propertyfile ./ant/build.properties
Buildfile: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\build.xml
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

echo_name:
[echo] idl

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\idl\build.xml:55: warning: 'includeantruntime' was not set, defaulting to build.sy
sclasspath=last; set to false for repeatable builds

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

buildSubDirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

subdirs:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

echo_name:
[echo] AddDefDbNavView

init:

create_dirs:

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\AddDefaultDbNavView\build.xml:7: warning: 'includeantruntime' was n
ot set, defaulting to build.sysclasspath=last; set to false for repeatable builds

make_jar:

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source

echo_name:
[echo] EmvDbTrans

init:

create_dirs:
[mkdir] Created dir: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvDbToOracle\${env.EMV_JAR_OUTPUT}

compile:
[javac] C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvDbToOracle\build.xml:7: warning: 'includeantruntime' was not set
, defaulting to build.sysclasspath=last; set to false for repeatable builds

make_jar:
[jar] Building jar: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvDbToOracle\${env.EMV_JAR_OUTPUT}\EmvDbTrans.jar

build:
[echo] env.EMV_VOBS = C:\Depot\afischer_L09691\Mvision\MAIN\
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\jar\Veracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
..............
[javac] Note: C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\src\EmvUtils\web\DumpRequest.java uses unchecked or
unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 30 errors
[javac] 4 warnings

BUILD FAILED
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\build.xml:30: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\build.xml:6: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\ant\commonbuild.xml:12: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\build.xml:8: The following error occurred while executing this line:
C:\Depot\afischer_L09691\Mvision\Dev\EMV_VERACODE\emv\utilities\java\EmvUtils\build.xml:7: Compile failed; see the compiler error output for details
.

Total time: 1 second

这对我来说很奇怪,因为 commonbuild.xml 的第三行

<property file="${env.EMV_VOBS}/emv/ant/build.properties"/>

应该导入我的 build.properties 文件,它有点......如果你查看 > ant 的输出,你会看到 OUTPUT_DIR = classes 我认为是从 build.properties 获取的。

所以...

  • 为什么 build.properties 中的某些值被使用,而其他值却没有被使用?
  • 您还发现这些文件存在哪些其他问题?

这只是第一期,所以欢迎对下面的代码提出任何批评;我想尽我所能地了解这些文件。

代码附录:

build.xml:

<!--

To run this, type in ant in the emv vobs directory (c:\view\emv)

ant clean - to clean the build environment
ant - to build the environment
-->
<project name="Emv" default="build" basedir=".">

<import file="ant/commonbuild.xml" />

<target name="subdirs">
<ant dir="idl" target="${param1}"/>
<ant dir="utilities" target="${param1}"/>
<ant dir="admin_panel" target="${param1}"/>
<ant dir="emv_monitor" target="${param1}"/>
<ant dir="integratedClient" target="${param1}"/>
<ant dir="web_server" target="${param1}"/>
<ant dir="XY-Graphics" target="${param1}"/>
</target>

<target name="build" depends="buildSubDirs" />
<target name="clean" depends="cleanSubDirs" />

</project>

commonbuild.xml:

<project name="commonbuild" default="buildSubDirs" basedir=".">

<property environment="env"/>
<property file="${env.EMV_VOBS}/emv/ant/build.properties"/>
<echo message="env.EMV_VOBS = ${env.EMV_VOBS}"/>
<echo message="OUTPUT_DIR = ${OUTPUT_DIR}"/>
<echo message="JAR_OUTPUT_DIR = ${env.EMV_JAR_OUTPUT}"/>
<echo message="DEBUG_ON = ${DEBUG_ON}"/>
<echo message="DEBUG_LVL = ${DEBUG_LVL}"/>

<target name="buildSubDirs">
<antcall target="subdirs">
<param name="param1" value="build"/>
</antcall>
</target>

<target name="cleanSubDirs">
<antcall target="subdirs">
<param name="param1" value="clean"/>
</antcall>
</target>

<target name="echo_name" depends="">
<echo message="${ant.project.name}"/>
</target>

<target name="init" depends="echo_name">
<property name="project_name" value="${ant.project.name}"/>
<property name="jar" value="${JAR_OUTPUT_DIR}/${project_name}.jar"/>
<tstamp/>
</target>

<target name="clean" depends="init">
<delete dir="${OUTPUT_DIR}"/>
<delete file="${jar}"/>
</target>

<target name="create_dirs" depends="init">
<mkdir dir="${OUTPUT_DIR}"/>
<mkdir dir="${JAR_OUTPUT_DIR}"/>
</target>

</project>

构建.属性:

OUTPUT_DIR=classes
DEBUG_ON=on
DEBUG_LVL=lines,vars,source
JAR_OUTPUT_DIR=${env.EMV_JAR_OUTPUT}
TOMCAT_HOME=${env.TOMCAT_HOME}
ant.build.javac.target=1.5

最佳答案

对于那些感兴趣的人,我找到了问题的根源。

我正在一台具有多个分支的机器上工作。我被要求在我的机器上的主分支中做一些事情,并设置一些环境变量,然后继续下一期。几周后,这些 ant 文件使用了相同的环境变量,当我去构建我的 Dev 分支时,我忘记了其中一个变量的重要性。除了一处之外,我都改变了,当然这是最重要的一处。 =/

所以最后,我尝试使用另一个代码库的 build.xml 文件来编译一个代码库,并手动传递我的 build.properties ,这进一步混淆了我的问题。这其中的教训是什么?当遇到问题时,我需要真正检查我的环境,而不仅仅是假设我已经正确设置了所有内容。

感谢您阅读我的困境,我要躲到角落里去。 =)

关于java - 为什么我的 build.properties 中的值没有通过我的 ant 构建传播?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31143234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com