Package com.tuenti.supernanny.ant

Source Code of com.tuenti.supernanny.ant.SuperNannyStatus

/**
* Ant task for SuperNanny dependency fetching.
*
* @package Build
* @subpackage Dependencies
* @author Goran Petrovic <gpetrovic@tuenti.com>
*/
package com.tuenti.supernanny.ant;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.tuenti.supernanny.SuperNannyUtil;
import com.tuenti.supernanny.Util;
import com.tuenti.supernanny.cli.ProjectStatus;
import com.tuenti.supernanny.cli.handlers.CliParser;

/**
* Ant task for SuperNanny.
*
* Ant task takes a project root folder as input. The resolver will try and
* fetch all dependencies for the desired project.
*
* @author Goran Petrovic <gpetrovic@tuenti.com>
*/
public class SuperNannyStatus extends Task {
  private String root = ".";
  private String depFile = "";

  public void setRoot(String root) {
    this.root = root;
  }

  public void setDepFile(String depFile) {
    this.depFile = depFile;
  }

  @Override
  public void init() throws BuildException {
    super.init();

    /*
     * Configure the logger.
     */
    Logger.getLogger("").setLevel(Level.OFF);
  }

  @Override
  public void execute() throws BuildException {
    Injector injector = Guice.createInjector(new AbstractModule() {

      @Override
      protected void configure() {
        CliParser p = new CliParser();
        p.depfile = depFile;
        Util util = new SuperNannyUtil();
        util.setRoot(new File(root));

        bind(CliParser.class).toInstance(p);
        bind(Util.class).toInstance(util);
      }
    });
   
    ProjectStatus ps = injector.getInstance(ProjectStatus.class);
    try {
      ps.printStatus();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of com.tuenti.supernanny.ant.SuperNannyStatus

TOP
Copyright © 2018 www.massapi.com. 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.