Importance of tools like Ant Maven - java

I am a novice programmer in Java.
I would like to know how important is it working on tools like maven/ant as compared to gaining a lot of hands on expereince in Java.

I would stick to first learning java. Tools like Ant and Maven are mostly used for packaging a project and library dependencies.
Both tools are also powered by Java so after learning abit of Java it will definately be easier to master them.
Basically when you feel like you need a solution for building your projects, it is time to have a look at Ant or Maven.
For myself I started using Ant when I got started with Hibernate, Maven came years later.

maven/ant could simplify some of your jobs. like building, dependency mgmt, deployment etc. And they are very important in real projects.
However, it only makes sense, if you know how to build/using libraries/deploy without those handy tools. If you have no idea about how to do them by hand, it's hard to use maven/ant correctly.
my 2 cents

You definitely need to know both (at some point in your career). Ant/Maven (Gradle anyone?) are indispensable for non-trivial projects, but you also need to know the details of how those tools are working.

Related

Is Maven suitable for a small Java project?

Being a beginner in Java SE development, I am quite interested in using Maven to manage and organize my project properly.
However, though I am more than willing to learn how to use it, I don't want to spend more time understanding Maven than actually coding. Yes, I know about Maven's perks and drawbacks, I am only worried about the learning curve.
This project will last 5 months, with a single developer — yet more people might have to maintain it later. I know larger projects are very successful with it, but is using Maven worth it in my case, or is it a waste of time?
Maven looks complicated at first, but it really is a huge time saver once you know the basics. Starting is not that hard, and the experience will be really useful for any other future java project of pretty much any size. I'd go for it. Do you have 5 minutes? ;)
I think that the time you will spend setting up Maven for a small project
bootstrapping the project
tweaking plugin options if needed ( java source / target etc )
adding dependencies
will be as small as or possibly smaller than setting up Ant for a small project.
Maven is especially simple when the projects are small and don't have special requirements, so your use case would fit it perfectly.
You do not need to learn much about maven to use it and in any case you will use some or the other build tool to build your project so why not maven.
Out of the box without any configuration maven does most of the standard things for you so you not need to go deeper.
If you use Eclipse then you can create new Project using maven via eclipse which will generate the default maven pom.xml for you.
As you need more features out of maven you can learn and use them.
Better off going ahead with Maven since the project might evolve with time sometimes and other developers who will work on it in the future will thank you for that :). Of course you can achieve the same with Ant+Ivy, yet in my opinon maven will be easy to set up and start running with miniml effort. Also you do not have to worry about dependent jars which will be transitivly bundled as required.
For a first timer, it could be really overwhelming. As mentioned in one of the comments, the most useful thing for your small project will be Dependency Management.
I would say it depends on the project you are undertaking. If you simply need to build a JAR or WAR you could in fact save a lot of time which would be needed to write say an ANT script. If you expect to tweak your build process too much, I would recommend of not using Maven.

Java build system with automatic dependency resolution

