<commit_before>package com.ottogroup.emfavro

import java.io.File
import java.io.FileNotFoundException
import java.nio.file.Files
import org.apache.maven.model.Resource
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugin.MojoExecutionException
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.project.MavenProject

@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
class Ecore2AvroMojo extends AbstractMojo {
    private static val UTF8 = "UTF-8"

    @Parameter(defaultValue = "${project}", required = true, readonly = true)
    private var MavenProject project;

    @Parameter(required = true)
    private var File genModel;

    @Parameter(defaultValue = "${project.build.directory}/generated-resources/avro")
    private var File outputDirectory;

    def override void execute() throws MojoExecutionException {
        if (!outputDirectory.exists) outputDirectory.mkdirs
        if (!genModel.exists) throw new FileNotFoundException(genModel.toString)

        val loader = new GenModelLoader
        val genModel = loader.load(genModel.path)
        log.info('''Processing «genModel.genPackages.size» GenPackages''')

        val protocol = Ecore2Avro.convert(genModel)
        val outputPath = outputDirectory.toPath.resolve(protocol.name + ".avpr");
        Files.write(outputPath, protocol.toString(true).getBytes(UTF8))

        val resource = new Resource
        resource.setDirectory(outputDirectory.path)
        project.addResource(resource);
    }
}<commit_msg>Use the default charset for writing the Avro protocol files<commit_after>package com.ottogroup.emfavro

import java.io.File
import java.io.FileNotFoundException
import java.nio.file.Files
import org.apache.maven.model.Resource
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugin.MojoExecutionException
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.project.MavenProject

@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
class Ecore2AvroMojo extends AbstractMojo {
    @Parameter(defaultValue = "${project}", required = true, readonly = true)
    private var MavenProject project;

    @Parameter(required = true)
    private var File genModel;

    @Parameter(defaultValue = "${project.build.directory}/generated-resources/avro")
    private var File outputDirectory;

    def override void execute() throws MojoExecutionException {
        if (!outputDirectory.exists) outputDirectory.mkdirs
        if (!genModel.exists) throw new FileNotFoundException(genModel.toString)

        val loader = new GenModelLoader
        val genModel = loader.load(genModel.path)
        log.info('''Processing «genModel.genPackages.size» GenPackages''')

        val protocol = Ecore2Avro.convert(genModel)
        val outputPath = outputDirectory.toPath.resolve(protocol.name + ".avpr");
        Files.write(outputPath, protocol.toString(true).getBytes)

        val resource = new Resource
        resource.setDirectory(outputDirectory.path)
        project.addResource(resource);
    }
}
{'fraction_non_alphanumeric': 0.095094793860969, 'fraction_numerical': 0.0021065302437556425, 'mean_word_length': 4.326923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6650809', 'n_tokens_mistral': 932, 'n_tokens_neox': 891, 'n_words': 200}