// Path: src/main/java/com/turn/sorcerer/config/AnnotationProcessor.java
// public interface AnnotationProcessor {
// 
// 	void process(Collection<String> ... pkgs);
// }
// 
// Path: src/main/java/com/turn/sorcerer/pipeline/Pipeline.java
// public interface Pipeline {
// 
// 	/**
// 	 * Provides the current iteration number of a pipeline
// 	 *
// 	 * <p>
// 	 * This method should be implemented to trigger the scheduling of a
// 	 * pipeline based on the iteration number. Sorcerer will use the value
// 	 * returned by this method to schedule pipelines. Each time a new iteration
// 	 * number is provided by this method, Sorcerer will instantiate and
// 	 * schedule a new pipeline.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Note: This method will be called periodically (as defined by the
// 	 * {@code interval} field of a pipeline configuration) and so it should
// 	 * be stateless. Sorcerer instantiates a Pipeline instance using its
// 	 * injector and then calls this method to generate the current iteration
// 	 * number.
// 	 * </p>
// 	 *
// 	 * @return Current iteration number
// 	 */
// 	Integer getCurrentIterationNumber();
// 
// 	Integer getPreviousIterationNumber(int curr, int prev);
// }
// 
// Path: src/main/java/com/turn/sorcerer/task/Task.java
// public interface Task {
// 
// 	/**
// 	 * Initializes the task
// 	 *
// 	 * <p>
// 	 * First method called by Sorcerer in the execution of a task. Any task
// 	 * initialization code should be put in the implementation of this
// 	 * method.
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#initialize
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param context Context object containing task execution context.
// 	 *                See {@link com.turn.sorcerer.task.Context}.
// 	 */
// 	void init(final Context context);
// 
// 	/**
// 	 * Executes the task
// 	 *
// 	 * <p>
// 	 * Implementation of this method should contain the "meat" of the task.
// 	 * This method will not be called if the dependency checking phase returns
// 	 * false. This of course means that this method will be called after both
// 	 * {@code init()} and {@code checkDependencies()}. The successful execution
// 	 * of this method will result in the task being committed to a successful
// 	 * completed state.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Obviously if an exception is thrown the task will be committed to an
// 	 * ERROR state. Additionally, exceptions thrown by this method will be
// 	 * caught by Sorcerer, wrapped in a {code SorcererException}, logged,
// 	 * and then an email will be sent to the admins with the exception as the
// 	 * email body (if enabled).
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#execute
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param context Context object containing task execution context.
// 	 *                See {@link com.turn.sorcerer.task.Context}.
// 	 * @throws Exception Will be wrapped by a {@code SorcererException} before
// 	 * being thrown into a higher context.
// 	 */
// 	void exec(final Context context) throws Exception;
// 
// 	/**
// 	 * Provides a Collection of this task's dependencies
// 	 *
// 	 * <p>
// 	 * This method should provide a collection of all the dependencies of this
// 	 * task. Sorcerer will iterate over the collection, and call the
// 	 * {@code check()} method of the {@code Dependency} instance. Once any of
// 	 * the Dependencies return false, Sorcerer will consider the task
// 	 * ineligible to be scheduled.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Note that Sorcerer calls this method <i>after</i> {@code init()}.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * If any complex dependency logic is required (for example if the user
// 	 * desires a task be executed if one of many dependencies are fulfilled)
// 	 * then the logic should be contained in a custom implementation of the
// 	 * {@link com.turn.sorcerer.dependency.Dependency} class.
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#checkDependencies
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param iterNo Iteration number of the task being executed
// 	 * @return Collection of Dependency objects
// 	 */
// 	Collection<Dependency> getDependencies(int iterNo);
// 
// 	void abort();
// }


import com.turn.sorcerer.config.AnnotationProcessor;
import com.turn.sorcerer.pipeline.Pipeline;
import com.turn.sorcerer.pipeline.SorcererPipeline;
import com.turn.sorcerer.task.SorcererTask;
import com.turn.sorcerer.task.Task;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Lists;
import eu.infomas.annotation.AnnotationDetector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
 * Copyright (c) 2015, Turn Inc. All Rights Reserved.
 * Use of this source code is governed by a BSD-style license that can be found
 * in the LICENSE file.
 */

package com.turn.sorcerer.config.impl;




/**
 * Class Description Here
 *
 * @author tshiou
 */
public class InfomasAnnotationProcessor implements AnnotationProcessor {

	private static final Logger logger =
			LoggerFactory.getLogger(InfomasAnnotationProcessor.class);

