public void execute()

in src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java [144:190]


    public void execute() throws MojoExecutionException {
        if (!isDistModule) {
            getLog().info("This module is marked as a non distribution or assembly module, and the plugin will not run.");
            return;
        }
        if (StringUtils.isEmpty(distSvnStagingUrl)) {
            getLog().warn("commons.distSvnStagingUrl is not set, the commons-release-plugin will not run.");
            return;
        }
        getLog().info("Detaching Assemblies");
        for (final Artifact attachedArtifact : project.getAttachedArtifacts()) {
            putAttachedArtifactInSha512Map(attachedArtifact);
            if (ARTIFACT_TYPES_TO_DETACH.contains(attachedArtifact.getType())) {
                detachedArtifacts.add(attachedArtifact);
            }
        }
        if (detachedArtifacts.isEmpty()) {
            getLog().info("Current project contains no distributions. Not executing.");
            return;
        }
        //
        // PROBLEM CODE for Maven >= 3.8.3
        // https://issues.apache.org/jira/browse/MNG-7316
        try {
            // (1) Try the normal way
            // Maven 3.8.3 throws an exception here because MavenProject.getAttachedArtifacts()
            // returns an IMMUTABLE collection.
            project.getAttachedArtifacts().removeAll(detachedArtifacts);
        } catch (final UnsupportedOperationException e) {
            // (2) HACK workaround for https://issues.apache.org/jira/browse/MNG-7316
            final ArrayList<Artifact> arrayList = new ArrayList<>(project.getAttachedArtifacts());
            arrayList.removeAll(detachedArtifacts);
            try {
                // MavenProject#setAttachedArtifacts(List) is protected
                MethodUtils.invokeMethod(project, true, "setAttachedArtifacts", arrayList);
            } catch (final ReflectiveOperationException roe) {
                throw new MojoExecutionException(roe);
            }
        }
        if (!workingDirectory.exists()) {
            SharedFunctions.initDirectory(getLog(), workingDirectory);
        }
        writeAllArtifactsInSha512PropertiesFile();
        copyRemovedArtifactsToWorkingDirectory();
        getLog().info("");
        hashArtifacts();
    }