I've been using Maven for a while for my Java (and now Scala) projects. Recently, I've seen some talk about issue with Maven (example). Personally, I'm happy with it till now. I've used sbt for Scala a little bit and I think it works well.
Again my point here is not to say which system is better but to expore out what other alternatives exist and how real developers are using them for Java and Scala projects.
There is a Scala plugin for Gradle.
Alternatively you could use Scala's built-in Ant tasks and Ivy for dependency management (which is what SBT uses internally).
Yet another option is Apache Buildr.
Pretty much any build system designed for Java-based projects should work with Scala.
Related:
A Basic Ant+Ivy+Scala Setup
Comparing SBT and Gradle
Buildr vs. Gradle
I think if you're going to use Scala, you'll need to become familiar with SBT. It's the standard build system for Scala projects, and the build system of choice at every professional organization that I have worked at using Scala.
SBT has a bit of a learning curve, but it also has some amazing features - console is probably the one I use most - load up a shell with your project already on the CLASSPATH.
You can do some pretty clever stuff with SBT - in the end it's all Scala under the hood. The effort to pick it up is well worth it if you plan to work with Scala professionally.
Related
Is it possible to have in the same solution a project in Java, another in Python and another in Scala? Or all the projects must be either in Java either in Scala?
You can mix Java and Scala in a single Maven project. Read the following tutorial for more information:
Scala with Maven
Python and Maven: well python doesn't need to be compiled like Java or Scala code does. Instead, python project building is about resolving dependencies, running unit tests, creating installables and so on. Unfortunately, python has its own way of doing these things that different from Maven. To the extent that it probably doesn't make much sense for Maven to manage python code.
Having said that, you can "lightly integrate" python into a Maven build system by having Maven run a setup.py script as an external command. Here is an article that describes this approach:
Python & Java: a unified build process (1/4)
So I installed Apache Netbeans. Installed some of the plugins and instead of just seeing the Java folder in the categories when I want to create a new Project, I see this:
What is Gradle, Ant, and Maven? I am not familiar with Java and wanted to study the language, but I have no idea of what these are.
I keep seeing that I need to have certain plug ins installed and active.
Here they are.
Ant, Maven and Gradle are Java build tools. You don't really need to know the exact differences though.
Java with Ant
The "Java with Ant" option uses NetBeans' own internal project format (based on Ant). In older NetBeans versions this category was simply called "Java"
If you don't need to share your project with non-NetBeans users, use that option.
You will have to manage dependent libraries yourself (download, add them to the project) unless you are only using libraries and frameworks that are bundled with NetBeans. The turnaround times (the time it takes between you hit "Run" and the application actually starts) are the shortest with this option, as Maven and Gradle add substantial overhead to that.
Java with Maven
Maven is a standardized dependency and build management tool. A project defined with Maven can be used by everybody else as it automatically manages (and downloads) any dependency.
Use that option if you know you need to share your project with other people (e.g. hand it in your school or university).
Java with Gradle
Gradle is yet another build tool, which also manages dependencies for your and has more flexibility than Maven. However the build scripts are less standardized than in Maven. But that is also a good option if you know that you need to share your project with other people.
Unless you are using NetBeans 11.1 (which is currently in Beta) I would not use this option as Gradle support in older versions is not as good as Ant or Maven support.
You might want to go through the tutorials on the NetBeans homepage:
http://netbeans.apache.org/help/index.html
I'm looking for a plugin that would run in a console continuously to scan a Maven project's test sources directory, and when it detects a change kicks off a test cycle. Something analogous to mvn scala:cc or the Scala Build Tool, but for Java. Can anyone point me towards one?
I have personally used sbt even for a java only project just for continuous test feature.
I added a sbt build file to a maven based project and use sbt when developing, but use maven when building the final package, starting embedded jetty etc and this has worked out quite well.
I've just discovered that the scala-maven-plugin supports both continuous compilation & testing, as well as cross-compilation (Java + Scala). So it's possible to use it over a pure Java build and get all the continuous build goodness.
Recently, I have had a need for a solution to this. Having been learning scala and finding about the goodness of sbt ~test, I want to apply it to Java projects that do not have continuous test.
Using the scala-maven-plugin that you mentioned, I have created a github seed that will run Java Junit tests everytime I save a Java source or a Java test.
Check it out:
https://github.com/ailveen/maven-scala-java-continuous-test
The project is very simple right now (contains only Java files because that is my current need) but in the future I hope to add scala test (or specs2 or scalacheck) so it works with mixed java and scala files.
Hope you find it useful.
It is not exactly for Maven, but JUnit Max does continuous testing and if you're on Eclipse it might be the tool you would like to check out
I'm trying to understand what's the best way to setup a project
that is a mix of java and scala and that will use lift.
Lift is intended to run embedded by jetty in another application.
I'm comfortable to work in Eclipse and also used to how it
works with ant as build tool.
I'm a relatively newbie in both scala and lift and get confused
about the different build tool and how to set up things.
I don't really understand maven and haven't really looked at sbt,
but it seem to be the choice of scala developers, but I'm also
dependent on quite some javacode.
Any suggestions, links, tutorials or else on how to setup
the best environment so I can work comfortably in Eclipse
and also build releases quite easily given my scala/java/lift/jetty
enrironment?
I would say that if you are comfortable using Ant as a build tool, Maven should be a piece of cake to use instead. It's main advantage is encouraging conforming to conventions rather than lots of configuration meaning that as long as you follow the standards, setup and usage of any most maven projects is a breeze. I strongly recommend that you invest the time to become familiar with this build tool because it will be very valuable experience/knowledge you can continue to use in your Java career.
With Maven aside, if you are convinced that you and the rest of the project's devs will all be using Eclipse, I would recommend using Eclipse's built in project management infrastructure. It uses Ant under the hood so you will be able to leverage you experience to also run/release from the command-line. All you need to do is set up a eclipse Lift project normally and then to add the scala integration, check out Scala IDE for pretty good IDE support of scala development inside of eclipse.
Good luck!
This screencast is what I used to get started. It starts with a git repository for an SBT template and then adds the Eclipsify sbt plugin to make it into an Eclipse project.
What would you suggest as a replacement to the Maven Java build toolset? Just plain Ant scripts? SCons?
It depends on what you use anyway. Maven 1? Maven 2? I find Maven 2 decently documented, and quite powerful, when used in combination with Ant tasks and some home baked Java plugins.
There are Ant tasks to use Maven features from Ant: http://maven.apache.org/ant-tasks/index.html . So you don't really need to write your own "library".
And you can call Ant from Maven: http://maven.apache.org/plugins/maven-antrun-plugin/ .
You can also script things using Groovy for example: http://groovy.codehaus.org/GMaven+-+Executing+Groovy+Code .
Or just write Java code for the custom bits you need: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html .
There's no reason not to mix and match, when you can do it ;)
While I like the idea of Maven, I always find myself fighting it for anything but the simplest configurations. Its architecture is plugin-based, and the quality of the plugins varies widely. Documentation is sketchy at best; half the time I can't figure out if the doc I'm reading is for Maven 1 or 2. And how often have you had to resort to using the maven-ant-plugin to do something basic?
I've been using Apache Ivy for about a year now, and I'm pretty happy with it. There is a bit of a learning curve though. But there's an active mailing list, and the author is very responsive.
What I ended up doing was writing a "library" of a few simple Ant targets such as "resolve", "compile", "install", etc. that expect things to be in standard Maven places (such as src/main/java) and then <import> the targets into my various projects. This way you get the best of both worlds- Maven-style configuration, and all the power of Ant.
I'm fond of using Ant with Ivy. Ivy uses Maven repositories to fetch library dependencies without forcing you to change your entire build system to suit Maven.
I've been using buildr for some of my projects. Very terse and readable build scripts (no xml) and it uses maven repos (with trivial effort, maven 1 and maven 2).
I was looking for something post-maven1 to work on for some projects and m2 wasn't all that appealing. Maven had already left all m1 users high and dry with the need to redo all of their build systems (and some of mine cannot be expressed in m2 as far as I can tell).
I really like using ant4eclipse - you set up your project dependencies in eclipse as normal and you can write a single ant script that'll build all the projects in the right order.
For third-party libs, you can either set up a single eclipse project containing (and exporting) all of your jars [I DON'T RECOMMEND THIS], or a separate project for each third-party lib, exporting the jar. [I recommend the latter b/c you can track project->third-party deps and upgrade parts when needed.]
I would go with buildr, if i am expecting complex build targets in my build. The benefit is, you are not dependent on any particular library at all. You have all the APIs from Ruby to do whatever you want; unlike Ivy in which case you are still tied up to ANT. Effort of migration to Ivy is worth if you want to introduce library dependency to an already established ANT based build mechanism which does all the operations you want to do.
There are at least three different parts of Maven: the repository, the implementation independent lifecyle and the conventions for a default project. Using Ivy provides only the repository.
I've not used it but I think that easyant is designed to be a more complete replacement to Maven. It uses Ivy as the repository but then adds conventions and standard modules.