I need to automate packing of Java EE projects into EAR archive in Eclipse. The most easy way, I think, is using Ant script. But writing of Ant from start is routine and long task. Is there a way to generate Ant script based on my actions in eclipse (like macros in MS Office)?
Or, maybe, exists easier way to do this?
Thanks!
There is nothing I know of that will generate an Ant build file for you. I don't think it is that difficult or long to create an Ant build file. If you have never done it before there is obviously a learning curve to it.
What I think you might be asking is can you have a build file that uses the same build configuration as your Eclipse project so that you don't have to setup your classpaths yourself then the answer is yes. I have never done this myself but I see this link seems to be offering that:
ant4eclipse
Just another thought... You can use Maven instead of Ant. using Maven you can specify packaging type and you don't need to write ant script. This will also lead to simplified build management of your app application.
But writing of Ant from start is
routine and long task.
Ridiculous. It's not a long task. And yes, it is routine. Do it once and forget it.
Laziness is a good trait for a programmer, but this is going too far.
Related
I have a simple pre-processing step that infrequently needs to be performed on some resources in a Maven/Eclipse project, this involves a simple OS command using a utility executable, for example:
glslc triangle.frag -o spv.triangle.frag
The glslc executable processes the triangle.frag shader module and generates the spv.triangle.frag output file (in the same directory).
Ideally I would like a maven goal that performed the above for all modified .frag files within a given directory structure, rather than having to switch to a terminal, or create shell scripts, etc.
I assume an ANT plugin for Maven is the way to go (assuming that's the simplest and most common mechanism available). I have tried adding a maven antrun plugin but I'm struggling to work out how to configure it for multiple/modified files. I'm sure it's relatively straight-forward but it's been a long time since I've had to fiddle with ANT and I'm at a bit of a loss where to start. Had a look online but can't find any decent examples or tutorials, probably because I'm not searching for the right things.
Note that the files do not change that much but it would be very convenient to have a quick-and-dirty (or hot-deploy) means of generating the output file file(s) that have changed.
Also note that these resources do not need to be part of the maven build/deploy process, i.e. they are only used during development and testing.
Alternatively is there an equivalent Eclipse mechanism that that can be used to do the same thing? Again this is a convenience so something relatively 'manual' is fine.
I'm looking for any pointers to relevant examples, tutorials, repos, etc. as a starting point or hint from which I can then implement a solution.
I do not understand the purpose of ant. I read the introduction, but am missing the big picture. I know the following (or at least that I want to use them),
Java
jdbc
hibernate
jsp
servlet container like Tomcat
But I don't see how ant fits in.
Is there some all comprehensive tutorial that tells me how to put all this together?
Why would I want ant? What is the alternative if I don't have ant?
EDIT: So is this sort of the compiling part of its Visual Studio counterpart?
Ant is used as a build system. You do not have to use it--in fact there are quite a few better systems but since ant was one of the first it's still likely to be very common. It generally is used to compile your java files, create wars and often even put the .war files onto the tomcats.
Maven is bigger and tries to do a lot more, but it's also rather strict in it's format and quite heavy--but it's quite common these days as well. Maven can gather all your dependencies automatically which is nice, with ant you still have to download everything yourself.
There are others, but you get the idea.
Response to comment:
I don't use visual studio, but I think it is more limited. For instance, Eclipse can build all your java files into a jar or execute them directly (in fact, it uses ant internally). If you wanted to take your visual stuido "Build configuration" and put it into another tool (Perhaps an automated build system like Jenkins) that doesn't rely on visual studio directly, can you do so?
I guess Ant is the way we code our builds--it's portable betweeen many tools. Visual Studio would be cleaner to "create" your build, but "Exporting" the ability to build would be more difficult (if even possible).
Also ant is portable across operating systems as well as tools. We can switch from Eclipse to Netbeans to IntelliJ without touching our build toolchain.
How would you completely remove visual studio and replace it with slickedit, emacs or vi (if that was your thing, which I'm sure it's not) without starting over from scratch with your build?
For any web application to work you need to package or build all your java code with all the libraries into an web application archive to accomplish this task we need to some tool or library to package into the correct format and some of the libraries which can achieve this is
Apache Ant and Apache Maven
There some good discussions about Ant vs Maven in SO.
You need ant to build the project. Well you can build project using IDE like eclipse etc. But for production purpose and big projects, it always advisable to some build script like ant. Its a script where you can customize what you want to build and what not. you can define what is the output should be like war/jar/ear etc
Other alternative is Maven which is very prevalent and standard now a days
I am relatively new to Eclipse and Java and have a number of tasks I would like to script when I am going to do a software release. They include running JAXB to generate source from an XSD, running javadoc to update the documentation and creating jars for distribution. What is the best way of scripting these tasks...Ant? I need the scripts to be called from our nightly build environment which is CrusieControl.net. We use both C# and Java in house but we have a single build environment on CruiseControl.net
Thanks for any help you can give.
Take a look at here :
How to execute the JAXB compiler from ANT
Javadoc task
Run ant from cc.net
I'll say go for it. We have a similar environment without java, but with tones of tools. Ant is a very useful weapon in your arsenal.
I am starting my first project with MySQL and Java in Eclipse. I found a tutorial:
http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html
It is full of ant builds and XML files which make me want to explode. Do I really need to use ant builds or can I just import the MySQL driver into my project and import the libraries into the class and away I go? MySQL is already setup.
If you are a beginner and just want to learn some Java and MySQL, then Ant is not required. If you are building a project for some class or project. Then Ant is something that you should use. Ant automates your manual steps like compiling and packaging which will become a overhead over a period of time. Ant just manages your build process.
If you are not into build and stuff then happily skip ant. Just add the mysql connector Jar to your classpath and you are good to go.
You don't need Ant for development, Eclipse can build your projects just fine.
Once (if) you get into build automation, take a look at Ant again. Before that, you can safely ignore it (as long as you still know how to follow the steps in your tutorial).
Ant is not required for Development, with help of eclipse can build your projects.
I am working on an Java assignment for a software design course in my university. It's not really complicated and it includes some classes, interfaces and jUnit test cases. We were now told we should supply a build.xml file as an input for an ant builder. I have never heard of, or used ant before. I also saw Eclipse supports it.
My questions are - What does build.xml do? How does Eclipse builds my project and why not do the same instead of using ant? And most important - how to create this file with Eclipse?
Thanks.
Ant is a build tool based on Java. It is very powerful, and integrates with various other tools you might need to build any imaginable Java application. It is very useful when deploying a Continunous Integration environment with a Continuous Build server.
You are building within Eclipse, and your build process is bound to your IDE - which is perfectly fine for a one-man project but might prove unefficient for a team project. Also, with Ant, you can have a complex build including multiple components and intricate dependencies done in a single step, including unit tests.
You can either create your Ant build from scratch (which is the best way, but it takes quite a while). Otherwise, you can create it with Eclipse using the File/Export menu (under General, select Ant buildfiles).
You should definitely know how to crate a build.xml file from scratch, just so you know what Eclipse does behind the scenes.
I taught a Java class a while ago where I explained the basics of ant.