1 package org.apache.maven;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.commons.jelly.tags.ant.AntTagLibrary;
22 import org.apache.commons.jelly.tags.ant.GrantProject;
23 import org.apache.commons.jelly.tags.ant.JellyPropsHandler;
24 import org.apache.maven.jelly.JellyBuildListener;
25 import org.apache.maven.jelly.MavenJellyContext;
26 import org.apache.maven.project.Project;
27 import org.apache.tools.ant.types.Path;
28
29 /**
30 * A class to help create Ant projects
31 */
32 public class AntProjectBuilder
33 {
34 /**
35 * Initialize Ant.
36 * @param project a Maven project
37 * @param context the maven context whose properties will be available to the Ant Project
38 * @return an Ant project
39 */
40 public static GrantProject build( final Project project, final MavenJellyContext context )
41 {
42
43 JellyBuildListener buildListener = new JellyBuildListener( context.getXMLOutput() );
44 buildListener.setDebug( context.getDebugOn().booleanValue() );
45 buildListener.setEmacsMode( context.getEmacsModeOn().booleanValue() );
46
47
48 GrantProject antProject = new GrantProject();
49 antProject.setPropsHandler( new JellyPropsHandler( context ) );
50 antProject.init();
51 antProject.setBaseDir( project.getFile().getParentFile().getAbsoluteFile() );
52 antProject.addBuildListener( buildListener );
53
54 context.setAntProject( antProject );
55 AntTagLibrary.setProject( context, antProject );
56
57 Path p = new Path( antProject );
58 p.setPath( project.getDependencyClasspath() );
59 antProject.addReference( MavenConstants.DEPENDENCY_CLASSPATH, p );
60
61 return antProject;
62 }
63 }