I am trying to get up to speed with Java after spending my last couple of years with Python and Perl. And boy is this hard! First of all, there's no easy to use build system that can do only what you want it to do without adding tons of boilerplate. Then, how to add dependencies to your project, how do you run junit tests from the build systems (say ant for example)? How can I make the build system download the dependencies on the fly (or can't I?)
Can I find some docs around that can get me up to speed with this without reading a couple of books ? I am trying to be "agile", but the comeback is hard.
Please feel free to close it if it is too subjective. Thanks!
This question is close to textbook trolling... anyway.
There are a lot of build systems that resolve dependencies for you out there (maven, ant, buildr, etc).
I'd say go with buildr since you are familiar with scripting languages.
NOTE
Though many people pointed out maven, considering your background (perl, python, etc) that will make you hate java even more (it's a sea of <XML> out there dude!). Please consider buildr if you feel frustrated enough
You don't mention which build systems you've tried (other than ant). I feel either Maven or Gradle would meet your needs (although I think Maven might fail your "tons of boilerplate" test; it certainly fails mine).
There are an awful lot of questions here. "Maven" is the Java build system that automatically downloads dependencies; it is based on Ant, which does everything else you ask about (running tests, etc).
If you want to use Maven, get started by using Maven's quickstart docs and examples.

Is there a tool pretty much like cmake for Java?

The best building tool for Java I know so far seems to be maven,
but it still doesn't give so much flexibility as cmake at all!
Anyone knows a cmake-alike tool for java?
Just for your your interest. I've developed Java support in CMake. It is available since version 2.8.6.
See also https://blog.cryptomilk.org/2011/01/15/cmake-java-support/
The best building tool for Java I know
so far seems to be maven, but it still
doesn't give so much flexibility as
cmake at all!
That might be true, but I'd ask if you really need that "flexibility". Part of maven's biggest value is that it standardizes development. The way source/resources, dependency are managed, well defined life-cycles etc. etc.
It is because of this standardization that you can hook up build servers, IDEs, automated test tools and many more tools easily. Also importantly, new developers find it easier to get familiar with the code base because they know what structure to expect.
Those benefits would be lost if you have a "flexible" build, however, are you really going to gain anything from having such a "flexible" build? A LOT of people are using maven, and for almost all problem they already created a solution. If you strive to use those standardized solutions, you'll have much less trouble with building IMHO.
Should you have the rare situation in which you truly need to do something that can't be done in a standardized way, you can still hook scripts/ant tasks etc into maven and even write custom plugins. But I really doubt you'd ever need to do that.
This probably is a better question for stacoverflow.com, but i would recommend Ant. It's very robust and flexible.
CMake has no concept of dependencies (only on dependencies of sources to object files or shared libraries) but not on the artifact level (like jar's in Java) or RPM's etc. I would call this a module dependencies. CMake does not has a concept of transitive dependencies etc.
CMake has no concept of defined structure of a project (Convention over configuration). CMake has no concept of a repository (like Maven has). CMake has no support of Unit/Integration tests integrated. No defined build life cycle. CMake has no concept of Release Management (which maven has) etc.
but it still doesn't give so much flexibility as cmake at all!
What exactly do you miss here in Maven?
Ant and maven are too great build tools. With maven, if you want to do custom builds, you are likely going to have to write your own maven plugin which isn't that hard. There is loads of documentation online to create your own plugin. The cool thing about making a maven plugin is that it is easy to share in an organization or with a team of developers; do share these plugins, you generally need to be hosting your own maven repo.
Ant is really quite flexible as it has a really extensive set of tags for doing just about anything including building, running tests, moving files around, checking out code from a repo, and even executing commands on a remote server. In my opinion, ant is a little easier to work with when you have to make custom builds. The problem with ant is that it is more difficult to make into a sharable module that you can share and configure like you can with a maven plugin.
Ivy is another popular build tool however, I have no experience with it.

What do you use for a complex build process? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am trying to revamp our build process, which is currently a gigantic Ant build.xml that calls into other ant build files and executes several Java classes to perform more complex logic that would be impossible/scary to attemp in Ant.
Background:
experience in Java and Ant, some Groovy
Windows platforms
Goals:
run as a combination of command line cron and when a servlet is posted to
as simplified as possible, fewest languages and bouncing between techs
I need higher level logical power that a language like Java provides and Ant is pretty easy and we use the filtering to override default properties files for different clients. Mostly I'm wondering if there is something other than Ant/Java that people use.
Except the Ant you mentioned and the scarry make/autotools, the mainstream tools are:
SCons
Jam
CMake
Maven
I use SCons, because it is python based, well-funded and elegant.
Jam seems to be the most pragmatic one.
I don't know too much about CMake.
Maven may be the choice for you as it is Java centric and more high level than Ant.
More you can find at wikipedia: List of built tools
If you pursue Maven, then you will have two problems: a complex build and learning the f#*#ing "magic" of Maven. Maven just makes the problem worse because it is obtuse and overly-complicated.
I inherited a legacy Maven 1.x build at a large Fortune 500 company. I used Maven 2.x by choice on many other projects in recent years. I evaluated Maestro, in hopes that it might make Maven tractable. My conclusion, like many other peoples' (check the 'net), is that Maven is a big step in the wrong direction. It definitely is not an improvement over Ant.
I have used Ant for MANY years, including writing a large open-source library of Ant helper scripts. I have also extensively used its .NET cousin nAnt. However, Ant has two major failings. One, XML is simply not the right place to be doing build tasks. Two, Ant and XML do not scale well to large, complex builds. In fact, I have written a lot here at SO about my experiences in that arena (and with Maven).
Industry leaders have concluded that a build is just another application, and should be approached using general application tools. However, since it involves system-level and cross-platform functionality, most development languages/platforms are not properly suited (which includes Java, and therefore Ant and Maven). That also excludes .NET.
I spent two years looking for an alternative, and I found it: Python. It has the right combination of system-level access, cross-platform portability, simplicity, readability, power, robustness, and maturity. SCons, buildbot, setuptools/easyinstall, and base Python are my current target platform for the build process. When necessary, integration with Ant, Maven, and any other such tool is easy. Meanwhile, I can use these tools for the core of any build on any platform with any source language. No more roadblocks, no more crazy complexity, no more supposedly-helpful "declarative" scripting, no more black-box f#*#ing "magic".
If you can't switch to Python, then try Ant + Ivy (at apache.org). It gives you Maven's cool repository without most of Maven's evils. That is what I am doing as well, where necessary and suitable.
Best wishes.
Also take a look at
Gant
Gradle
While more general purpose build systems like SCons are very powerful, the Java support is somewhat limited in comparison to systems specially tailored to build Java projects.
I like using Rake as you can fall back on the power of the whole Ruby language and it's framework library when needed.
I use Ant, taking advantage of its macro feature. If you layout your project in a consistent mannner, you can eliminate a lot of the duplication by writing macros.
I've been building up an Antlib containing macros and custom tasks that I reuse across multiple projects.
Alternatively, some people swear by Maven. Other people just swear about Maven.
I use Maven, not just for build, I also use their release/dist plugin.
In a pair of commands I can have code that was in a source control to build, package and release.
The release plugin handles updating the version numbers, dist handles how to put everything together and zip it.
Ant looks hard when compared to Maven. Sure there is a learning curve with Maven, but reading a pom.xml is far easier than reading a build.xml.
Maven needs to be far less verbose.
I like Ant but only if you spend the time to write your own Java plugins to encapsulate complex actions. It isn't hard but unfortunately most people try to write their logic in XML w/the ant-contrib stuff. I think this is a huge mistake.
I've heard good things about rake and the groovy tools (mentioned in another comment) but I've got no experience with them.
If you're trying to script together several steps in a life-cycle you might be better off using a process automation based build server like AnthillPro (Cruise, BuildForge and Electric-Commander are the others in this space).
Another place to ask this kind of question is the CITCON mailing list. CITCON is a conference on Continuous Integration and Testing and the associated mailing list has turned into a really great community around these kinds of topics.
(I'm an organizer for CITCON but a labor of love not a profit maker. It really does have a really helpful mailing list. If I was pimping something for money it would be The CI Guys. ;-) )
Stick with Ant since you're building Java. I've mixed Ant/SCons for some JNI work, but in general I'd stay with Ant especially since you've got an existing build setup in Ant. Porting to Maven will be like shoving a square peg through a wall with no holes.
Embrace your custom Java logic for any and consider writing proper Ant tasks instead of executing external Java code. I solved some very complex parts of our build process by simply extending Ant to do exactly what I needed, ex. managing icon resources for a large gui project or injected subversion information directly info jar manifests (thank you SVNKit)
I'd go with Ant any day of the week.
It's not perfect; XML is very verbose and implementing any logic at all is almost impossible, but even the most junior engineer on the team can at least understand what the ant file is doing within a day.
Complex logic can be refactored using java and integrated in ant, if you so wish. Ant gives you all the power of java:)
Dependency resolution is difficult no matter what system you use. With ant, the best solutions seem to be either a lib directory in which all your jars are stored, or an internal web server from which the libraries are copied at build time.
I also have some experience with both Maven 1 and Maven 2. That experience left me with the feeling that Maven is awesome for hobby projects, but can have complications for software you need to maintain over time.
I see two important problems with Maven:
Any dependency you import using Maven may change over time without you knowing it, resulting in weird problems.
You import the licenses of not only the software you import directly using Maven, but also the licenses used by the libraries which are indirectly imported
In short, I dislike the fact that the build depends on the time it is started. That can be a true problem when producing a bugfix release a year after the production release.
These problems can of course be managed (maybe using a nexus proxy) but you need to consider them before rebuilding the build system. At my company we decided to use Ant for all new project and try to port maven 1 and 2 to ant whenever the occasion presents itself. It's just too difficult to keep it working.
My advice, if you and your team know how to deal with ant, try to refactor your ant file and don't jump on some other build tool. It just takes too much time to get it right; time you could spend making money and surviving as a company :)
I use Rake everywhere I can. Where you need to build java code you might use it with jruby, or look at something like: buildr
We use luntbuild. It's a web app that's very easy to use. It will check out from CVS/SVN, automatically increment the version/build number, execute build tasks in ant scripts and tag your repository with the new version. Can schedule automatic builds, have it email you or contact you via IM, also has security and build dependencies.
We're still using version 1.2.3 but I see it's up to 1.6.0. It just works.
http://luntbuild.javaforge.com/
EDIT: Re-reading your question I see now that you're looking for something to replace Ant. In our case Ant is not really a problem. We have projects setup in Netbeans, which uses Ant for building and we just have to implement some hooks into the existing scripts provided by Netbeans which is very easy to do.
EDIT: Looks like you can call Ant from Groovy. That would be nice because then you can re-use all the tasks that already exist for Ant.
http://groovy.codehaus.org/Using+Ant+from+Groovy
Try FinalBuilder
It provides a GUI interface to whatever your build process may be and has a native action for almost everything, plus an action studio where you can create your own.
With a bit of planning can be very streamlined.
I have to add to these one solution that I find I can't live without ... its called Hudson. It only takes a few seconds to setup and you can usually get away with most of whatever your existing ANT files are already doing.
Additionally, Hudson provides a great way to "cron" builds, execute test cases, and generate "artifacts" (e.g. build products) in a way that anyone can download.
It is hard to capture all that it can do for you ... so just try it out ... you will no be disappointed.
Maven is really good choice to do large builds...in the majority of the cases where it doesn't work is very simple. The people misunderstand the concepts of Maven. If your are working with the "maven way" you will end up with smaller modules which gives you a better architecture in your software. On the other hand things like Hudson will support you in reducing build times by using Maven, cause Hudson supports to build only changed modules which is not supported by any other build tool. The problem with Maven is to learn and understand the concepts of Maven for example the structure of a project(folders etc.) or only a single artifact etc. The build-cycle will support you in different areas: compiling, packaging, deployment and release which is not supported by other tools (only if you implement it by hand...I've wrote many large Ant scripts to reach this)...Other problem like changes over the time are caused by ignoring the best practice and pin pointing versions which are used.
I use mainly Ant, but Maven is also a good tool. With ant you can do anything you want.
At our company, we created a general purpose ant builder that does a lot of things: Build, Compess images, minify, generate documentation, pack files.. It is open source and we are open to improvements. You can get it here:
https://github.com/edertone/TurboBuilder

