ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Putnam <d...@bellsouth.net>
Subject Javac Run By Ant Script is Unable to Find External Jars
Date Wed, 13 Feb 2019 18:26:09 GMT
I had a working ant script until I made a number of source changes to my
Java project via Eclipse and egit. I obviously somehow inadvertently
changed something, somewhere, that is causing javac to not find
libraries (perhaps pushed something via git that is not part of the
source). There are some Maven libraries and external jars in the build
path (as displayed by Eclipse) but it seems they are not being found
with the ant script. This is the ant output:

    Buildfile: /usr/build/makejar.xml

    checkOS:

    if_linux:

    if_windows:

    setclass:

    incserial:
         [echo] update build requested
    [propertyfile] Updating property file:
    /usr/build/bin/KCBSEvents/resource/build.properties
         [echo] serial number: 1001

    jar:
         [echo] Using destination file /tmp/60286/KCBSEvents.jar
        [javac] Compiling 7 source files to /usr/build/bin
        [javac] /usr/build/src/KCBSEvents/DoSearch.java:11: error:
    package org.json.simple does not exist
        [javac] import org.json.simple.JSONObject;
        [javac]                       ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:48: error:
    package org.apache.commons.io does not exist
        [javac] import org.apache.commons.io.IOUtils;
        [javac]                             ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:49: error:
    package org.apache.http does not exist
        [javac] import org.apache.http.Consts;
        [javac]                       ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:50: error:
    package org.apache.http does not exist
        [javac] import org.apache.http.HttpResponse;
        [javac]                       ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:51: error:
    package org.apache.http.client does not exist
        [javac] import org.apache.http.client.HttpClient;
        [javac]                              ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:52: error:
    package org.apache.http.client.methods does not exist
        [javac] import org.apache.http.client.methods.HttpPost;
        [javac]                                     
