public void execute()

in src/main/java/org/apache/maven/plugins/clean/CleanMojo.java [223:270]


    public void execute() {
        if (skip) {
            logger.info("Clean is skipped.");
            return;
        }

        String multiModuleProjectDirectory =
                session != null ? session.getSystemProperties().get("maven.multiModuleProjectDirectory") : null;
        Path fastDir;
        if (fast && this.fastDir != null) {
            fastDir = this.fastDir;
        } else if (fast && multiModuleProjectDirectory != null) {
            fastDir = Path.of(multiModuleProjectDirectory, "target", ".clean");
        } else {
            fastDir = null;
            if (fast) {
                logger.warn("Fast clean requires maven 3.3.1 or newer, "
                        + "or an explicit directory to be specified with the 'fastDir' configuration of "
                        + "this plugin, or the 'maven.clean.fastDir' user property to be set.");
            }
        }
        if (fast
                && !FAST_MODE_BACKGROUND.equals(fastMode)
                && !FAST_MODE_AT_END.equals(fastMode)
                && !FAST_MODE_DEFER.equals(fastMode)) {
            throw new IllegalArgumentException("Illegal value '" + fastMode + "' for fastMode. Allowed values are '"
                    + FAST_MODE_BACKGROUND + "', '" + FAST_MODE_AT_END + "' and '" + FAST_MODE_DEFER + "'.");
        }
        final var cleaner =
                new Cleaner(session, logger, isVerbose(), fastDir, fastMode, followSymLinks, failOnError, retryOnError);
        try {
            for (Path directoryItem : getDirectories()) {
                if (directoryItem != null) {
                    cleaner.delete(directoryItem);
                }
            }
            if (filesets != null) {
                for (Fileset fileset : filesets) {
                    if (fileset.getDirectory() == null) {
                        throw new MojoException("Missing base directory for " + fileset);
                    }
                    cleaner.delete(fileset);
                }
            }
        } catch (IOException e) {
            throw new MojoException("Failed to clean project: " + e.getMessage(), e);
        }
    }