• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Maven or Ant?

 
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm at that stage where I need a build tool that
1.  let me collaborate with others (something like git, which feels...clunky)
2.  manage dependencies and versions
3. take care of the whole build process for me

What's popular and easy to learn and use, no steep learning curve, Maven or Ant?
 
Saloon Keeper
Posts: 13367
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use Maven as your dependency manager and build tool, and use Git as your version control system. I will not take you seriously as a Java developer unless you know these two.
 
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ant can't manage dependencies for you. A better question would be "Maven or Gradle?". I haven't really used Gradle so I can't answer that question for you.
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Ant can't manage dependencies for you. A better question would be "Maven or Gradle?". I haven't really used Gradle so I can't answer that question for you.


Isn't Gradle only for Android... I did some work with it
 
Rob Spoor
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stephan is mostly right about Git. There are other alternatives, but Git appears to be the most widely used. Even OpenJDK switched from Mercurial to Git (which I found a good thing, I hated having to work with Mercurial).

For people that can't get used to the CLI, I recommend SourceTree. I don't use it myself (CLI all the way!), but a lot of colleagues are happy to use it.
 
Rob Spoor
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

AhFai Chan wrote:

Rob Spoor wrote:Ant can't manage dependencies for you. A better question would be "Maven or Gradle?". I haven't really used Gradle so I can't answer that question for you.


Isn't Gradle only for Android... I did some work with it


It's used mostly for Android, but you can use it for non-Android projects as well. From what I just saw, you can even use it for non-Java projects.
 
Stephan van Hulst
Saloon Keeper
Posts: 13367
295
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, Gradle can be used instead of Maven on any platform.

I believe Gradle made some improvements to dependency management with regards to Maven, but it's not nearly as widely used as Maven. When you're looking for help in getting some of your build plugins to work, it's probably easier to find resources that target Maven.
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the inputs and sharing, my software ecosphere is coming together.

Sorry if the following question seems unrelated to the subject title, but it is a collection of interacting software that I am dealing with

I have evaluated JSTL using MVC + CSS + mySQL and Tomcat -vs- Spring.
Spring doesn't use HTML or CSS, it's attractive inasmuch that it seems more straightforward and simpler but lacks the sophistication of JSTL + CSS and MVC which is very powerful.

For a dynamic web project with thick server and thin client, which combination would you use? Must scale well.
 
Rob Spoor
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring can do JSTL + CSS as well, and it can definitely do MVC; there's a module called "spring-webmvc" after all. However, to get JSP + JSTL working you need to do some configuration. The default is Thymeleaf, and with it you can do just about the same as with JSP + JSTL but in a slightly different way. CSS is really easy to get working; just put it in src/main/resources/static or src/main/resources/public, as everything in those folders is directly accessible as static content relative to the context path (so src/main/resources/static/style.css is available as http://localhost:8080/style.css out-of-the-box, as there is no context path out-of-the-box).
 
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Back to the original topic:

Ant cannot deal with dependencies itself, but Ivy can give that ability to Ant. That said, the upside to Ant is that you can build complex build systems in any way you like. The downside to Ant is that the complex build systems can be in any way you like (see below!)

Maven is best known for its dependency management, but one of its other prime virtues is that the build systems need to be in the way that Maven likes. Maven projects have standard organization. You always know where to find things and those things are going to be within the project, not at some random location in the original author's file systems (passing Ant projects back and forth in an Enterprise was a real mess for me, since entire departments structured their filesystems differently). You can collapse a project down to its bare minimum with a single "clean" command, ship it around the world, and rebuild the whole thing somewhere else with only the Java compiler and Maven itself for pre-supplied resources.

That said, I didn't like Maven's restrictions and I didn't like Maven's "magic" - In Ant you know exactly what the process steps are and what they do. In Maven you just request one or more goals. And there's really no easy way I know of to even know what the valid goals are, much less what they do. Would you expect that a random Maven project could be importable by the Eclipse IDE just by running the goal "eclipse:eclipse"?

So it took some time, but Maven has become my build system of choice, as it is for many open-source and other Java projects.

Gradle is less familiar to me. As I understand it, it's more flexible than Maven in how it can build things (note: you can add build features to both Ant and Maven and both implement those features as JavaBeans). But the biggest advantage is probably that you can build a project that's written in more than one language. This has an especial appeal to Android developers who are trying to escape Java and Oracle's legal assaults on Dalvij and thus need to mix legacy Java with Kotlin. Whether you can easily mix in subsystems in C or assembler in Gradle I haven't explored.

Personally, I've had Gradle projects break on me. Maven is more solid, which is another reason I prefer Maven.
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Back to the original topic:

