0
votes

I'm reasonably new to ant and I'm not quite sure why I am getting the following error when I run ant: Cannot locate target java: please set JAVA_HOME to its location. I've pasted the relevant source code below. From what I can see, the target -check-langtools.jdk.home is being executed. But because it depends on -def-check, that gets executed. Do the attributes (name, property, marker) get passed into -def-check when -check-langtools.jdk.home is being called? If so - the failure must be happening at the condition where is the property is not being set (i.e isset must be returning false). I don't understand how the property is not being set, if it is able to print out the value (i.e. JAVA_HOME).

Background: Trying to build langtools from OpenJDK

<target name="-def-check">
  <macrodef name="check">
      <attribute name="name"/>
      <attribute name="property"/>
      <attribute name="marker" default=""/>
        <sequential>
            <fail message="Cannot locate @{name}: please set @{property} to its location">  
                <condition>
                    <not>
                        <isset property="@{property}"/>
                    </not>
                </condition>
            </fail>
            <fail message="@{name} is not installed in ${@{property}}">
                <condition>
                    <and>
                        <not>
                            <equals arg1="@{marker}" arg2=""/>
                        </not>
                        <not>
                            <available file="${@{property}}/@{marker}"/>
                        </not>
                    </and>
                </condition>
            </fail>
        </sequential>
    </macrodef>
</target>

<target name="-check-langtools.jdk.home" depends="-def-check">
    <!-- <check name="target java" property="langtools.jdk.home" marker="${java.marker}"/>   -->
    <check name="target java" property="JAVA_HOME" marker="${java.marker}"/>
</target>

<target name="-check-jtreg.home" depends="-def-check">
    <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
</target>
1
depends means run this before you run meBevynQ
So then my question is: how does the first thing that is run ("Cannot locate @{name}: please set @{property} to its location") know things that are set in run me. e.g. Cannot locate target java: please set @{property} to its location where property = JAVA_HOMEuser3601148
isset is looking for properties set with <property>BevynQ
why macro inside target ???Antoniossss

1 Answers

0
votes

This question was a bit of a blonde one but I ended up approaching this problem the wrong way, but I'll post up the answer here if anyone is new to Ant, and looking to do the same thing. To build the langtools portion of javac, what they need to do is set langtools.jdk.home=path_to_jdk_installation in a separate build.properties file that is included.

(eg. langtools.jdk.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home)