Showing posts with label ANT. Show all posts
Showing posts with label ANT. Show all posts

Apache MAVEN


MAVEN

Maven, a Yiddish word meaning accumulator of knowledge, was originally started as an attempt to simplify the build processes in the Jakarta Turbine project. There were several projects each with their own Ant build files that were all slightly different and JARs were checked into CVS. We wanted a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information and a way to share JARs across several projects.
The result is a tool that can now be used for building and managing any Java-based project. We hope that we have created something that will make the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.
Maven is distributed in several formats for your convenience. Use a source archive if you intend to build Maven yourself.

Maven's Objectives

Maven's primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:
  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features
While using Maven doesn't eliminate the need to know about the underlying mechanisms, Maven does provide a lot of shielding from the details.
Maven allows a project to build using its project object model (POM) and a set of plugins that are shared by all projects using Maven, providing a uniform build system. Once you familiarize yourself with how one Maven project builds you automatically know how all Maven projects build saving you immense amounts of time when trying to navigate many projects.
Maven provides plenty of useful project information that is in part taken from your POM and in part generated from your project's sources. For example, Maven can provide:
  • Change log document created directly from source control
  • Cross referenced sources
  • Mailing lists
  • Dependency list
  • Unit test reports including coverage
As Maven improves the information set provided will improve, all of which will be transparent to users of Maven.
Maven aims to gather current principles for best practices development, and make it easy to guide a project in that direction.
For example, specification, execution, and reporting of unit tests are part of the normal build cycle using Maven. Current unit testing best practices were used as guidelines:
  • Keeping your test source code in a separate, but parallel source tree
  • Using test case naming conventions to locate and execute tests
  • Have test cases setup their environment and don't rely on customizing the build for test preparation.
  • Maven also aims to assist in project workflow such as release management and issue tracking.
Maven also suggests some guidelines on how to layout your project's directory structure so that once you learn the layout you can easily navigate any other project that uses Maven and the same defaults.

What is Maven Not?

You may have heard some of the following things about Maven:
  • Maven is a site and documentation tool
  • Maven extends Ant to let you download dependencies
  • Maven is a set of reusable Ant scriptlets
Maven does encourage best practices, but we realise that some projects may not fit with these ideals for historical reasons. While Maven is designed to be flexible, to an extent, in these situations and to the needs of different projects, it can not cater to every situation without making compromises to the integrity of its objectives.


More on Javamazon

Ant Copy Command-SCP


Ant is a platform-independent scripting tool that lets you construct your build scripts in much the same fashion as the "make" tool in C or C++. You can use a large number of built-in tasks in Ant without any customization. 
Copies a file or FileSet to or from a (remote) machine running an SSH daemon. FileSet only works for copying files from the local machine to a remote machine.

Examples

Copy a single local file to a remote machine

<scp file=”myfile.txt” todir=”user:password@somehost:/home/chuck”/>

Copy a single local file to a remote machine with separate password attribute

<scp file=”myfile.txt” todir=”user@somehost:/home/chuck” password=”password”/>

Copy a single local file to a remote machine using key base authentication.

<scp file=”myfile.txt”

todir=”user@somehost:/home/chuck”

keyfile=”${user.home}/.ssh/id_dsa”

passphrase=”my extremely secret passphrase”

/>

Copy a single remote file to a local directory

<scp file=”user:password@somehost:/home/chuck/myfile.txt” todir=”../some/other/dir”/>

Copy a remote directory to a local directory

<scp file=”user:password@somehost:/home/chuck/*” todir=”/home/sara”/>

Copy a local directory to a remote directory

<scp todir=”user:password@somehost:/home/chuck/”>

<fileset dir=”src_dir”/>

</scp>

Copy a set of files to a directory

<scp todir=”user:password@somehost:/home/chuck”>

<fileset dir=”src_dir”>

<include name=”**/*.java”/>

</fileset>

</scp>

<scp todir=”user:password@somehost:/home/chuck”>

<fileset dir=”src_dir” excludes=”**/*.java“/>

</scp>

Security Note: Hard coding passwords and/or usernames in scp task can be a serious security hole. Consider using variable substitution and include the password on the command line. For example:

<scp todir=”${username}:${password}@host:/dir” …>

Invoking ant with the following command line:

ant -Dusername=me -Dpassword=mypassword target1 target2

Is slightly better, but the username/password is exposed to all users on an Unix system (via the ps command). The best approach is to use the <input> task and/or retrieve the password from a (secured) .properties file.

Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the current Java runtimes. If you need a permission- preserving copy function, use <exec executable=”scp” … > instead.

To know more click here