Showing posts with label ant. Show all posts
Showing posts with label ant. Show all posts

Friday, February 7, 2014

Enabling javac debugging for Apache ANT

Short answer: Yes, you may leave the debuglevel attribute out as long as you set the debug attribute totrue.
From the javac Ant task documentation:
debug
Indicates whether source should be compiled with debug information; defaults to off. If set to off, -g:none will be passed on the command line for compilers that support it (for other compilers, no command line argument will be used). If set to true, the value of the debuglevel attribute determines the command line argument.
debugLevel
Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except modern, classic(ver >= 1.2) and jikes. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debuglevel is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.
Therefore, setting debug to true and omitting debugLevel is the same as passing the flag -g with no options appended. According to the javac documentation, passing the -g flag with nothing appended is equivalent to specifying sources, lines, and vars.

Tuesday, October 9, 2012

How do I use Nant/Ant naming patterns?

The rules are:
  • a single star (*) matches zero or more characters within a path name
  • a double star (**) matches zero or more characters across directory levels
  • a question mark (?) matches exactly one character within a path name
Another way to think about it is double star (**) matches slash (/) but single star (*) does not.
Let's say you have the files:
  1. bar.txt
  2. src/bar.c
  3. src/baz.c
  4. src/test/bartest.c
Then the patterns:
  • *.c             matches nothing (there are no .c files in the current directory)
  • src/*.c     matches 2 and 3
  • */*.c         matches 2 and 3 (because * only matches one level)
  • **/*.c       matches 2, 3, and 4 (because ** matches any number of levels)
  • bar.*         matches 1
  • **/bar.*   matches 1 and 2
  • **/bar*.* matches 1, 2, and 4
  • src/ba?.c matches 2 and 3    
http://stackoverflow.com/questions/69835/how-do-i-use-nant-ant-naming-patterns

Friday, August 3, 2012

How to copy the directory using Ant

   todir="${dest.dir}" >  
         dir="${src.dir}" includes="**"/>  
 
believe that will do what you want...

http://stackoverflow.com/questions/1685442/how-to-copy-the-directory-using-ant

