private boolean isMojoGoalExecuted()

in src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidateFilesMojo.java [382:405]


    private boolean isMojoGoalExecuted(LifecycleExecutor lifecycleExecutor, String mojoGoal, String... goals) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginManagerException {
        if (goals.length == 0) {
            return false;
        }
        
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        try {
            MavenExecutionPlan executionPlan = lifecycleExecutor.calculateExecutionPlan(session, goals);
            for (MojoExecution mojoExecution : executionPlan.getMojoExecutions()) {
                if (isMojoGoalExecuted(mojoExecution, mojoGoal)) {
                    return true;
                }
                lifecycleExecutor.calculateForkedExecutions(mojoExecution, session);
                // also evaluate forked execution goals
                if (mojoExecution.getForkedExecutions().values().stream().flatMap(Collection::stream).anyMatch( t -> isMojoGoalExecuted(t, mojoGoal))) {
                    return true;
                }
            }
            return false;
        } finally {
            // restore old classloader as calculate execution plan modifies it
            Thread.currentThread().setContextClassLoader(classLoader);
        }
    }