1

I'm working on a Java project for which I need a very specific testing code, which I create in Jasmin, the JVM assembly. The project is built with Ant and has a nice directory structure, namely:

root
  /src
    /classes
    /tests
  /build
    /classes
    /tests

The tailor-made Jasmin source file is in the src/tests directory, together with the JUnit Java files. All of these get built with Ant (I use the simple "java" Ant task to run the Jasmin compiler on the source file), they're put into respective directories inside the /build folder, and Ant then runs the JUnit tasks. All of this works fine...

Until I introduced the single Jasmin-generated class, Eclipse worked perfectly with the project. The problem is that Eclipse doesn't see the new .class file. The Build Path contains src/classes and src/tests as source folders, and /build as an output folder. Yet it doesn't seem to be able to find the class generated by Jasmin, so there are hundreds of "ClassX unresolved" problems and it really makes developing quite painful.

Does anyone have an idea how to force Eclipse to see this class?

david.brazdil
  • 133
  • 1
  • 1
  • 4

1 Answers1

0

A simple solution would be to compile Jasmin classes into a separate class folder and then add that folder into Eclipse's build path: Project Properties / Java Build Path / Libraries / Add Class Folder...

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
  • Well, that's exactly what I do. Ant builds the Jasmin source file into /build/tests, and /build is already in Eclipse's Build Path, so when I press "Add Class Folder" it doesn't even let me pick any of the subdirectories of /build. – david.brazdil Jun 23 '12 at 20:07
  • You can not use a subfolder of another build folder in Eclips build path. Like I said, use a separate folder. – Eugene Kuleshov Jun 23 '12 at 23:44
  • Man, I probably don't get what you mean. I moved the Jasmin file into src/assembly and changed Ant configuration to put the respective class file into build/assembly, and changed classpath of tests accordingly. Then I added a new Source Folder to Build Path of Eclipse: ``. Still nothing... – david.brazdil Jun 24 '12 at 11:25
  • Oh, you mean to put it outside /build completely! But that's just ugly... isn't there a way around? Surely Eclipse has to be a bit more clever than that. – david.brazdil Jun 24 '12 at 12:48
  • You should just follow the instructions I've posted instead of manually editing .classpath file. But if you want to do that, use (replace {project name} with your actual project). With this it should be enough to refresh Eclipse project after running your Ant build. – Eugene Kuleshov Jun 24 '12 at 14:15
  • Thanks, it works now. The problem was that Eclipse wouldn't allow me to add the build/assembly folder to Build Path from GUI. /build is set to be the output folder and Eclipse doesn't even show it in the folder structure when you hit Add Class Folder. Adding it directly into the .classpath file works though... – david.brazdil Jun 25 '12 at 09:23
  • Your question was referring to /build/classes as an output folder. You should be more specific. Besides, I've pointed out to you that you can't and don't need to use nested folders for your build output. – Eugene Kuleshov Jun 27 '12 at 14:25
  • Don't want to be disrespectful, but I specifically mentioned that /build is my output folder... thanks anyway... – david.brazdil Jun 27 '12 at 17:44