Tim Moores wrote:You have been around the Ranch long enough to know not to post screenshots of error messages. In the future, copy the text and post it directly. That's much easier to read, and can be quoted and copied.
The error message is really quite obvious: The build file is referring to a directory that does not exist. And indeed, the directory mentioned in the error message does not exist according to the screenshot of your file system. We can't say where your build file goes wrong, but apparently "${src.dir}" is set incorrectly.
https://stackoverflow.com/questions/22615107/apache-ant-compile-javac-srcdir-does-not-exist
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:Oh, and properties files are very simple. They are just text file with name/value pairs in them. So things like this:
Note that Unix-style comments ("#") are supported and blank lines are ignored.
tangara goh wrote:I hope you could tell me how to specify the build directory.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:I think you're getting Ant and Maven confused here.
In Maven, you'd put your properties file under the project's /src/main/resources directory (or /src/main/webapp/WEB-INF/classes/ if you're building a WAR). You can also keep testing properties under /src/test/resources and so forth.
In Maven, the target is built into a directory named /target, which is created when you build if it doesn't exist and which is deleted when you do a Maven "clean".
In Ant, however, the only rules are the ones you make yourself. You can build anywhere you like in any way you like and where the sources are is also up to you to specify. Ant has no defaults or preferred locations or values.
C:\Users\xxx\ant\tutorial_firststeps_jar\src\firststeps
jar:
[jar] Building jar: C:\Users\karen\ant\tutorial_firststeps_jar\src\firststeps\build\jar\HelloWorld.jar
run:
[java] Error: Could not find or load main class firststeps.HelloWorld1
[java] Caused by: java.lang.ClassNotFoundException: firststeps.HelloWorld1
[java] Java Result: 1
Tim Moores wrote:Have you set the classpath to include that class? Remember that we haven't seen your build file, so we can only speculate what's going on.
tangara goh wrote:I am not getting the concept of Ant
I can't make sense of the aboe. Is mkdir dir = "build" a instructional step to Ant that makes Ant change the directory to build before building things which is linked to the next task - declare ?
I also dun get the part about javac srcdir="source" but there is no indication whereabout is the source so how on earth will Ant know?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:That example isn't the simplest example though. The first target is - create the build directory if it doesn't exist yet, then compile all files in the source directory and place them in the build directory. The other tasks are for using your own tasks, but that's something I would stay away from for now. First get to know the basics before you start extending Ant.
C:\Users\abc\ant\test_ant2>ant run
Buildfile: C:\Users\abc\ant\test_ant2\build.xml
run:
[java] Error: Could not find or load main class oata.HelloWorld
[java] Caused by: java.lang.ClassNotFoundException: oata.HelloWorld
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 0 seconds
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:Ant is basically just a programming language done in XML. Targets are goals that you can request and tasks are the instructions.
Ant comes pre-supplied with a set of standard tasks that you can use. You can also create custom task types of your own, but that should not be necessary here.
So the mkdir task makes a directory. The javac task runs the Java compiler. The jar task takes files and makes a JAR file out of them. And so forth.
Tim Moores wrote:As was mentioned before, Ant is flexible about where stuff is. You can just adapt the build file to point to where your source code is, rather than having to put it where the build tool expects it (as Maven would require). That's what the srcdir parameter is for.
At this point I need to ask: if Ant is giving you such headaches, why are you using it? Why aren't you building this project in whichever way you build all your other projects? Surely the customer doesn't care how you do it.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Driven Development | Test until the fear goes away
Tim Holloway wrote:Ant is only "old technology" in terms of age.
https://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:Ant allows you to define "variables" in order to make the project more flexible. They are defined within project files using the "properties" elements, as well as in various other ways (including via -D definitions on the Ant command line). They're not actually variables, because once the value is set, it cannot be changed and there are rules that determine which definition has precedence if the same property is defined more .
Why is the word "abbreviation" so long? And this ad is so short?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|