我一直在做一个用ant构建的Java项目,直到最近,它都能完美地工作。现在我遇到了一些我不理解的错误(我是蚂蚁的新手),而且似乎有很多错误。我已经找出了其中一个,但潜在的问题可能还有更多的问题,所以如果我没有提供足够的信息,请向我索取更多
我发现的问题与我的build.properties
文件、调用它的commonbuild.xml
以及整个项目的根build.xml
有关。当我像这样从命令行运行ant时:
> ant
它输出:
(除了前10行,我不会显示所有行,但我被告知要始终显示动作的全部输出)
C:Depotafischer_L09691MvisionDevEMV_VERACODEemv>ant
Buildfile: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvbuild.xml
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
echo_name:
[echo] idl
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvidlbuild.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:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
echo_name:
[echo] AddDefDbNavView
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaAddDefaultDbNavViewbuild.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:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
echo_name:
[echo] EmvDbTrans
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvDbToOraclebuild.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:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = ${DEBUG_ON}
[echo] DEBUG_LVL = ${DEBUG_LVL}
echo_name:
[echo] EmvUtils
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilsbuild.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:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilsclasses
[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:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:41: error: package
EmvIdl does not exist
[javac] public EmvIdl.EmvSessionManager m_emv_session_manager;
[javac] ^
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:46: error: package
EmvIdl does not exist
[javac] public EmvIdl.AdminServer m_admin_server;
[javac] ^
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:51: error: package
EmvIdl does not exist
[javac] public EmvIdl.FigureToPngImage m_figure_to_png_image_server;
[javac] ^
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:189: error: package
EmvIdl does not exist
[javac] m_emv_session_manager = EmvIdl.EmvSessionManagerHelper.narrow(obj);
[javac] ^
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:219: error: package
EmvIdl does not exist
[javac] m_admin_server = EmvIdl.AdminServerHelper.narrow(obj);
[javac] ^
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilsEmvConnectionManager.java:252: error: package
EmvIdl does not exist
[javac] m_figure_to_png_image_server = EmvIdl.FigureToPngImageHelper.narrow(obj);
[javac] ^
[javac] Note: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilswebDumpRequest.java uses or overrides
a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilswebDumpRequest.java uses unchecked or
unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 6 errors
[javac] 4 warnings
BUILD FAILED
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvbuild.xml:30: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesbuild.xml:6: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavabuild.xml:8: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilsbuild.xml:7: Compile failed; see the compiler error output for details
.
Total time: 1 second
在这里,您可以从我的调试尝试中看到一些echo
。如果你看一下OUTPUT_DIR
的值,它计算为classes
,env.EMV_VOBS
和JAR_OUTPUT_DIR
也是,但DEBUG_ON
和DEBUG_LVL
没有。这就是问题所在。。。并不是所有来自CCD_ 11的值都被使用。
相反,如果我像这样运行ant构建:
>ant -propertyfile ./ant/build.properties
它输出这个:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemv>ant -propertyfile ./ant/build.properties
Buildfile: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvbuild.xml
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
echo_name:
[echo] idl
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvidlbuild.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:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
buildSubDirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
subdirs:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
echo_name:
[echo] AddDefDbNavView
init:
create_dirs:
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaAddDefaultDbNavViewbuild.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:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
echo_name:
[echo] EmvDbTrans
init:
create_dirs:
[mkdir] Created dir: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvDbToOracle${env.EMV_JAR_OUTPUT}
compile:
[javac] C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvDbToOraclebuild.xml:7: warning: 'includeantruntime' was not set
, defaulting to build.sysclasspath=last; set to false for repeatable builds
make_jar:
[jar] Building jar: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvDbToOracle${env.EMV_JAR_OUTPUT}EmvDbTrans.jar
build:
[echo] env.EMV_VOBS = C:Depotafischer_L09691MvisionMAIN
[echo] OUTPUT_DIR = classes
[echo] JAR_OUTPUT_DIR = C:Depotafischer_L09691MvisionDevEMV_VERACODEemvjarVeracode
[echo] DEBUG_ON = on
[echo] DEBUG_LVL = lines,vars,source
..............
[javac] Note: C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilssrcEmvUtilswebDumpRequest.java uses unchecked or
unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 30 errors
[javac] 4 warnings
BUILD FAILED
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvbuild.xml:30: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesbuild.xml:6: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvantcommonbuild.xml:12: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavabuild.xml:8: The following error occurred while executing this line:
C:Depotafischer_L09691MvisionDevEMV_VERACODEemvutilitiesjavaEmvUtilsbuild.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:viewemv)
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
对于那些感兴趣的人,我找到了问题的根源。
我在一台有多个分支的机器上工作。我被要求在机器的Main分支中做一些事情,设置一些环境变量,然后继续下一期。几周后,这些ant文件使用了相同的环境变量,当我构建Dev分支时,我忘记了其中一个变量有多重要。除了一个,我都改了,当然这是最重要的一个
因此,最后,我试图使用另一个代码库中的build.xml文件编译一个代码基,并手动传递我的build.properties
,这进一步混淆了我的问题。这里面的教训是什么?当我遇到问题时,我需要真正检查我的环境,而不仅仅是假设我已经正确设置了所有内容。
谢谢你读到我的困境,我要躲在角落里