background preloader

Build/Source

Facebook Twitter

Dependencies

Rake -- Ruby Make. Maven: The Complete Reference / Documentation Sonatype.com. Maven Getting Started Guide. What is Maven? At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices. Maven is essentially a project management and comprehension tool and as such provides a way to help with managing: BuildsDocumentationReportingDependenciesSCMsReleasesDistribution If you want more background information on Maven you can check out The Philosophy of Maven and The History of Maven.

Now let's move on to how you, the user, can benefit from using Maven. How can Maven benefit my development process? Maven can provide benefits for your build process by employing standard conventions and practices to accelerate your development cycle while at the same time helping you achieve a higher rate of success. How do I setup Maven? How do I make my first Maven project? On to creating your first project! And the default excludes are: Maven secrets: filtering sources - Connect. The default Maven root project object model provides very good defaults that declare what needs to be done in most cases.

Sometimes you need a bit more or different and Maven lets you do that. In this first episode I’ll show you how to filter your source files. Why filter source files? Well there are many use cases you can think of. Public static final String DOMAIN = "${pom.groupId}"; public static final String WCB_ID = "${pom.artifactId}"; Note: We could discuss if this is a good approach compared to using resource files (that are filtered by default) and can be loaded from the classpath at runtime, but that is beyond the scope of this post ;) Filtering in Maven Filtering is a standard feature in Maven and any typical project uses it extensively. Note: Always make sure binary resources are NOT being filtered.

Configuring the resources plugin So, in order to filter the source files we need to tell the resources plugin to use them as resources. <project... > ... <project... > ... Conclusion. Maven vs Ant or Ant vs Maven? JavaFAQ Home » Java Tools This article is not about religious war between two groups of developers, it is about what is real difference between two tools and why in one case you choose Ant and in another Maven. It help you if you f you in a hurry to make a choice between two Java build tools. Very easy to understand overview over Maven and Ant build concept. We usually prefer one tool over another because we want make developers happy and: Develop faster Concentrate on real work Generate all related document easy We also prefer one tool over another to keep our bosses happy, which means: Reduce development costs Reduce time to market Frequent status reports, which can be easily presented to higher boss Historically Ant is much older tool and it was deigned to have some Java-based build tool.

Ant is different. Maven does encourage best practices and some people can prefer Ant. Maven is not the next generation Ant! Ant and Maven are different. Maven will help you with: Printer Friendly Page. Maven or Ant? Maven vs. Ant is one of the semi-religious topics (like IntelliJ vs. Eclipse, SWT vs. Swing or Spring vs. EJB). Depending on your specific needs, both build tools may be interesting. Ant is just a framework, or a build-DSL, which cannot be used out of the box. Maven can be understood as "Ant With Convention Over Configuration".

As with every Convention Over Configuration framework, you will have to understand the conventions to be able to work efficiently. The real strength of Maven is its dependency management. I use Maven and Ant in my projects, the choice is dependent on the specific needs. You are working with many "creative" developers. On the other hand, I would choose Ant for: "Situational Software" which has to be developed quickly (in a few weeks / months).Projects with external dependencies which are working with "cutting edge" libraries. In my case, in the last few years the ratio between Maven and Ant was about 50-50. Running Apache Ant. Command Line If you've installed Apache Ant as described in the Installing Ant section, running Ant from the command-line is simple: just type ant. When no arguments are specified, Ant looks for a build.xml file in the current directory and, if found, uses that file as the build file and runs the target specified in the default attribute of the <project> tag.

To make Ant use a build file other than build.xml, use the command-line option , where file is the name of the build file you want to use (or a directory containing a build.xml file). If you use the option, Ant will search for a build file first in the current directory, then in the parent directory, and so on, until either a build file is found or the root of the filesystem has been reached. You can also set properties on the command line. It is also possible to specify one or more targets that should be executed. The option prints out a list of the build file's targets. Command-line Options Summary Library Directories Examples ant.