^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:53: error:
    package org.apache.http.entity does not exist
        [javac] import org.apache.http.entity.ContentType;
        [javac]                              ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:54: error:
    package org.apache.http.entity does not exist
        [javac] import org.apache.http.entity.StringEntity;
        [javac]                              ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:55: error:
    package org.apache.http.impl.client does not exist
        [javac] import org.apache.http.impl.client.HttpClients;
        [javac]                                   ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:56: error:
    package org.json.simple does not exist
        [javac] import org.json.simple.JSONObject;
        [javac]                       ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:57: error:
    package org.json.simple does not exist
        [javac] import org.json.simple.JSONArray;
        [javac]                       ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:58: error:
    package org.json.simple.parser does not exist
        [javac] import org.json.simple.parser.JSONParser;
        [javac]                              ^
        [javac] /usr/build/src/KCBSEvents/Helpers.java:362: error:
    cannot find symbol
        [javac]     public static ArrayList<JSONObject> getPage(String
    url) {
        [javac]                             ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:401: error:
    cannot find symbol
        [javac]     public static Comparator<JSONObject> sortJSON=new
    Comparator<JSONObject>() {
        [javac]                              ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/DoSearch.java:33: error:
    cannot find symbol
        [javac]                     ArrayList<JSONObject>
    json=Helpers.getPage(getURL);
        [javac]                               ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class DoSearch
        [javac] /usr/build/src/KCBSEvents/DoSearch.java:40: error:
    cannot find symbol
        [javac]                                    
JSONObject
    evnt=json.get(i);
        [javac]                                    
^
        [javac]   symbol:   class JSONObject
        [javac]   location: class DoSearch
        [javac] /usr/build/src/KCBSEvents/Helpers.java:320: error:
    cannot find symbol
        [javac]             HttpPost post=new
    HttpPost("http://www.mapquestapi.com/directions/v2/routematrix?inFormat=xml&outFormat=xml&key="+Registration.getInstance().getMapQuestKey());
        [javac]             ^
        [javac]   symbol:   class HttpPost
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:320: error:
    cannot find symbol
        [javac]             HttpPost post=new
    HttpPost("http://www.mapquestapi.com/directions/v2/routematrix?inFormat=xml&outFormat=xml&key="+Registration.getInstance().getMapQuestKey());
        [javac]                               ^
        [javac]   symbol:   class HttpPost
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:321: error:
    cannot find symbol
        [javac]             StringEntity entity = new
    StringEntity(xmlString, ContentType.create("text/xml", Consts.UTF_8));
        [javac]             ^
        [javac]   symbol:   class StringEntity
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:321: error:
    cannot find symbol
        [javac]             StringEntity entity = new
    StringEntity(xmlString, ContentType.create("text/xml", Consts.UTF_8));
        [javac]                                      
^
        [javac]   symbol:   class StringEntity
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:321: error:
    cannot find symbol
        [javac]             StringEntity entity = new
    StringEntity(xmlString, ContentType.create("text/xml", Consts.UTF_8));
       
    [javac]                                                                                             
    ^
        [javac]   symbol:   variable Consts
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:321: error:
    cannot find symbol
        [javac]             StringEntity entity = new
    StringEntity(xmlString, ContentType.create("text/xml", Consts.UTF_8));
       
    [javac]                                                              
^
        [javac]   symbol:   variable ContentType
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:324: error:
    cannot find symbol
        [javac]             HttpClient client = HttpClients.createDefault();
        [javac]             ^
        [javac]   symbol:   class HttpClient
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:324: error:
    cannot find symbol
        [javac]             HttpClient client = HttpClients.createDefault();
        [javac]                                 ^
        [javac]   symbol:   variable HttpClients
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:327: error:
    cannot find symbol
        [javac]                     HttpResponse response =
    client.execute(post);
        [javac]                     ^
        [javac]   symbol:   class HttpResponse
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:330: error:
    cannot find symbol
        [javac]                             body =
    IOUtils.toString(in,"UTF-8");
        [javac]                                    ^
        [javac]   symbol:   variable IOUtils
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:344: error:
    cannot find symbol
        [javac]                             body =
    IOUtils.toString(in,"UTF-8");
        [javac]                                    ^
        [javac]   symbol:   variable IOUtils
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:369: error:
    cannot find symbol
        [javac]                     ArrayList<JSONObject> array=new
    ArrayList<JSONObject>();
        [javac]                               ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:369: error:
    cannot find symbol
        [javac]                     ArrayList<JSONObject> array=new
    ArrayList<JSONObject>();
       
    [javac]                                                              
^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:376: error:
    cannot find symbol
        [javac]                     JSONParser parser=new JSONParser();
        [javac]                     ^
        [javac]   symbol:   class JSONParser
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:376: error:
    cannot find symbol
        [javac]                     JSONParser parser=new JSONParser();
        [javac]                                          
^
        [javac]   symbol:   class JSONParser
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:378: error:
    cannot find symbol
        [javac]                             JSONObject json=(JSONObject)
    parser.parse(sb.toString());
        [javac]                             ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:378: error:
    cannot find symbol
        [javac]                             JSONObject json=(JSONObject)
    parser.parse(sb.toString());
        [javac]                                             
^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:381: error:
    cannot find symbol
        [javac]                                    
    array.add((JSONObject) pair.getValue());
        [javac]                                               
^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:385: error:
    cannot find symbol
        [javac]                             JSONArray json=(JSONArray)
    parser.parse(sb.toString());
        [javac]                             ^
        [javac]   symbol:   class JSONArray
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:385: error:
    cannot find symbol
        [javac]                             JSONArray json=(JSONArray)
    parser.parse(sb.toString());
        [javac]                                            
^
        [javac]   symbol:   class JSONArray
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:387: error:
    cannot find symbol
        [javac]                                    
    array.add((JSONObject) json.get(i));
        [javac]                                               
^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:401: error:
    cannot find symbol
        [javac]     public static Comparator<JSONObject> sortJSON=new
    Comparator<JSONObject>() {
       
    [javac]                                                                 
    ^
        [javac]   symbol:   class JSONObject
        [javac]   location: class Helpers
        [javac] /usr/build/src/KCBSEvents/Helpers.java:404: error:
    cannot find symbol
        [javac]             public int compare(JSONObject arg0,
    JSONObject arg1) {
        [javac]                                ^
        [javac]   symbol: class JSONObject
        [javac] /usr/build/src/KCBSEvents/Helpers.java:404: error:
    cannot find symbol
        [javac]             public int compare(JSONObject arg0,
    JSONObject arg1) {
        [javac]                                                
^
        [javac]   symbol: class JSONObject
        [javac] 40 errors

    BUILD FAILED
    /usr/build/makejar.xml:56: Compile failed; see the compiler error
    output for details.


Here is my ant script (makejar.xml):

    <?xml version="2.0" encoding="UTF-8"?>
    <project name="KCBSEvents" default="jar" basedir=".">
            <property name="build.properties" value="build.properties"/>
            <property name="resources" value="resource" />
            <property name="jardir" value="KCBSEvents" />
            <property name="KCBSDir" value="src/KCBSEvents" />
            <property name="member.number" value="000000" />
            <property name="member.name" value="" />
            <target name="checkOS">
                    <condition property="isWindows">
                            <os family="windows" />
                    </condition>
                    <condition property="isLinux">
                            <os family="unix" />
                    </condition>
            </target>
            <target name="if_windows" depends="checkOS" if="isWindows">
                    <property name="jarfile"
    value="C:\temp\KCBSEvents.jar" />
                    <property name="antcontrib"
    value="H:\html\Applets\ant-contrib" />
            </target>
            <target name="if_linux" depends="checkOS" if="isLinux">
                    <property name="jarfile"
    value="/tmp/${member.number}/KCBSEvents.jar" />
                    <property name="antcontrib"
    value="/var/www/html/Applets/ant-contrib/ant-contrib-1.0b3.jar" />
            </target>
            <target name="setclass" depends="if_linux,if_windows">
                    <taskdef
    resource="net/sf/antcontrib/antcontrib.properties">
                            <classpath>
                                    <pathelement location="${antcontrib}"
/>
                            </classpath>
                    </taskdef>
            </target>
            <target name="incserial" depends="setclass">
                    <copy todir="bin/${jardir}/${resources}">
                            <fileset dir="${KCBSDir}/${resources}">
                                    <include name="${build.properties}"
/>
                            </fileset>
                            <filterchain>
                                    <expandproperties />
                            </filterchain>
                    </copy>
                    <if> <isset Property="build.number" /> <then>
                            <echo message="update build requested"
/>
                    </then> <else>
                            <echo message="new build requested"
/>
                            <buildnumber />
                    </else> </if>
                    <propertyfile
    file="bin/${jardir}/${resources}/${build.properties}">
                           <entry key="serialnumber"
    value="${build.number}" />
                            <entry key="membernumber"
    value="${member.number}" />
                            <entry key="name" value="${member.name}"
/>
                    </propertyfile>
                    <echo message="serial number: ${build.number}" />
            </target>
            <target name="jar" description="Compile serialized jar"
    depends="incserial,if_windows,if_linux">
                    <echo message="Using destination file ${jarfile}" />
                    <javac srcdir="src" destdir="bin"
    includeantruntime="false" />
                    <jar destfile="${jarfile}" basedir="bin"
    filesetmanifest="mergewithoutmain">
                            <manifest>
                                    <attribute name="Manifest-Version"
    value="1.0"/>
                                    <attribute name="Created-By"
    value="ant 1.9.2 on CentOS 7" />
                                    <attribute name="Main-Class"
    value="KCBSEvents.KCBSEvents" />
                            </manifest>
                            <fileset dir="${user.home}/.m2/repository"
/>
                            <zipfileset excludes="META-INF/*.SF"
    src="${user.home}/.m2/repository/commons-io/2.5/commons-io-2.5.jar"/>
                            <zipfileset excludes="META-INF/*.SF"
    src="${user.home}/.m2/repository/httpcomponents-client/httpclient-4.5.6.jar"/>
                            <zipfileset excludes="META-INF/*.SF"
    src="${user.home}/.m2/repository/httpcomponents-client/httpcore-4.4.10.jar"/>
                            <zipfileset excludes="META-INF/*.SF"
    src="${user.home}/.m2/repository/commons-logging/1.2/commons-logging-1.2.jar"/>
                            <zipfileset excludes="META-INF/*.SF"
    src="${user.home}/.m2/repository/commons-codec/1.10/commons-codec-1.10.jar"/>
                    </jar>
            </target>
    </project>

The zipfileset tags are seemingly being ignored and I don't know how it
knows to include the external jar (org.json.simple). Since this was
working I am guessing that something changed external to the ant script
but I don't know what or where to look. I don't know how the build path
that I see in Eclipse (which is correct and works) fits into all this.
I'm hoping someone can point me in the right direction. TIA.

Mime
View raw message