	public void process(Collection<String> ... pkgs) {

		List<String> packages = Lists.newArrayList();

		for (Collection<String> p : pkgs) {
			packages.addAll(p);
		}

		final AnnotationDetector cf = new AnnotationDetector(new TaskAnnotationReporter());
		try {

			// Full classpath
// Path: src/main/java/com/turn/sorcerer/config/AnnotationProcessor.java
// public interface AnnotationProcessor {
// 
// 	void process(Collection<String> ... pkgs);
// }
// 
// Path: src/main/java/com/turn/sorcerer/pipeline/Pipeline.java
// public interface Pipeline {
// 
// 	/**
// 	 * Provides the current iteration number of a pipeline
// 	 *
// 	 * <p>
// 	 * This method should be implemented to trigger the scheduling of a
// 	 * pipeline based on the iteration number. Sorcerer will use the value
// 	 * returned by this method to schedule pipelines. Each time a new iteration
// 	 * number is provided by this method, Sorcerer will instantiate and
// 	 * schedule a new pipeline.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Note: This method will be called periodically (as defined by the
// 	 * {@code interval} field of a pipeline configuration) and so it should
// 	 * be stateless. Sorcerer instantiates a Pipeline instance using its
// 	 * injector and then calls this method to generate the current iteration
// 	 * number.
// 	 * </p>
// 	 *
// 	 * @return Current iteration number
// 	 */
// 	Integer getCurrentIterationNumber();
// 
// 	Integer getPreviousIterationNumber(int curr, int prev);
// }
// 
// Path: src/main/java/com/turn/sorcerer/task/Task.java
// public interface Task {
// 
// 	/**
// 	 * Initializes the task
// 	 *
// 	 * <p>
// 	 * First method called by Sorcerer in the execution of a task. Any task
// 	 * initialization code should be put in the implementation of this
// 	 * method.
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#initialize
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param context Context object containing task execution context.
// 	 *                See {@link com.turn.sorcerer.task.Context}.
// 	 */
// 	void init(final Context context);
// 
// 	/**
// 	 * Executes the task
// 	 *
// 	 * <p>
// 	 * Implementation of this method should contain the "meat" of the task.
// 	 * This method will not be called if the dependency checking phase returns
// 	 * false. This of course means that this method will be called after both
// 	 * {@code init()} and {@code checkDependencies()}. The successful execution
// 	 * of this method will result in the task being committed to a successful
// 	 * completed state.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Obviously if an exception is thrown the task will be committed to an
// 	 * ERROR state. Additionally, exceptions thrown by this method will be
// 	 * caught by Sorcerer, wrapped in a {code SorcererException}, logged,
// 	 * and then an email will be sent to the admins with the exception as the
// 	 * email body (if enabled).
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#execute
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param context Context object containing task execution context.
// 	 *                See {@link com.turn.sorcerer.task.Context}.
// 	 * @throws Exception Will be wrapped by a {@code SorcererException} before
// 	 * being thrown into a higher context.
// 	 */
// 	void exec(final Context context) throws Exception;
// 
// 	/**
// 	 * Provides a Collection of this task's dependencies
// 	 *
// 	 * <p>
// 	 * This method should provide a collection of all the dependencies of this
// 	 * task. Sorcerer will iterate over the collection, and call the
// 	 * {@code check()} method of the {@code Dependency} instance. Once any of
// 	 * the Dependencies return false, Sorcerer will consider the task
// 	 * ineligible to be scheduled.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * Note that Sorcerer calls this method <i>after</i> {@code init()}.
// 	 * </p>
// 	 *
// 	 * <p>
// 	 * If any complex dependency logic is required (for example if the user
// 	 * desires a task be executed if one of many dependencies are fulfilled)
// 	 * then the logic should be contained in a custom implementation of the
// 	 * {@link com.turn.sorcerer.dependency.Dependency} class.
// 	 * </p>
// 	 *
// 	 * @see com.turn.sorcerer.task.executable.ExecutableTask#checkDependencies
// 	 * @see com.turn.sorcerer.executor.TaskExecutor#call
// 	 *
// 	 * @param iterNo Iteration number of the task being executed
// 	 * @return Collection of Dependency objects
// 	 */
// 	Collection<Dependency> getDependencies(int iterNo);
// 
// 	void abort();
// }


// Path: src/main/java/com/turn/sorcerer/config/impl/InfomasAnnotationProcessor.java
import com.turn.sorcerer.config.AnnotationProcessor;
import com.turn.sorcerer.pipeline.Pipeline;
import com.turn.sorcerer.pipeline.SorcererPipeline;
import com.turn.sorcerer.task.SorcererTask;
import com.turn.sorcerer.task.Task;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Lists;
import eu.infomas.annotation.AnnotationDetector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * Copyright (c) 2015, Turn Inc. All Rights Reserved.
 * Use of this source code is governed by a BSD-style license that can be found
 * in the LICENSE file.
 */

package com.turn.sorcerer.config.impl;




/**
 * Class Description Here
 *
 * @author tshiou
 */
public class InfomasAnnotationProcessor implements AnnotationProcessor {

	private static final Logger logger =
			LoggerFactory.getLogger(InfomasAnnotationProcessor.class);

	public void process(Collection<String> ... pkgs) {

		List<String> packages = Lists.newArrayList();

		for (Collection<String> p : pkgs) {
			packages.addAll(p);
		}

		final AnnotationDetector cf = new AnnotationDetector(new TaskAnnotationReporter());
		try {

			// Full classpath
			if (packages == null || packages.size() == 0) {