<commit_before>import java.io.File;

basedir = project.basedir;

def subst(srcFile, pattern, substition) {
    File workDir = new File("${basedir}/target/groovy_tmp");
    workDir.mkdirs();
    
    File tmpFile = File.createTempFile("subst", "tmp", workDir);
    if (!srcFile.renameTo(tmpFile)) {
        fail("Unable to rename "+srcFile+" to "+tmpFile+" Aborting!");
    }
    
    srcFile.withPrintWriter { out ->
        def lineNo = 0;
        tmpFile.eachLine { line ->
            lineNo++;
            def newline = line.replaceAll(pattern, substition);
            if (newline != line) {
                log.debug("${srcFile}");
                log.info("${srcFile.name}: Replaced line ${lineNo} >${line}< with >${newline}<");
            }
            out.println(newline);
        }
    }
    
    
}

def argFile = new File("${basedir}/target/generated-sources/castor/org/opennms/netmgt/config/notificationCommands/Argument.java")

subst(argFile, /@param\s+_switch\s*$/, "");
subst(argFile, /@param\s+switch/, "@param _switch");

def genDir = new File("${basedir}/target/generated-sources/castor");

genDir.eachDirRecurse { dir ->

    dir.eachFileMatch( ~/.*Descriptor\.java/) { file ->
        subst(file, /java\.lang\.Class getJavaClass/, /java\.lang\.Class<?> getJavaClass/)
    }
    
}<commit_msg>still doesn't work for some reason on win32, but at least is more correct than it was  ;)<commit_after>import java.io.File;

basedir = project.basedir;

def subst(srcFile, pattern, substition) {
    File workDir = new File("${basedir}" + File.separator + "target" + File.separator + "groovy_tmp");
    workDir.mkdirs();
    
    File tmpFile = File.createTempFile("subst", "tmp", workDir);
    if (!srcFile.renameTo(tmpFile)) {
        fail("Unable to rename "+srcFile+" to "+tmpFile+" Aborting!");
    }
    
    srcFile.withPrintWriter { out ->
        def lineNo = 0;
        tmpFile.eachLine { line ->
            lineNo++;
            def newline = line.replaceAll(pattern, substition);
            if (newline != line) {
                log.debug("${srcFile}");
                log.info("${srcFile.name}: Replaced line ${lineNo} >${line}< with >${newline}<");
            }
            out.println(newline);
        }
    }
    
    
}

def argFile = new File("${basedir}" + File.separator + "target" + File.separator + "generated-sources" + File.separator + "castor" + File.separator + "org" + File.separator + "opennms" + File.separator + "netmgt" + File.separator + "config" + File.separator + "notificationCommands" + File.separator + "Argument.java");

subst(argFile, /@param\s+_switch\s*$/, "");
subst(argFile, /@param\s+switch/, "@param _switch");

def genDir = new File("${basedir}" + File.separator + "target" + File.separator + "generated-sources" + File.separator + "castor");

genDir.eachDirRecurse { dir ->

    dir.eachFileMatch( ~/.*Descriptor\.java/) { file ->
        subst(file, /java\.lang\.Class getJavaClass/, /java\.lang\.Class<?> getJavaClass/)
    }
    
}
{'fraction_non_alphanumeric': 0.17027657447517494, 'fraction_numerical': 0.0013328890369876708, 'mean_word_length': 2.766624843161857, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1433925', 'n_tokens_mistral': 1002, 'n_tokens_neox': 964, 'n_words': 195}