Ant: placing classes in the classpath but not visible

I am trying to configure Ant to run my tests, but my tests will not compile. The error is that it cannot find the classes that I am testing, although I put them in the classpath. I even issue a classpath, and they are on it.

Ant:

<target name="compile"> <echo>compiling code</echo> <javac debug="true" srcdir="${src}" destdir="${build}" classpathref="build.path" /> <echo>compiling tests</echo> <echo message="${toString:build.test.path}" /> <javac debug="true" srcdir="${test}" destdir="${build.test}" classpathref="build.test.path" /> </target> <path id="build.test.path"> <fileset dir="${build}"> <include name="**/*.class"/> </fileset> <fileset dir="${install}"> <include name="junit-4.11.jar"/> </fileset> </path> 

This is the console output:

 compile: [echo] compiling code [javac] C:\PetProjects\timesheet\build.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 2 source files to C:\PetProjects\timesheet\build [echo] [echo] [echo] compiling tests [echo] [echo] [echo] C:\PetProjects\timesheet\build\com\me\timesheet\exceptions\BadBlockException.class;C:\PetProjects\timesheet\build\com\me\timesheet\pojo\Block.class;C:\Installations\junit-4.11.jar [echo] [echo] [javac] C:\PetProjects\timesheet\build.xml:47: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to C:\PetProjects\timesheet\build-test [javac] C:\PetProjects\timesheet\test\com\me\timesheet\pojo\BlockTest.java:9: cannot find symbol [javac] symbol : class Block [javac] location: package com.me.timesheet.pojo [javac] import com.me.timesheet.pojo.Block; [javac] ^ [javac] C:\PetProjects\timesheet\test\com\me\timesheet\pojo\BlockTest.java:11: package com.me.timesheet.exceptions does not exist [javac] import com.me.timesheet.exceptions.BadBlockException; 
+4
source share
1 answer

You need to put the C:\PetProjects\timesheet\build in the classpath, not the individual classes. Therefore, when the code refers to com.me.timesheet.pojo.Block , the class is located on the path C:\PetProjects\timesheet\build\com\me\timesheet\pojo\Block.class

+2
source

Source: https://habr.com/ru/post/1412891/


All Articles