Ant™ User Manual. Ant - Binary Distributions. Apache Ant™ Apache Ant is a Java library and command-line tool that help building software. Downloading Apache Ant Use the links below to download a binary distribution of Ant from one of our mirrors. It is good practice to verify the integrity of the distribution files, especially if you are using one of our mirror sites.

In order to do this you must use the signatures from our main distribution directory. Ant is distributed as zip, tar.gz and tar.bz2 archives - the contents are the same. Please note that the tar.* archives contain file names longer than 100 characters and have been created using GNU tar extensions. In addition the JPackage project provides RPMs at their own distribution site. If you do not see the file you need in the links below, please see the master distribution directory or, preferably, its mirror. Mirror You are currently using Current Release of Ant The Apache Ant team currently maintains two lines of development. Note Old Ant Releases. Welcome to Apache Maven. Installing 3rd party jars. Although rarely, but sometimes you will have 3rd party JARs that you need to put in your local repository for use in your builds, since they don't exist in any public repository like Maven Central.

The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Apache Maven. To make this easier, and less error prone, we have provide a goal in the maven-install-plugin which should make this relatively painless. To install a JAR in the local repository use the following command: mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \ -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> If there's a pom-file as well, you can install it with the following command: mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile> With version 2.5 of the maven-install-plugin it gets even better.

Mvn install:install-file -Dfile=<path-to-file> Maven Compiler plugin - Introduction. The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler. Other compilers than javac can be used and work has already started on AspectJ, .NET, and C#. This Compiler Plugin corresponds to Maven 1.x's Java Plugin. NOTE: To know more about the JDK javac, please see: Goals Overview The Compiler Plugin has two goals. Usage. Maven Ear plugin - ear:ear. Builds J2EE Enterprise Archive (EAR) files. Parameter Details The location of a custom application.xml file to be used within the EAR file. : java.lang.String : No : org.apache.maven.archiver.MavenArchiveConfiguration The artifact type mappings. : org.codehaus.plexus.configuration.PlexusConfiguration Classifier to add to the artifact generated. The default bundle dir for libraries. Single directory for extra files to include in the EAR. : java.io.File : Yes : ${basedir}/src/main/application The comma separated list of tokens to exclude from the EAR.

The comma separated list of tokens to include in the EAR. Character encoding for the auto-generated deployment file(s). Expression preceded with this String won't be interpolated \${foo} will be replaced with ${foo}. : maven.ear.escapeString To escape interpolated value with Windows path c:\foo\bar will be replaced with c:\\foo\\bar. : boolean : maven.ear.escapedBackslashesInFilePath : false Specify that the EAR sources should be filtered. : java.util.List. Settings Reference. Plugin Groups This element contains a list of pluginGroup elements, each contains a groupId. The list is searched when a plugin is used and the groupId is not provided in the command line.

This list automatically contains org.apache.maven.plugins and org.codehaus.mojo. <settings xmlns=" xmlns:xsi=" xsi:schemaLocation=" ... <pluginGroups><pluginGroup>org.mortbay.jetty</pluginGroup></pluginGroups> ... </settings> For example, given the above settings the Maven command line may execute org.mortbay.jetty:jetty-maven-plugin:run with the truncated command: Servers The repositories for download and deployment are defined by the repositories and distributionManagement elements of the POM.

Note: If you use a private key to login to the server, make sure you omit the <password> element. Profiles Activation Properties Repositories. Guide to using Multiple Repositories. There are two different ways that you can specify the use of multiple repositories. The first way is to specify in a POM which repositories you want to use: <project> ... <repositories><repository><id>my-repo1</id><name>your custom repo</name><url> custom repo</name><url> ... </project> The repositories element is inherited so you would usually specify the repositories to use for a group of projects by defining a repositories element at the top of your inheritance chain. NOTE: You will also get the standard set of repositories as defined in the Super POM. The other way you can specify the use of multiple repositories by creating a profile in your ~/.m2/settings.xml file like the following: <settings> ...

If you specify repositories in profiles you must remember to activate that particular profile! Apache Subversion.