You can collapse a project down to its bare minimum with a single "clean" command, ship it around the world, and rebuild the whole thing somewhere else with only the Java compiler and Maven itself for pre-supplied resources.

Personally, I've had Gradle projects break on me. Maven is more solid, which is another reason I prefer Maven.



Thank-you. I am going with Maven and github. So just ship a pom file to git?

Thanks for sharing your experience with me.
 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should be able to to a "git init ." to make the Maven project a git project (I just looked to see if there's a goal for that, but I guess not). Create/edit .gitignore to include the target directory and connect the git remote to gihub or other favorite git repository. That should be about it.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Back to the original topic:

That said, the upside to Ant is that you can build complex build systems in any way you like. In Ant you know exactly what the process steps are and what they do.



Quoted for truth. There is value is knowing what your dependencies are, and a build system is not the same as a dependency management system. I don't understand why people are trying to conflate the two. I suppose it is simply to provide the illusion of a one-size-fits-all-and-solves-all-my-problems solution for devops and pointy-haired managers. At some level of the stack you will have to deal with dependencies and libraries, installations and versions, and no build system can do that for you. The setup and installation is not the same as the build. If, as part of the build, you want to call out to a dependency management tool to ensure all packages are downloaded and installed, fine: but I don't see why it needs to be integrated into a build system itself.

The next big thing would be the tool "doitall" and just set up everything exactly perfectly correct -- eh, it doesn't and cannot exist. /rant

Edit: Please don't think I am disrespecting anyone or knocking anyone's use of these tools in their job, for practical purposes; I am simply ranting my prior frustrations with some of these tools.
 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what this "dependency management system" thing is supposed to be.

Maven is a build system where the dependencies are indicated as standard resources. Maven keeps a local cache (repository) of such resources so that it will automatically pull needed dependencies from central Maven repositories as needed, then keep them in the cache. It will also transitively pull indirect dependencies so that the build is self-contained.

Ant is a build system where you have to pull all of the dependencies manually and store them locally (and where people stored them locally was always one of my biggest headaches). You basically either had to store them in the Ant project directory and end up with myriad duplicate copies if you had lots of projects or put them in a location outside the project which made shipping projects difficult and installing them on remote systems sometimes impossible. Or you could use Ivy, which basically does what Maven does, and, in fact, I'm fairly certain pulls from Maven's repositories (as does Gradle).

As for managing dependencies, I can attest that while Maven can handle pulling, caching, and building with dependencies, if you modify a project where one dependency's upstream version requirements clash with another's, you're in for fun times. If there's a tool that can unsnarl that particular problem automatically a lot of people would love to hear about it.
 
Damon McNeill
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I'm not sure what this "dependency management system" thing is supposed to be.

Maven is a build system where the dependencies are indicated as standard resources. Maven keeps a local cache (repository) of such resources so that it will automatically pull needed dependencies from central Maven repositories as needed, then keep them in the cache. It will also transitively pull indirect dependencies so that the build is self-contained.

Ant is a build system where you have to pull all of the dependencies manually and store them locally (and where people stored them locally was always one of my biggest headaches). You basically either had to store them in the Ant project directory and end up with myriad duplicate copies if you had lots of projects or put them in a location outside the project which made shipping projects difficult and installing them on remote systems sometimes impossible. Or you could use Ivy, which basically does what Maven does, and, in fact, I'm fairly certain pulls from Maven's repositories (as does Gradle).

As for managing dependencies, I can attest that while Maven can handle pulling, caching, and building with dependencies, if you modify a project where one dependency's upstream version requirements clash with another's, you're in for fun times. If there's a tool that can unsnarl that particular problem automatically a lot of people would love to hear about it.



I hear you. At some point it just becomes a system like yum or apt, no? And neither yum nor apt is the same as make. I like to feel in some control of what my dependencies are and where they come from, after suffering multiple headaches, and with an automated downloader and installer maybe I am out of a job, lol. The where things are installed is super important, as well as configuring the environment variables, paths, and so forth. Most people don't even understand where or what the dependencies are.

if you modify a project where one dependency's upstream version requirements clash with another's, you're in for fun times



This seems to happen quite often. Especially in a dynamic language like Python where your failure occurs at a large distance from the the seemingly innocuous root of the stack trace.

 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Damon McNeill wrote:At some point it just becomes a system like yum or apt, no?



No. While Java build systems and OS package managers have certain things in common, Java build systems exist first and foremost to build, package managers exist to install packages. You typically build over and over, but you only install a specific version of a package once. Their download managers and caches (if any) are subsidiary functions.

Which brings up a critical difference. Package managers generally pull the latest versions of the requested packages, and if you set up a Maven project that way, you're using Maven in a very broken manner. One of the key tenets  of Maven is being able to produce an exact duplicate of the target every time and every place and you cannot do that if the dependency versions keep changing. A Maven POM should always be requesting explicit versions of the dependencies and those are the versions that will be used. A Maven artefact version cannot be updated. Ever. You have to produce a new version if you've changed something,

Maven must therefore be told explicitly what artefacts (libraries) the project is dependent on, including the version required. It cannot to resolve dependencies automatically and even the upstream dependencies are actually resolved by the dependencies declared in the POM that built the artefact itself. Fortunately there are some fairly good ways to locate candidates, startoing with the search page at maven,com and most libraries these days have package names that correspond.

Damon McNeill wrote:

Tim Holloway wrote:if you modify a project where one dependency's upstream version requirements clash with another's, you're in for fun times



This seems to happen quite often. Especially in a dynamic language like Python where your failure occurs at a large distance from the the seemingly innocuous root of the stack trace.


Dependency conflicts are the Java (and Python - and Perl) equivalents of "DLL Hell". They're not limited to automated build systems, alas.
 
Stephan van Hulst
Saloon Keeper
Posts: 13367
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why one wouldn't feel in control when using Maven, as opposed to using Ant. Sure, Maven dictates how the low level stuff is done, but we say that a pilot is in control of the airplane even if they don't know how the engines are built.

With Maven I can take a quick look at a POM and know how the project is structured and what dependencies it uses.

With Ant, I have flat out refused to take a look at the problems people experience with their projects, because it's invariably an absolutely incoherent mess. Nobody is in control of that.
 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I'm not sure why one wouldn't feel in control when using Maven, as opposed to using Ant. Sure, Maven dictates how the low level stuff is done, but we say that a pilot is in control of the airplane even if they don't know how the engines are built.



It's more that with Ant I'm used to being the pilot and with Maven I'm in the passenger cabin.

Definitely, though, Ant projects can be a real mess.
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Spring can do JSTL + CSS as well, and it can definitely do MVC; there's a module called "spring-webmvc" after all. However, to get JSP + JSTL working you need to do some configuration. The default is Thymeleaf, and with it you can do just about the same as with JSP + JSTL but in a slightly different way. CSS is really easy to get working; just put it in src/main/resources/static or src/main/resources/public, as everything in those folders is directly accessible as static content relative to the context path (so src/main/resources/static/style.css is available as http://localhost:8080/style.css out-of-the-box, as there is no context path out-of-the-box).



I read your reply a few times and I was looking at Spring Framework again,  in terms of data access (DAO); web-mvc and the core containers, seems Spring is ideal for a scalable enterprise project. I have a few last questions:

1) continuing development and support of the framework, can I continue using 5.1 and how easy is the version upgrade;
2) does it support a UI such as HTML+JSTL and/or Swing
            2.1   although I like the Swing JComponents, JFrames and Dialogs (they have an FX feel to it), Swing itself does not have a drag and drop builder like WindowBuilder or Gluon .
            2.2   Swing has some great layouts e.g. BorderLayout and GridLayout, but also some tedious, long winded codes to get horizontal and vertical alignment of JFrame components e.g. this code in V of MVC (seriously?!)


