// Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenDependency.java
// public class MavenDependency extends MavenArtifact {
// 
//     private String scope;
//     public boolean optional;
// 
//     @Nonnull
//     public String getScope() {
//         return scope == null ? "compile" : scope;
//     }
// 
//     public void setScope(String scope) {
//         this.scope = scope == null || scope.isEmpty() ? null : scope;
//     }
// 
//     @Override
//     public String toString() {
//         return "MavenDependency{" +
//                 getGroupId() + ":" +
//                 getArtifactId() + ":" +
//                 getType() +
//                 (getClassifier() == null ? "" : ":" + getClassifier()) + ":" +
//                 getBaseVersion() + ", " +
//                 "scope: " + scope + ", " +
//                 " optional: " + optional +
//                 " version: " + getVersion() +
//                 " snapshot: " + isSnapshot() +
//                 (getFile() == null ? "" : " " + getFile()) +
//                 '}';
//     }
// 
//     public MavenArtifact asMavenArtifact() {
//         MavenArtifact result = new MavenArtifact();
// 
//         result.setGroupId(getGroupId());
//         result.setArtifactId(getArtifactId());
//         result.setVersion(getVersion());
//         result.setBaseVersion(getBaseVersion());
//         result.setType(getType());
//         result.setClassifier(getClassifier());
//         result.setExtension(getExtension());
//         result.setFile(getFile());
//         result.setSnapshot(isSnapshot());
// 
//         return result;
//     }
// 
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(super.hashCode(), optional, scope);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (!super.equals(obj))
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         MavenDependency other = (MavenDependency) obj;
//         if (optional != other.optional)
//             return false;
//         if (scope == null) {
//             return other.scope == null;
//         } else return scope.equals(other.scope);
//     }
// }


import hudson.Extension;
import hudson.FilePath;
import hudson.model.FingerprintMap;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.tasks.Fingerprinter;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.pipeline.maven.MavenDependency;
import org.jenkinsci.plugins.pipeline.maven.MavenPublisher;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.w3c.dom.Element;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesLister.listDependencies;

    private boolean includeScopeTest;

    private boolean includeScopeProvided = true;

    @DataBoundConstructor
    public DependenciesFingerprintPublisher() {
        super();
    }

    protected Set<String> getIncludedScopes() {
        Set<String> includedScopes = new TreeSet<>();
        if (includeScopeCompile)
            includedScopes.add("compile");
        if (includeScopeRuntime)
            includedScopes.add("runtime");
        if (includeScopeProvided)
            includedScopes.add("provided");
        if (includeScopeTest)
            includedScopes.add("test");
        return includedScopes;
    }

    @Override
    public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsElt) throws IOException, InterruptedException {
        Run run = context.get(Run.class);
        TaskListener listener = context.get(TaskListener.class);

        FilePath workspace = context.get(FilePath.class);

// Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenDependency.java
// public class MavenDependency extends MavenArtifact {
// 
//     private String scope;
//     public boolean optional;
// 
//     @Nonnull
//     public String getScope() {
//         return scope == null ? "compile" : scope;
//     }
// 
//     public void setScope(String scope) {
//         this.scope = scope == null || scope.isEmpty() ? null : scope;
//     }
// 
//     @Override
//     public String toString() {
//         return "MavenDependency{" +
//                 getGroupId() + ":" +
//                 getArtifactId() + ":" +
//                 getType() +
//                 (getClassifier() == null ? "" : ":" + getClassifier()) + ":" +
//                 getBaseVersion() + ", " +
//                 "scope: " + scope + ", " +
//                 " optional: " + optional +
//                 " version: " + getVersion() +
//                 " snapshot: " + isSnapshot() +
//                 (getFile() == null ? "" : " " + getFile()) +
//                 '}';
//     }
// 
//     public MavenArtifact asMavenArtifact() {
//         MavenArtifact result = new MavenArtifact();
// 
//         result.setGroupId(getGroupId());
//         result.setArtifactId(getArtifactId());
//         result.setVersion(getVersion());
//         result.setBaseVersion(getBaseVersion());
//         result.setType(getType());
//         result.setClassifier(getClassifier());
//         result.setExtension(getExtension());
//         result.setFile(getFile());
//         result.setSnapshot(isSnapshot());
// 
//         return result;
//     }
// 
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(super.hashCode(), optional, scope);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (!super.equals(obj))
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         MavenDependency other = (MavenDependency) obj;
//         if (optional != other.optional)
//             return false;
//         if (scope == null) {
//             return other.scope == null;
//         } else return scope.equals(other.scope);
//     }
// }


// Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/DependenciesFingerprintPublisher.java
import hudson.Extension;
import hudson.FilePath;
import hudson.model.FingerprintMap;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.tasks.Fingerprinter;
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.pipeline.maven.MavenDependency;
import org.jenkinsci.plugins.pipeline.maven.MavenPublisher;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.w3c.dom.Element;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.jenkinsci.plugins.pipeline.maven.publishers.DependenciesLister.listDependencies;


    private boolean includeScopeTest;

    private boolean includeScopeProvided = true;

    @DataBoundConstructor
    public DependenciesFingerprintPublisher() {
        super();
    }

    protected Set<String> getIncludedScopes() {
        Set<String> includedScopes = new TreeSet<>();
        if (includeScopeCompile)
            includedScopes.add("compile");
        if (includeScopeRuntime)
            includedScopes.add("runtime");
        if (includeScopeProvided)
            includedScopes.add("provided");
        if (includeScopeTest)
            includedScopes.add("test");
        return includedScopes;
    }

    @Override
    public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsElt) throws IOException, InterruptedException {
        Run run = context.get(Run.class);
        TaskListener listener = context.get(TaskListener.class);

        FilePath workspace = context.get(FilePath.class);

        List<MavenDependency> dependencies = listDependencies(mavenSpyLogsElt, LOGGER);