Is Ant still the best choice for a Java build tool? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
From my small amount of experience, I've only used Ant as a build tool. Are there any other projects which are better, and why?
Maven
It is much better than ant because for most common tasks you don't have to write a complicated build.xml, maven has very good defaults and it's all convention over configuration.
It has also a big central repository of libraries and it's very easy to configure it to, like, "use latest stable commons-whatever". Maven will then download the latest stable version for you (no more checking in jars into VCS) and if a new upstream stable version is released, it will download it as well. Of course, it's just as easy to lock it to some specific version should you need that.
It is also well integrated both with Netbeans and Eclipse (m2eclipse plugin) so the IDE honors whatever settings (including dependencies) you declare in the pom.xml file.
There are also some downsides to maven: some plugins are rather poorly documented, integration with both IDEs is not really perfect, and that in different ways, some error messages may be hard to understand.
Ant is still a major player. In my experience, it is dominant. Plus, with Ivy, it handles some of Maven's strengths. IMO, Ant will become a framework for other tools: XML is too rigid (see link below).
Maven 2 is also a major player. I know people who quite like it and bristle at criticisms that were true for Maven 1 (it has come a long way).
Groovy is offering some cool stuff in the build space, because they build on Ant. Gant is used in Grails, but may be subsumed into Gradle. These can be used for Java as well.
At the risk of pimping my own blog, here is a post about Gant and Gradle. Here is a link to the very current debate about their future.
in the enterprise, ant is still the entrenches player. dependencies don't change fast. unlike open source projects that keep moving to fairly newest version of dependent jars, MOST enterprises try NOT to change their dependencies too fast. Given that, maven's advantages are NOT too much compared to ant.
Then again, if you want some of maven's features, ant folks have ivy (http://ant.apache.org/ivy/) for the dependencies feature.
IF you want to continue using ant, get hold of "ANT IN ACTION", 2nd edition so that you can use ant to the best productivity.
Good luck,
Some people like Ivy, which is a dependency managing thingy for Ant so I suppose that people coming from an Ant background will like it.
Others like Buildr. It's a JRuby thing, so if you can juggle Ruby and Java in the same projects, then I suppose it'll be interesting.
Personally, I just use Maven. It's easy to whip up a default pom.xml file and have all the build commands at your disposal. And when the project grows, you already have the infrastructure in place for running plugins and adding dependencies.
You also have Gant. Gant is Groovy + Ant, you can write your tasks in plain groovy and you can also call any ant task. If you are a Java shop and want to reuse the ant skills you have but dislike XML, I recommend Gant, it is ver easy to setup and you can embed it in ant (and also call gant from ant).
I really like SCons, which is a build tool whose configuration files are all just Python scripts. This will appeal to anyone who knows Python or similar scripting languages. SCons is designed to work well with Java as well as C/C++ and other languages, and I've been very satisfied with it in the past.
Because SCons files are written in Python, you can write arbitrary Python code if you find yourself needing to do anything special. However, if you're completely unfamiliar with Python, then there will possibly be a higher learning curve than trying to extend Ant or something similar to do what you want.
Maven2 seems to be the up and coming thing.
For our projects however we are migrating back to ant wherever feasible.
Maven2 requires quite a bit of knowledge to get it exactly the way you want, and Maven2 versions seem to handle classpaths differently.
And it is a pain to check all licenses included in the dependencies of the dependencies which may get drawn in.
And may have a slower start-up time, as you need to figure out the dependencies yourself, but at least it's easily readable. No magic going on here :)
If you do use maven, give a thought to an internal repository like Nexus. That way your software is not dead if some libraries decide to go away from the net*.
*We got burned with maven1; the ibiblio maven1 repository redirects and maven1 does not support redirects :(
I would urge you to start with your requirements when considering the right tool. Each project is different, the tool you use should reflect the problem space not the fashion.
That being said, I think for general use ant is still probably the best general tool for building java applications. It is often used effectively with other tools for dependency management but there we go again skirting off into a solution without a problem.
The very good news, is that if your process are good switching build tools is a fairly painless process - lesson - start with a good process scaled to the problem at hand.
You will find already some answers in What are some good java make utilities?.

Categories