// Path: src/main/java/net/nicoulaj/maven/plugins/checksum/artifacts/ArtifactListener.java
// public interface ArtifactListener {
//     /**
//      * <p>artifactCreated.</p>
//      *
//      * @param artifact a {@link java.io.File} object
//      * @param checksumType a {@link java.lang.String} object
//      * @param artifactExtension a {@link java.lang.String} object
//      * @param artifactClassifier a {@link java.lang.String} object
//      */
//     void artifactCreated(File artifact, String checksumType, String artifactExtension, String artifactClassifier);
// }
// 
// Path: src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ChecksumFile.java
// public class ChecksumFile
// {
// 	protected final String basePath;
// 
//     protected final File file;
// 
//     protected final String extension;
// 
//     protected final String classifier;
// 
// 	/**
// 	 * <p>Constructor for ChecksumFile.</p>
// 	 *
// 	 * @param basePath a {@link java.lang.String} object
// 	 * @param file a {@link java.io.File} object
// 	 * @param extension a {@link java.lang.String} object
// 	 * @param classifier a {@link java.lang.String} object
// 	 */
// 	public ChecksumFile(String basePath, File file, String extension, String classifier)
// 	{
// 		this.basePath = basePath;
//         this.file = file;
//         this.extension = extension;
//         this.classifier = classifier;
// 	}
// 
// 	/**
// 	 * <p>Getter for the field <code>basePath</code>.</p>
// 	 *
// 	 * @return a {@link java.lang.String} object
// 	 */
// 	public String getBasePath()
// 	{
// 		return basePath;
// 	}
// 
//     /**
//      * <p>Getter for the field <code>file</code>.</p>
//      *
//      * @return a {@link java.io.File} object
//      */
//     public File getFile()
//     {
//         return file;
//     }
// 
//     /**
//      * <p>Getter for the field <code>extension</code>.</p>
//      *
//      * @return a {@link java.lang.String} object
//      */
//     public String getExtension()
//     {
//         return extension;
//     }
// 
//     /**
//      * <p>Getter for the field <code>classifier</code>.</p>
//      *
//      * @return a {@link java.lang.String} object
//      */
//     public String getClassifier()
//     {
//         return classifier;
//     }
// 
// 	/**
// 	 * <p>getRelativePath.</p>
// 	 *
// 	 * @param file a {@link net.nicoulaj.maven.plugins.checksum.mojo.ChecksumFile} object
// 	 * @param subPath a {@link java.lang.String} object
// 	 * @return a {@link java.lang.String} object
// 	 */
// 	public String getRelativePath(ChecksumFile file, String subPath)
// 	{
// 		String filePath = file.getFile().getName();
// 
// 		if ( subPath != null ) {
// 			if ( file.getBasePath() != null && !file.getBasePath().isEmpty() )
// 			{
// 				String basePath = file.getBasePath();
// 
// 				if ( !basePath.endsWith( System.getProperty("file.separator") ) )
// 					basePath = basePath + System.getProperty("file.separator");
// 
// 				filePath = file.getFile().getPath().replace(basePath, "");
// 
// 				if ( !subPath.isEmpty() )
// 				{
// 					if ( !subPath.endsWith( System.getProperty("file.separator") ) )
// 						subPath = subPath + System.getProperty("file.separator");
// 
// 					filePath = filePath.replace(subPath, "");
// 				}
// 			}
// 		}
// 
// 		return filePath;
// 	}
// }


import java.util.HashMap;
import java.util.Map;
import net.nicoulaj.maven.plugins.checksum.artifacts.ArtifactListener;
import net.nicoulaj.maven.plugins.checksum.mojo.ChecksumFile;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter;
import java.io.*;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Comparator;
/*-
 * ====================================================================
 * checksum-maven-plugin
 * ====================================================================
 * Copyright (C) 2010 - 2016 Julien Nicoulaud <julien.nicoulaud@gmail.com>
 * ====================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ====================================================================
 */

package net.nicoulaj.maven.plugins.checksum.execution.target;




/**
 * An {@link net.nicoulaj.maven.plugins.checksum.execution.target.ExecutionTarget} that writes digests to an XML file.
 *
 * @author <a href="mailto:julien.nicoulaud@gmail.com">Julien Nicoulaud</a>
 * @since 1.0
 * @version $Id: $Id
 */
