[
https://issues.apache.org/jira/browse/DERBY-4341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833904#action_12833904
]
John Storta Jr. commented on DERBY-4341:
----------------------------------------
I have been digging into this for a while and the more I read about ant the
more it becomes clear that ant runs best when CLASSPATH is not set at all. The
ant documentation has a whole section about the classpath.
http://ant.apache.org/manual/install.html
Section: "The CLASSPATH environment variable"
The gist of it is that you should not run ant with CLASSPATH set. And if you
do, you should run ant with the -noclasspath option as I had indicated in the
workaround section.
They also include the following code as something that you can add to your
build.xml file to error out if the CLASSPATH is set.
<property environment="env."/>
<property name="env.CLASSPATH" value=""/>
<fail message="Unset $CLASSPATH / %CLASSPATH% before running Ant!">
<condition>
<not><equals arg1="${env.CLASSPATH}" arg2=""/></not>
</condition>
</fail>
This essentially checks if your CLASSPATH is set and reports a relevant error
message.
I've tested it at the top of the build.xml and also within the runmessagecheck
target. With this in place, the build will fail with a message indicating the
problem and how to fix it, which is at least clearer than just getting errors
about missing messages.
Below is my modified version of the runmessagecheck target.
<!-- Run the MessageBundleTest -->
<target name="runmessagecheck">
<property environment="env."/>
<property name="env.CLASSPATH" value=""/>
<fail message="Unset $CLASSPATH / %CLASSPATH% before running Ant!">
<condition>
<not><equals arg1="${env.CLASSPATH}" arg2=""/></not>
</condition>
</fail>
<taskdef
name="runMessageBundleTest"
classname="org.apache.derbyBuild.MessageBundleTest"
classpath="${out.dir}"
/>
<runMessageBundleTest/>
</target>
The test could also be put at the top of the build.xml if we want to fail out
any time CLASSPATH is set rather than just from within this one target. I
could see this same situation occurring with other targets and with it
apparently never being a good idea to have the CLASSPATH set, we might want to
avoid the case of getting additional bugs down the road as new targets exhibit
the issue.
In my opinion, the solution that matches what ant recommends is to update the
documentation to reflect that ant should be run without the CLASSPATH set (or
with the -noclasspath option)
As a separate item, we can add the code I indicated to the appropriate place in
build.xml to catch cases where it would fail so that a meaningful message is
displayed. One thing to keep in mind if the build.xml is changed. If you have
CLASSPATH set AND use the -noclasspath option, the code will still result in
the fail since it does not check the -noclasspath option. I am seeing if there
is a way to also test for the -noclasspath option.
> Building with ant all with a different CLASSPATH defined causes the build to
> fail
> ---------------------------------------------------------------------------------
>
> Key: DERBY-4341
> URL: https://issues.apache.org/jira/browse/DERBY-4341
> Project: Derby
> Issue Type: Bug
> Components: Build tools
> Affects Versions: 10.6.0.0
> Reporter: Tiago R. Espinha
> Assignee: John Storta Jr.
>
> The problem happens when we are trying to compile the source code in a folder
> and have the CLASSPATH variable set to a different code tree folder. This
> results in compile failures like the following:
> runmessagecheck:
> [runMessageBundleTest] WARNING: Message id 22011.S.1 in
> messages_en.properties is not referenced in either SQLState.java or
> MessageId.java
> [runMessageBundleTest] WARNING: Message id 42Y03.S.0 in
> messages_en.properties is not referenced in either SQLState.java or
> MessageId.java
> [runMessageBundleTest] WARNING: Message id 42Y03.S.1 in
> messages_en.properties is not referenced in either SQLState.java or
> MessageId.java
> [runMessageBundleTest] WARNING: Message id 42Y03.S.2 in
> messages_en.properties is not referenced in either SQLState.java or
> MessageId.java
> BUILD FAILED
> /home/tiago/Desktop/DerbyStuff/CodeTenFiveTwo/build.xml:514: Message check
> failed.
> See error in build output or call ant runmessagecheck.
> Total time: 1 minute 11 seconds
> This should be an easy fix and it is marked as a bug, since it doesn't seem
> very logical for the compiling process to be CLASSPATH-dependent. Note that
> unsetting the CLASSPATH altogether allows the compile to run without errors,
> so clearly this variable isn't needed and shouldn't be used when it is set.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.