protected void doExecute()

in src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java [202:267]


    protected void doExecute() throws MojoExecutionException {
        // initialize the separators.
        boolean isFileSepSet = fileSeparator != null && !fileSeparator.isEmpty();
        boolean isPathSepSet = pathSeparator != null && !pathSeparator.isEmpty();

        // don't allow them to have absolute paths when they attach.
        if (attach && (localRepoProperty == null || localRepoProperty.isEmpty())) {
            localRepoProperty = "${M2_REPO}";
        }

        Set<Artifact> artifacts = getResolvedDependencies(true);

        if (artifacts == null || artifacts.isEmpty()) {
            getLog().info("No dependencies found.");
        }

        List<Artifact> artList = new ArrayList<>(artifacts);

        StringBuilder sb = new StringBuilder();
        Iterator<Artifact> i = artList.iterator();

        if (i.hasNext()) {
            appendArtifactPath(i.next(), sb);

            while (i.hasNext()) {
                sb.append(isPathSepSet ? this.pathSeparator : File.pathSeparator);
                appendArtifactPath(i.next(), sb);
            }
        }

        String cpString = sb.toString();

        // if file separator is set, I need to replace the default one from all
        // the file paths that were pulled from the artifacts
        if (isFileSepSet) {
            // Escape file separators to be used as literal strings
            final String pattern = Pattern.quote(File.separator);
            final String replacement = Matcher.quoteReplacement(fileSeparator);
            cpString = cpString.replaceAll(pattern, replacement);
        }

        // make the string valid for filtering
        if (outputFilterFile) {
            cpString = "classpath=" + cpString;
        }

        if (outputProperty != null) {
            getProject().getProperties().setProperty(outputProperty, cpString);
            if (getLog().isDebugEnabled()) {
                getLog().debug(outputProperty + " = " + cpString);
            }
        }

        if (outputFile == null) {
            getLog().info("Dependencies classpath:" + System.lineSeparator() + cpString);
        } else {
            if (regenerateFile || !isUpToDate(cpString)) {
                storeClasspathFile(cpString, outputFile);
            } else {
                this.getLog().info("Skipped writing classpath file '" + outputFile + "'.  No changes found.");
            }
        }
        if (attach) {
            attachFile(cpString);
        }
    }