public class XmlSummaryFileTarget
    implements ExecutionTarget
{
    /**
     * The number of spaces used to indent the output file.
     */
    public static final int XML_INDENTATION_SIZE = 2;

    /**
     * Encoding to use for generated files.
     */
    protected final String encoding;

    /**
     * The association file =&gt; (algorithm,hashcode).
     */
// Path: src/main/java/net/nicoulaj/maven/plugins/checksum/artifacts/ArtifactListener.java
// public interface ArtifactListener {
//     /**
//      * <p>artifactCreated.</p>
//      *
//      * @param artifact a {@link java.io.File} object
//      * @param checksumType a {@link java.lang.String} object
//      * @param artifactExtension a {@link java.lang.String} object
//      * @param artifactClassifier a {@link java.lang.String} object
//      */
//     void artifactCreated(File artifact, String checksumType, String artifactExtension, String artifactClassifier);
// }
// 
// Path: src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ChecksumFile.java
// public class ChecksumFile
// {
// 	protected final String basePath;
// 
//     protected final File file;
// 
//     protected final String extension;
// 
//     protected final String classifier;
// 
// 	/**
// 	 * <p>Constructor for ChecksumFile.</p>
// 	 *
// 	 * @param basePath a {@link java.lang.String} object
// 	 * @param file a {@link java.io.File} object
// 	 * @param extension a {@link java.lang.String} object
// 	 * @param classifier a {@link java.lang.String} object
// 	 */
// 	public ChecksumFile(String basePath, File file, String extension, String classifier)
// 	{
// 		this.basePath = basePath;
//         this.file = file;
//         this.extension = extension;
//         this.classifier = classifier;
// 	}
// 
// 	/**
// 	 * <p>Getter for the field <code>basePath</code>.</p>
// 	 *
// 	 * @return a {@link java.lang.String} object
// 	 */
// 	public String getBasePath()
// 	{
// 		return basePath;
// 	}
// 
//     /**
//      * <p>Getter for the field <code>file</code>.</p>
//      *
//      * @return a {@link java.io.File} object
//      */
//     public File getFile()
//     {
//         return file;
//     }
// 
//     /**
//      * <p>Getter for the field <code>extension</code>.</p>
//      *
//      * @return a {@link java.lang.String} object
//      */
//     public String getExtension()
//     {
//         return extension;
//     }
// 
//     /**
//      * <p>Getter for the field <code>classifier</code>.</p>
//      *
//      * @return a {@link java.lang.String} object
//      */
//     public String getClassifier()
//     {
//         return classifier;
//     }
// 
// 	/**
// 	 * <p>getRelativePath.</p>
// 	 *
// 	 * @param file a {@link net.nicoulaj.maven.plugins.checksum.mojo.ChecksumFile} object
// 	 * @param subPath a {@link java.lang.String} object
// 	 * @return a {@link java.lang.String} object
// 	 */
// 	public String getRelativePath(ChecksumFile file, String subPath)
// 	{
// 		String filePath = file.getFile().getName();
// 
// 		if ( subPath != null ) {
// 			if ( file.getBasePath() != null && !file.getBasePath().isEmpty() )
// 			{
// 				String basePath = file.getBasePath();
// 
// 				if ( !basePath.endsWith( System.getProperty("file.separator") ) )
// 					basePath = basePath + System.getProperty("file.separator");
// 
// 				filePath = file.getFile().getPath().replace(basePath, "");
// 
// 				if ( !subPath.isEmpty() )
// 				{
// 					if ( !subPath.endsWith( System.getProperty("file.separator") ) )
// 						subPath = subPath + System.getProperty("file.separator");
// 
// 					filePath = filePath.replace(subPath, "");
// 				}
// 			}
// 		}
// 
// 		return filePath;
// 	}
// }


// Path: src/main/java/net/nicoulaj/maven/plugins/checksum/execution/target/XmlSummaryFileTarget.java
import java.util.HashMap;
import java.util.Map;
import net.nicoulaj.maven.plugins.checksum.artifacts.ArtifactListener;
import net.nicoulaj.maven.plugins.checksum.mojo.ChecksumFile;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter;
import java.io.*;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Comparator;

/*-
 * ====================================================================
 * checksum-maven-plugin
 * ====================================================================
 * Copyright (C) 2010 - 2016 Julien Nicoulaud <julien.nicoulaud@gmail.com>
 * ====================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ====================================================================
 */

package net.nicoulaj.maven.plugins.checksum.execution.target;




/**
 * An {@link net.nicoulaj.maven.plugins.checksum.execution.target.ExecutionTarget} that writes digests to an XML file.
 *
 * @author <a href="mailto:julien.nicoulaud@gmail.com">Julien Nicoulaud</a>
 * @since 1.0
 * @version $Id: $Id
 */
public class XmlSummaryFileTarget
    implements ExecutionTarget
{
    /**
     * The number of spaces used to indent the output file.
     */
    public static final int XML_INDENTATION_SIZE = 2;

    /**
     * Encoding to use for generated files.
     */
    protected final String encoding;

    /**
     * The association file =&gt; (algorithm,hashcode).
     */
    protected Map<ChecksumFile, Map<String, String>> filesHashcodes;