Re: Javac Run By Ant Script is Unable to Find External Jars

Dennis Putnam <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <[email protected]>
Hi Matt,

Thanks for that information. Since this used to work I guess somewhere
along the line I must have deleted that classpath info. I will give this
a try. In the mean time does this mean I don't need the zipfileset
elements if I include those jars in the path element? Or do I still need
both because they are Maven dependencies?

On 2/17/2019 12:45 PM, Matt Bertolini wrote:
> Hi Dennis,
>
> I think you might be mixing up Eclipse concepts and Ant concepts and that
> might be causing some extra confusion. Based on your original email, the
> compiler is having issues finding your third-party dependencies. I believe
> Jaikiran is correct in saying that the <javac> task needs to be given some
> sort of classpath. The .classpath file is an Eclipse concept and unless
> there is some sort of Eclipse/Ant plugin I am not aware of, the .classpath
> file will have no effect on Ant’s, <javac> task. Also, I don’t believe the
> <javac> task has a default value for the classpath attribute. If no
> classpath or classpathref is specified then the compiler is not passed any
> classpath information.
>
> I would start by locating the folder where your third-party dependencies
> are and create a <path> element containing them like this:
>
> <path id="compile-classpath">
>     <fileset dir="/the/path/to/your/third/party/jars"/>
> </path>
>
> Once you have a path defined you can pass the classpath to the <javac> task
> using a refid like this:
>
> <javac srcdir="src" destdir="bin" includeantruntime="false"
> classpathref="compile-classpath"/>
>
> Try that and see how it goes.
>
> Matt Bertolini
>
> On Sun, Feb 17, 2019 at 10:02 AM Dennis Putnam <[email protected]> wrote:
>
>> I apologize for being a pest but this is a problem I cannot resolve on my
>> own. The more I read the more confusing it gets. It seems like there are
>> thousands of ways to accomplish what I want but none make any more sense
>> than what I have. Is there no one that can help me debug this problem or at
>> least point me in the right direction?
>>
>> On 2/14/2019 9:42 AM, Dennis Putnam wrote:
>>
>> Hi Jaikiran,
>>
>> Thanks for the reply. I thought the classpath parameter defaulted to
>> "basedir"/.classpath. In any case I made the following change:
>>
>> <javac srcdir="src" destdir="bin" includeantruntime="false" classpath=".classpath" />
>>
>>
>> Unfortunately that didn't help. The ant output is exactly the same. FWIW
>> here is .classpath:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <classpath>
>>         <classpathentry including="**/*.java" kind="src"
>> output="target/classes" path="src">
>>                 <attributes>
>>                         <attribute name="optional" value="true"/>
>>                         <attribute name="maven.pomderived" value="true"/>
>>                 </attributes>
>>         </classpathentry>
>>         <classpathentry kind="con"
>> path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
>>                 <attributes>
>>                         <attribute name="maven.pomderived" value="true"/>
>>                 </attributes>
>>         </classpathentry>
>>         <classpathentry kind="lib"
>> path="/lib/java-ext/json-simple-1.1.1/json-simple-1.1.1.jar"/>
>>         <classpathentry kind="con"
>> path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
>>                 <attributes>
>>                         <attribute name="maven.pomderived" value="true"/>
>>                 </attributes>
>>         </classpathentry>
>>         <classpathentry kind="output" path="target/classes"/>
>>
>> The "lib" path is correct. I am guessing that the next tag essentially
>> points the pom.xml so here it is in case it matters:
>>
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> <http://maven.apache.org/POM/4.0.0> xmlns:xsi=
>> "http://www.w3.org/2001/XMLSchema-instance"
>> <http://www.w3.org/2001/XMLSchema-instance> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/xsd/maven-4.0.0.xsd"
>> <http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd>
>>   <modelVersion>4.0.0</modelVersion>
>>   <groupId>KCBSEvents</groupId>
>>   <artifactId>KCBSEvents</artifactId>
>>   <version>0.0.1-SNAPSHOT</version>
>>   <build>
>>     <sourceDirectory>src</sourceDirectory>
>>     <resources>
>>       <resource>
>>         <directory>src</directory>
>>         <excludes>
>>           <exclude>**/*.java</exclude>
>>         </excludes>
>>       </resource>
>>     </resources>
>>     <plugins>
>>       <plugin>
>>         <artifactId>maven-compiler-plugin</artifactId>
>>         <version>3.7.0</version>
>>         <configuration>
>>           <source>1.7</source>
>>           <target>1.7</target>
>>         </configuration>
>>       </plugin>
>>     </plugins>
>>   </build>
>>    <dependencies>
>>         <dependency>
>>                 <groupId>org.apache.httpcomponents</groupId>
>>                 <artifactId>httpclient</artifactId>
>>                 <version>4.5.6</version>
>>         </dependency>
>>         <dependency>
>>                 <groupId>commons-io</groupId>
>>                 <artifactId>commons-io</artifactId>
>>                 <version>2.5</version>
>>         </dependency>
>>         <dependency>
>>                 <groupId>org.apache.httpcomponents</groupId>
>>                 <artifactId>httpcore</artifactId>
>>                 <version>4.4.10</version>
>>         </dependency>
>>         <dependency>
>>                 <groupId>commons-codec</groupId>
>>                 <artifactId>commons-codec</artifactId>
>>                 <version>1.10</version>
>>         </dependency>
>>         <dependency>
>>                 <groupId>commons-logging</groupId>
>>                 <artifactId>commons-logging</artifactId>
>>                 <version>1.2</version>
>>         </dependency>
>>    </dependencies>
>>
>> Presumably the maven libraries are found from the zipfilesets in the ant
>> script.
>>
>> On 2/14/2019 8:55 AM, Jaikiran Pai wrote:
>>
>> Hi Dennis,
>>
>> On 13/02/19 11:56 PM, Dennis Putnam wrote:
>>
>> <javac srcdir="src" destdir="bin" includeantruntime="false" />
>>
>> I don't see any classpath being passed to the javac task in your build
>> script. You should be passing a classpath containing your jars that are
>> required to compile the source. There's more than one way to do that.
>> The javac task manual has more details about ithttps://ant.apache.org/manual/Tasks/javac.html
>>
>>
>> -Jaikiran
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>>
signature.asc (application/pgp-signature, 196 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iEYEARECAAYFAlxqs8kACgkQ/fiWYqZ2tVSzWwCdFbNjGYq7fH8onMH+gXfTtryt
BXkAn35Q2vNgXCk6NYz6gHE2A4D9MBak
=1WsQ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.