3) has anyone had experience deploying the whole Spring system to Tomcat and AWS?



 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what you mean by "the whole Spring system". I've used Spring on Tomcat to provide support for JavaServer Faces. I've used it with JPA, Neo4J, Spring Scheduler/Quartz, mail services, and more.

There are a lot modules in Spring. I doubt you'd ever use all of them in a single app.

As far as AWS goes, there were 3 options last I counted:

1. Run Tomcat stand-alone in a VM

2. Run an Amazon elastic Tomcat(s)

3. Run Tomcat in an Amazon container(s)

Options 1 and 3 also allow for Spring Boot.
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank-you for sharing your experience.

Here is one more question, promise my last one on this topic

Just going by your experience with configuring Spring Containers, which of the following method would give me the least number of lines of codes + great overview of flow of control?
XML configuration
Annotations
Java Source Code (the POJO approach)
 
Tim Holloway
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring uses annotations on POJOs, so those aren't separate considerations. As a general rule, use annotations instead of XML files - it's fewer files to co-ordinate. XML "annotations" these days are generally reserved for resources where there's no Java class that can be annotated or when you have a generic annotated POJO and you need to override the default annotation values.

(Betcha that left you with more questions.)  
 
AhFai Chan
Ranch Hand
Posts: 260
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
(Betcha that left you with more questions.)  



OK, just one for now.

What sort of injections are the most often used / most popular with coders ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic