// Path: src/common/java/net/minecraftforge/gradle/common/config/MCPConfigV2.java
// public class MCPConfigV2 extends MCPConfigV1 {
//     public static MCPConfigV2 get(InputStream stream) {
//         return Utils.fromJson(stream, MCPConfigV2.class);
//     }
//     public static MCPConfigV2 get(byte[] data) {
//         return get(new ByteArrayInputStream(data));
//     }
// 
//     public static MCPConfigV2 getFromArchive(File path) throws IOException {
//         try (ZipFile zip = new ZipFile(path)) {
//             ZipEntry entry = zip.getEntry("config.json");
//             if (entry == null)
//                 throw new IllegalStateException("Could not find 'config.json' in " + path.getAbsolutePath());
// 
//             byte[] data = IOUtils.toByteArray(zip.getInputStream(entry));
//             int spec = Config.getSpec(data);
//             if (spec == 2 || spec == 3)
//                 return MCPConfigV2.get(data);
//             if (spec == 1)
//                 return new MCPConfigV2(MCPConfigV1.get(data));
// 
//             throw new IllegalStateException("Invalid MCP Config: " + path.getAbsolutePath() + " Unknown spec: " + spec);
//         }
//     }
// 
//     private boolean official = false;
//     private int java_target = 8;
//     @Nullable
//     private String encoding = "UTF-8";
// 
//     public boolean isOfficial() {
//         return this.official;
//     }
// 
//     public int getJavaTarget() {
//         return this.java_target;
//     }
// 
//     public String getEncoding() {
//         return this.encoding == null ? "UTF-8" : this.encoding;
//     }
// 
//     public MCPConfigV2(MCPConfigV1 old) {
//         this.version = old.version;
//         this.data = old.data;
//         this.steps = old.steps;
//         this.functions = old.functions;
//         this.libraries = old.libraries;
//     }
// }


import net.minecraftforge.gradle.common.config.MCPConfigV2;
import net.minecraftforge.srgutils.IMappingFile;
import org.apache.commons.io.IOUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import com.google.common.base.Strings;
import com.google.common.io.Files;
import de.siegmar.fastcsv.reader.NamedCsvReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipFile;
/*
 * ForgeGradle
 * Copyright (C) 2018 Forge Development LLC
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

package net.minecraftforge.gradle.patcher.tasks;




public abstract class CreateExc extends DefaultTask {
    private static final Pattern CLS_ENTRY = Pattern.compile("L([^;]+);");

    public CreateExc() {
        getOutput().convention(getProject().getLayout().getBuildDirectory().dir(getName()).map(d -> d.file("output.exc")));
    }

    @TaskAction
    public void run() throws IOException {
// Path: src/common/java/net/minecraftforge/gradle/common/config/MCPConfigV2.java
// public class MCPConfigV2 extends MCPConfigV1 {
//     public static MCPConfigV2 get(InputStream stream) {
//         return Utils.fromJson(stream, MCPConfigV2.class);
//     }
//     public static MCPConfigV2 get(byte[] data) {
//         return get(new ByteArrayInputStream(data));
//     }
// 
//     public static MCPConfigV2 getFromArchive(File path) throws IOException {
//         try (ZipFile zip = new ZipFile(path)) {
//             ZipEntry entry = zip.getEntry("config.json");
//             if (entry == null)
//                 throw new IllegalStateException("Could not find 'config.json' in " + path.getAbsolutePath());
// 
//             byte[] data = IOUtils.toByteArray(zip.getInputStream(entry));
//             int spec = Config.getSpec(data);
//             if (spec == 2 || spec == 3)
//                 return MCPConfigV2.get(data);
//             if (spec == 1)
//                 return new MCPConfigV2(MCPConfigV1.get(data));
// 
//             throw new IllegalStateException("Invalid MCP Config: " + path.getAbsolutePath() + " Unknown spec: " + spec);
//         }
//     }
// 
//     private boolean official = false;
//     private int java_target = 8;
//     @Nullable
//     private String encoding = "UTF-8";
// 
//     public boolean isOfficial() {
//         return this.official;
//     }
// 
//     public int getJavaTarget() {
//         return this.java_target;
//     }
// 
//     public String getEncoding() {
//         return this.encoding == null ? "UTF-8" : this.encoding;
//     }
// 
//     public MCPConfigV2(MCPConfigV1 old) {
//         this.version = old.version;
//         this.data = old.data;
//         this.steps = old.steps;
//         this.functions = old.functions;
//         this.libraries = old.libraries;
//     }
// }


// Path: src/patcher/java/net/minecraftforge/gradle/patcher/tasks/CreateExc.java
import net.minecraftforge.gradle.common.config.MCPConfigV2;
import net.minecraftforge.srgutils.IMappingFile;
import org.apache.commons.io.IOUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import com.google.common.base.Strings;
import com.google.common.io.Files;
import de.siegmar.fastcsv.reader.NamedCsvReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipFile;

/*
 * ForgeGradle
 * Copyright (C) 2018 Forge Development LLC
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

package net.minecraftforge.gradle.patcher.tasks;




public abstract class CreateExc extends DefaultTask {
    private static final Pattern CLS_ENTRY = Pattern.compile("L([^;]+);");

    public CreateExc() {
        getOutput().convention(getProject().getLayout().getBuildDirectory().dir(getName()).map(d -> d.file("output.exc")));
    }

    @TaskAction
    public void run() throws IOException {
        MCPConfigV2 cfg = MCPConfigV2.getFromArchive(getConfig().get().getAsFile());