<commit_before>package com.izforge.izpack.merge.jar;

import com.izforge.izpack.api.exception.MergeException;
import com.izforge.izpack.merge.AbstractMerge;
import com.izforge.izpack.util.IoHelper;
import org.apache.tools.zip.ZipOutputStream;

import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.jar.JarInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * Jar files merger.
 *
 * @author <NAME>
 */
public class JarMerge extends AbstractMerge
{
    private String jarPath;

    private String regexp = ".*";
    private String destination;


    public JarMerge(URL resource, String jarPath, Map<OutputStream, List<String>> mergeContent)
    {
        this.jarPath = jarPath;
        this.mergeContent = mergeContent;
        destination = resource.getFile().replaceAll(this.jarPath, "").replaceAll("file:", "").replaceAll("!/", "");
        regexp = new StringBuilder().append(destination).append("(.*)").toString();
    }

    public JarMerge(String jarPath, String jarPackage, String destination, Map<OutputStream, List<String>> mergeContent)
    {
        this.jarPath = jarPath;
        this.destination = destination;
        this.mergeContent = mergeContent;
        regexp = new StringBuilder().append(jarPackage).append("(.*)").toString();
    }


    public File find(FileFilter fileFilter)
    {
        try
        {
            ArrayList<String> fileNameInZip = getFileNameInZip();
            for (String fileName : fileNameInZip)<commit_msg>Need to exclude the last / of the regexp capture when merging a jar with a specific packag<commit_after>package com.izforge.izpack.merge.jar;

import com.izforge.izpack.api.exception.MergeException;
import com.izforge.izpack.merge.AbstractMerge;
import com.izforge.izpack.util.IoHelper;
import org.apache.tools.zip.ZipOutputStream;

import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.jar.JarInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * Jar files merger.
 *
 * @author <NAME>
 */
public class JarMerge extends AbstractMerge
{
    private String jarPath;

    private String regexp = ".*";
    private String destination;


    public JarMerge(URL resource, String jarPath, Map<OutputStream, List<String>> mergeContent)
    {
        this.jarPath = jarPath;
        this.mergeContent = mergeContent;
        destination = resource.getFile().replaceAll(this.jarPath, "").replaceAll("file:", "").replaceAll("!/", "");
        regexp = new StringBuilder().append(destination).append("(.*)").toString();
    }

    public JarMerge(String jarPath, String jarPackage, String destination, Map<OutputStream, List<String>> mergeContent)
    {
        this.jarPath = jarPath;
        this.destination = destination;
        this.mergeContent = mergeContent;
        regexp = new StringBuilder().append(jarPackage).append('/').append("(.*)").toString();
    }


    public File find(FileFilter fileFilter)
    {
        try
        {
            ArrayList<String> fileNameInZip = getFileNameInZip();
            for (String fileName : fileNameInZip)
{'fraction_non_alphanumeric': 0.12488822652757078, 'fraction_numerical': 0.0, 'mean_word_length': 3.6162310866574967, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '16853', 'n_tokens_mistral': 978, 'n_tokens_neox': 943, 'n_words': 213}