What does **/* mean in maven syntax?

It is more related to Ant convention upon which Maven is built.
**/* : all files in all subdirectories: see Ant Patterns.
When ** is used as the name of a directory in the pattern, it matches zero or more directories.
For example: /test/** matches all files/directories under /test/, such as /test/x.java, or /test/foo/bar/xyz.html, but not /xyz.xml.
 http://stackoverflow.com/questions/905845/what-does-mean-in-maven-syntax

Monday, May 28, 2012

Differences between Ant and Maven

In Maven: The Definitive Guide, I wrote about the differences between Maven and Ant in the introduction the section title is "The Differences Between Ant and Maven". Here's an answer that is a combination of the info in that introduction with some additional notes.
A Simple Comparison
I'm only showing you this to illustrate the idea that, at the most basic level, Maven has built-in conventions. Here's a simple Ant build file:
 name="my-project" default="dist" basedir=".">
    
        simple example build file
       
       
     name="src" location="src/main/java"/>
     name="build" location="target/classes"/>
     name="dist"  location="target"/>

     name="init">
      
      
      
       dir="${build}"/>   
    

     name="compile" depends="init"
        description="compile the source " >
      
       srcdir="${src}" destdir="${build}"/>  
    

     name="dist" depends="compile"
        description="generate the distribution" >
      
       dir="${dist}/lib"/>

      
       jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
   

    name="clean"
        description="clean up" >
     
      dir="${build}"/>
      dir="${dist}"/>
   
 
In this simple Ant example, you can see how you have to tell Ant exactly what to do. There is a compile goal which includes the javac task that compiles the source in the src/main/java directory to the target/classes directory. You have to tell Ant exactly where your source is, where you want the resulting bytecode to be stored, and how to package this all into a JAR file. While there are some recent developments that help make Ant less procedural, a developer's experience with Ant is in coding a procedural language written in XML.
Contrast the previous Ant example with a Maven example. In Maven, to create a JAR file from some Java source, all you need to do is create a simple pom.xml, place your source code in ${basedir}/src/main/java and then run mvn install from the command line. The example Maven pom.xml that achieves the same results.

  4.0.0
  org.sonatype.mavenbook
  my-project
  1.0

That's all you need in your pom.xml. Running mvn install from the command line will process resources, compile source, execute unit tests, create a JAR, and install the JAR in a local repository for reuse in other projects. Without modification, you can run mvn site and then find an index.html file in target/site that contains links to JavaDoc and a few reports about your source code.
Admittedly, this is the simplest possible example project. A project which only contains source code and which produces a JAR. A project which follows Maven conventions and doesn't require any dependencies or customization. If we wanted to start customizing the behavior, our pom.xml is going to grow in size, and in the largest of projects you can see collections of very complex Maven POMs which contain a great deal of plugin customization and dependency declarations. But, even when your project's POM files become more substantial, they hold an entirely different kind of information from the build file of a similarly sized project using Ant. Maven POMs contain declarations: "This is a JAR project", and "The source code is in src/main/java". Ant build files contain explicit instructions: "This is project", "The source is in src/main/java", "Run javac against this directory", "Put the results in target/classses", "Create a JAR from the ....", etc. Where Ant had to be explicit about the process, there was something "built-in" to Maven that just knew where the source code was and how it should be processed.
High-level Comparison
The differences between Ant and Maven in this example? Ant...
  • Ant doesn't have formal conventions like a common project directory structure, you have to tell Ant exactly where to find the source and where to put the output. Informal conventions have emerged over time, but they haven't been codified into the product.
  • Ant is procedural, you have to tell Ant exactly what to do and when to do it. You had to tell it to compile, then copy, then compress.
  • Ant doesn't have a lifecycle, you had to define goals and goal dependencies. You had to attach a sequence of tasks to each goal manually.
Where Maven...
  • Maven has conventions, it already knew where your source code was because you followed the convention. It put the bytecode in target/classes, and it produced a JAR file in target.
  • Maven is declarative. All you had to do was create a pom.xml file and put your source in the default directory. Maven took care of the rest.
  • Maven has a lifecycle, which you invoked when you executed mvn install. This command told Maven to execute the a series of sequence steps until it reached the lifecycle. As a side-effect of this journey through the lifecycle, Maven executed a number of default plugin goals which did things like compile and create a JAR.
What About Ivy?
Right, so someone like Steve Loughran is going to read that comparison and call foul. He's going to talk about how the answer completely ignores something called Ivy and the fact that Ant can reuse build logic in the more recent releases of Ant. This is true. If you have a bunch of smart people using Ant + antlibs + Ivy, you'll end up with a well designed build that works. Even though, I'm very much convinced that Maven makes sense, I'd happily use Ant + Ivy with a project team that had a very sharp build engineer. That being said, I do think you'll end up missing out on a number of valuable plugins such as the Jetty plugin and that you'll end up doing a whole bunch of work that you didn't need to do over time.
More Important than Maven vs. Ant
  1. Is that you use a Repository Manager to keep track of software artifacts. I'd suggest downloading Nexus. You can use Nexus to proxy remote repositories and to provide a place for your team to deploy internal artifacts.
  2. You have appropriate modularization of software components. One big monolithic component rarely scales over time. As you project developers, you'll want to have the concept of modules and sub-modules. Maven lends itself to this approach very well.
  3. You adopt some conventions for your build. Even if you use Ant, you should strive to adopt some form of convention that is consistent with other projects. When a project uses Maven, it means that anyone familiar with Maven can pick up the build and start running with it without having to fiddle with configuration just to figure out how to get the thing to compile.
http://stackoverflow.com/questions/603189/differences-between-ant-and-maven

Saturday, May 26, 2012

How to use Ant?

Ant is a build tool. Say for example you have several projects in your Eclipse workspace, all of which are pieces of a larger application. To build it all into a jar file with dependencies included, you could select all the projects and export them as a jar file, but that's somewhat cumbersome.
Ant is an extensible solution. You define the build process in XML, and ant compiles your java files according to this recipe.
Ant can do more than building, too. I worked at a company where the mechanism for deployment was Debian packages in our own repository. We had Ant scripts that would build the jar files, arrange them and some metadata files into a Debian package, put them into the repository, and re-generate the repository manifest.
As with anything Java, there's a lot of configuration you need to get your head around before you're proficient with Ant, but some of the basic tutorials should give you an idea of what you're getting yourself into.

Thursday, August 27, 2009

How to Install ANT in Windows XP

1.First,You must have JDK installed first.
2.Get the ANT for windows here:
view plaincopy to clipboardprint?

1. http://ant.apache.org/bindownload.cgi

http://ant.apache.org/bindownload.cgi

choose latest version with zip package
3.After download ANT,extract zip package in (for example) C:\Ant


4.Set ANT_HOME

* Right click My Computer icon
* Choose properties
* Choose Advanced Tab
* Choose Environtmen Variables Button
* In the System Variables, click New Button
* Give the Variable Name:ANT_HOME
Give the Value: C:\Ant
* Click OK

Then,we’ll add new ANT_HOME path,

Find PATH in the Variable Column in System variables frame

* After found, click Edit button
* Then, add the following text in the bottom of Variable value:
view plaincopy to clipboardprint?
1. %ANT_HOME%\bin;

%ANT_HOME%\bin;

* Click OK to finish

5.Check wheter ANT works correctly or not.
In the command prompt, type:
view plaincopy to clipboardprint?

1. ant -version

ant -version

then click enter,
if the result text is something like:
view plaincopy to clipboardprint?

1. Apache Ant version 1.7.1 compiled on June 27 2008

Apache Ant version 1.7.1 compiled on June 27 2008

then your ANT is work correctly on your Windows

6.The end.

http://omrudi.wordpress.com/2008/11/08/how-to-install-ant-in-windows-xp/