package com.vackosar.gitflowincrementalbuild.boundary;

import com.google.inject.Guice;
import com.vackosar.gitflowincrementalbuild.control.Property;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;

@Component(role = AbstractMavenLifecycleParticipant.class)
public class MavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {

    @Requirement private Logger logger;

    @Override
    public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
        try {
            if (!Boolean.valueOf(Property.enabled.getValue())) {
                logger.info("gitflow-incremental-builder is disabled.");
            } else {
                logger.info("gitflow-incremental-builder is enabled.");
                Guice
                        .createInjector(new GuiceModule(logger, session))
                        .getInstance(UnchangedProjectsRemover.class)
                        .act();
            }
        } catch (Exception e) {
            throw new MavenExecutionException("Exception", e);
        }
    }


}

@@ -463,16 +463,97 @@
 .Logger;
+%0Aimport org.eclipse.jgit.api.errors.GitAPIException;%0A%0Aimport java.io.IOException;
 %0A%0A@Compo
@@ -867,9 +867,8 @@
 if (
-!
 Bool
@@ -972,114 +972,383 @@
 der 
-is disabled.%22);%0A            %7D else %7B%0A                logger.info(%22gitflow-incremental-builder is enabl
+starting...%22);%0A                execute(session);%0A                logger.info(%22gitflow-incremental-builder exitting...%22);%0A            %7D else %7B%0A                logger.info(%22gitflow-incremental-builder is disabled.%22);%0A            %7D%0A        %7D catch (Exception e) %7B%0A            throw new MavenExecutionException(%22Exception during gitflow-incremental-builder execution occur
 ed.%22
+, e
 );%0A 
@@ -1358,21 +1358,101 @@
     
+%7D%0A
     
+%7D%0A%0A
     
-Guice
+private void execute(MavenSession session) throws GitAPIException, IOException %7B
 %0A   
@@ -1448,32 +1448,38 @@
 ption %7B%0A        
+Guice%0A
                 
@@ -1544,24 +1544,16 @@
         
-        
 .getInst
@@ -1609,24 +1609,16 @@
     
-   
-     
 .act();%0A
     
@@ -1617,127 +1617,8 @@
 ();%0A
-            %7D%0A        %7D catch (Exception e) %7B%0A            throw new MavenExecutionException(%22Exception%22, e);%0A        %7D%0A
     

Refactor logging.