Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Ant


        File f = getBuildFile(event);
        if (f.exists()) {
            if (onlyOnce && isBuilt(f)) {
                Message.verbose("target build file already built, skipping: " + f);
            } else {
                Ant ant = new Ant();
                Project project = (Project) IvyContext.peekInContextStack(
                    IvyTask.ANT_PROJECT_CONTEXT_KEY);
                if (project == null) {
                    project = new Project();
                    project.init();
                }

                ant.setProject(project);
                ant.setTaskName("ant");

                ant.setAntfile(f.getAbsolutePath());
                ant.setInheritAll(false);
                String target = getTarget();
                if (target != null) {
                    ant.setTarget(target);
                }
                Map atts = event.getAttributes();
                for (Iterator iter = atts.keySet().iterator(); iter.hasNext();) {
                    String key = (String) iter.next();
                    String value = (String) atts.get(key);
                    Property p = ant.createProperty();
                    p.setName(prefix == null ? key : prefix + key);
                    p.setValue(value);
                }

                Message.verbose("triggering build: " + f + " target=" + target + " for " + event);
                try {
                    ant.execute();
                } catch (BuildException e) {
                    Message.verbose("Exception occurred while executing target " + target);
                    e.printStackTrace(); // TODO: remove when finished debugging
                    throw e;
                }
View Full Code Here


         for (Iterator it = m_iterationList.iterator(); it.hasNext(); )
         {
            Iteration iteration = (Iteration)it.next();
            List parameters = iteration.getParams();
            Ant callee = new Ant(this);

            callee.init();
            callee.setAntfile(getProject().getProperty("ant.file"));
            callee.setInheritAll(m_bInheritAll);
            callee.setInheritRefs(m_bInheritRefs);
            log("Executing task \"" + m_sTarget + "\" for:", Project.MSG_DEBUG);

            // set properties to persist as Parameters
            persistentState.restore(callee);

            // set nested parameters
            for (Iterator paramIt = parameters.iterator(); paramIt.hasNext(); )
            {
               Parameter param = (Parameter)paramIt.next();
               Property calleeParam = callee.createProperty();

               if (getProject().getProperty(param.getName()) != null)
               {
                  log("  Overriding existing property \"" + param.getName()  + "\".", Project.MSG_DEBUG);
               }

               log("  \"" + param.getName()  + "\"=\"" + param.getValue() + "\".", Project.MSG_DEBUG);
               calleeParam.setName(param.getName());
               calleeParam.setValue(param.getValue());
            }

            callee.setTarget(m_sTarget);
           
            try
            {
               // get Project handle
               Project calleeNewProject = extractNewProject(callee);

               //target execution
               try
               {                 
                  callee.execute();
               }
               catch (Exception exception)
               {
                  handleException(exception);
               }
View Full Code Here

     */
    public File resolve(final Extension extension,
                         final Project project) throws BuildException {
        validate();

        final Ant ant = new Ant();
        ant.setProject(project);
        ant.setInheritAll(false);
        ant.setAntfile(antfile.getName());

        try {
            final File dir =
                antfile.getParentFile().getCanonicalFile();
            ant.setDir(dir);
        } catch (final IOException ioe) {
            throw new BuildException(ioe.getMessage(), ioe);
        }

        if (null != target) {
            ant.setTarget(target);
        }

        ant.execute();

        return destfile;
    }
View Full Code Here

        File f = getBuildFile(event);
        if (f.exists()) {
            if (onlyOnce && isBuilt(f)) {
                Message.verbose("target build file already built, skipping: " + f);
            } else {
                Ant ant = new Ant();
                Project project = (Project) IvyContext.peekInContextStack(
                    IvyTask.ANT_PROJECT_CONTEXT_KEY);
                if (project == null) {
                    project = new Project();
                    project.init();
                }

                ant.setProject(project);
                ant.setTaskName("ant");

                ant.setAntfile(f.getAbsolutePath());
                ant.setInheritAll(false);
                String target = getTarget();
                if (target != null) {
                    ant.setTarget(target);
                }
                Map atts = event.getAttributes();
                for (Iterator iter = atts.keySet().iterator(); iter.hasNext();) {
                    String key = (String) iter.next();
                    String value = (String) atts.get(key);
                    if (value != null) {
                        Property p = ant.createProperty();
                        p.setName(prefix == null ? key : prefix + key);
                        p.setValue(value);
                    }
                }

                Message.verbose("triggering build: " + f + " target=" + target + " for " + event);
                try {
                    ant.execute();
                } catch (BuildException e) {
                    Message.verbose("Exception occurred while executing target " + target);
                    e.printStackTrace(); // TODO: remove when finished debugging
                    throw e;
                }
View Full Code Here

    public boolean execute(Project project,
                           long contentLength,
                           InputStream content)
            throws Throwable
    {
        Ant ant = (Ant)project.createTask("ant");
        File baseDir = project.getBaseDir();
        if (dir != null)
            baseDir = new File(dir);
        ant.setDir(baseDir);
        ant.setInheritAll(inheritall);
        ant.setInheritRefs(interitrefs);

        if (target != null)
            ant.setTarget(target);

        if (antFile != null)
            ant.setAntfile(antFile);

        Enumeration e = properties.elements();
        PropertyContainer pc = null;
        Property p = null;
        while (e.hasMoreElements())
        {
            pc = (PropertyContainer)e.nextElement();
            p = ant.createProperty();
            p.setName(pc.getName());
            p.setValue(pc.getValue());
        }

        e = references.elements();
        ReferenceContainer rc = null;
        Ant.Reference ref = null;
        while (e.hasMoreElements())
        {
            rc = (ReferenceContainer)e.nextElement();
            ref = new Ant.Reference();
            ref.setRefId(rc.getRefId());
            ref.setToRefid(rc.getToRefId());
            ant.addReference(ref);
        }

        ant.execute();

        return false;
    }
View Full Code Here

                         final Project project )
        throws BuildException
    {
        validate();

        final Ant ant = (Ant)project.createTask( "ant" );
        ant.setInheritAll( false );
        ant.setAntfile( m_antfile.getName() );

        try
        {
            final File dir =
                m_antfile.getParentFile().getCanonicalFile();
            ant.setDir( dir );
        }
        catch( final IOException ioe )
        {
            throw new BuildException( ioe.getMessage(), ioe );
        }

        if( null != m_target )
        {
            ant.setTarget( m_target );
        }

        ant.execute();

        return m_destfile;
    }
View Full Code Here

    public File resolve(final Extension extension,
                         final Project project)
        throws BuildException {
        validate();

        final Ant ant = (Ant) project.createTask("ant");
        ant.setInheritAll(false);
        ant.setAntfile(m_antfile.getName());

        try {
            final File dir =
                m_antfile.getParentFile().getCanonicalFile();
            ant.setDir(dir);
        } catch (final IOException ioe) {
            throw new BuildException(ioe.getMessage(), ioe);
        }

        if (null != m_target) {
            ant.setTarget(m_target);
        }

        ant.execute();

        return m_destfile;
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Ant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.