<commit_before>package javaposse.jobdsl.dsl.helpers

import com.google.common.base.Preconditions
import javaposse.jobdsl.dsl.WithXmlAction

import static javaposse.jobdsl.dsl.JobParent.maven

class StepContextHelper extends AbstractContextHelper<StepContext> {

    Map<String, Object> jobArguments

    StepContextHelper(List<WithXmlAction> withXmlActions, Map<String, Object> jobArguments=[:]) {
        super(withXmlActions)
        this.jobArguments = jobArguments
    }

    static class StepContext implements Context {
        List<Node> stepNodes = []

        StepContext() {
        }

        StepContext(List<Node> stepNodes) {
            this.stepNodes = stepNodes
        }

        /**
         <hudson.tasks.Shell>
             <command>echo Hello</command>
         </hudson.tasks.Shell>
         */
        def shell(String commandStr) {
            def nodeBuilder = new NodeBuilder()
            stepNodes << nodeBuilder.'hudson.tasks.Shell' {
                'command' commandStr
            }
        }

        /**
         <hudson.tasks.BatchFile>
             <command>echo Hello from Windows</command>
         </hudson.tasks.BatchFile>
         */
        def batchFile(String commandStr) {
            def nodeBuilder = new NodeBuilder()
            stepNodes << nodeBuilder.'hudson.tasks.BatchFile' {
                'command' commandStr
            }
        }

        /**
         <hudson.plugins.gradle.Gradle>
             <description/>
             <switches>-Dtiming-multiple=5 -P${Status}=true -I ${WORKSPACE}/netflix-oss.gradle ${Option}</switches>
             <tasks>clean${Task}</tasks>
             <rootBuildScriptDir/>
             <buildFile/>
             <useWrapper>true</useWrapper>
             <wrapperScript/>
         </hudson.plugins.gradle.Gradle>
         */
        def gradle(String tasksArg = null, String switchesArg = null, Boolean useWrapperArg = true, Closure configure = null) {
            def nodeBuilder = new NodeBuilder()
            def gradleNode = nodeBuilder.'hudson.plugins.gradle.Gradle' {
                description ''
                switches switchesArg?:''
                tasks tasksArg?:''
                rootBuildScriptDir ''
                buildFile ''
                useWrapper useWrapperArg==null?'true':useWrapperArg.toString()
                wrapperScript ''
            }
            // Apply Context
            if (configure) {
                WithXmlAction action = new WithXmlAction(configure)
                action.execute(gradleNode)
            }
            stepNodes << gradleNode
        }

        /**
         <hudson.tasks.Ant>
            <targets>target</targets>
            <antName>Ant 1.8</antName>
            <antOpts>-Xmx1g -XX:MaxPermSize=128M -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false</antOpts>
            <buildFile>build.xml</buildFile>
            <properties>test.jvmargs=-Xmx=1g
test.maxmemory=2g
multiline=true</properties>
         </hudson.tasks.Ant>

         Empty:
         <hudson.tasks.Ant>
            <targets/>
            <antName>(Default)</antName>
         </hudson.tasks.Ant>
         */
        def ant(Closure antClosure = null) {
            ant(null, null, null, antClosure)
        }

        def ant(String targetsStr, Closure antClosure = null) {
            ant(targetsStr, null, null, antClosure)
        }

        def ant(String targetsStr, String buildFileStr, Closure antClosure = null) {
            ant(targetsStr, buildFileStr, null, antClosure)
        }

        def ant(String targetsArg, String buildFileArg, String antInstallation, Closure antClosure = null) {
            AntContext antContext = new AntContext()
            AbstractContextHelper.executeInContext(antClosure, antContext)

            def targetList = []

            if (targetsArg) {
                targetList.addAll targetsArg.contains('\n') ? targetsArg.split('\n') : targetsArg.split(' ')
            }
            targetList.addAll antContext.targets

            // Build File
            if (!buildFileArg && antContext.buildFile) { // Fall back to context
                buildFileArg = antContext.buildFile
            }

            def antOptsList = antContext.antOpts

            if(!antInstallation) {
                antInstallation = antContext.antName?:'(Default)'
            }

            def propertiesList = []
            propertiesList += antContext.properties

            def nodeBuilder = NodeBuilder.newInstance()
            def antNode = nodeBuilder.'hudson.tasks.Ant' {
                targets targetList.join(' ')

                antName antInstallation

                if (antOptsList) {
                    antOpts antOptsList.join('\n')
                }

                if (buildFileArg) {
                    buildFile buildFileArg
                }
            }

            if(propertiesList) {
                antNode.appendNode('properties', propertiesList.join('\n'))
            }

            stepNodes << antNode
        }

        def static class AntContext implements Context {
            def targets = []
            def properties = []
            def buildFile = null
            def antOpts = []
            def antName = null

            def target(String target) {
                targets << target
            }

            def targets(Iterable<String> addlTargets) {
                addlTargets.each {
                    target(it)
                }
            }

            def prop(Object key, Object value) {
                properties << "${key}=${value}"
            }

            def props(Map<String, String> map) {
                map.entrySet().each {
                    prop(it.key, it.value)
                }
            }

            def buildFile(String buildFile) {
                this.buildFile = buildFile
            }<commit_msg>Use more appropriate name for internal method, so that it doesn't get confused with Groovy properties<commit_after>package javaposse.jobdsl.dsl.helpers

import com.google.common.base.Preconditions
import javaposse.jobdsl.dsl.WithXmlAction

import static javaposse.jobdsl.dsl.JobParent.maven

class StepContextHelper extends AbstractContextHelper<StepContext> {

    Map<String, Object> jobArguments

    StepContextHelper(List<WithXmlAction> withXmlActions, Map<String, Object> jobArguments=[:]) {
        super(withXmlActions)
        this.jobArguments = jobArguments
    }

    static class StepContext implements Context {
        List<Node> stepNodes = []

        StepContext() {
        }

        StepContext(List<Node> stepNodes) {
            this.stepNodes = stepNodes
        }

        /**
         <hudson.tasks.Shell>
             <command>echo Hello</command>
         </hudson.tasks.Shell>
         */
        def shell(String commandStr) {
            def nodeBuilder = new NodeBuilder()
            stepNodes << nodeBuilder.'hudson.tasks.Shell' {
                'command' commandStr
            }
        }

        /**
         <hudson.tasks.BatchFile>
             <command>echo Hello from Windows</command>
         </hudson.tasks.BatchFile>
         */
        def batchFile(String commandStr) {
            def nodeBuilder = new NodeBuilder()
            stepNodes << nodeBuilder.'hudson.tasks.BatchFile' {
                'command' commandStr
            }
        }

        /**
         <hudson.plugins.gradle.Gradle>
             <description/>
             <switches>-Dtiming-multiple=5 -P${Status}=true -I ${WORKSPACE}/netflix-oss.gradle ${Option}</switches>
             <tasks>clean${Task}</tasks>
             <rootBuildScriptDir/>
             <buildFile/>
             <useWrapper>true</useWrapper>
             <wrapperScript/>
         </hudson.plugins.gradle.Gradle>
         */
        def gradle(String tasksArg = null, String switchesArg = null, Boolean useWrapperArg = true, Closure configure = null) {
            def nodeBuilder = new NodeBuilder()
            def gradleNode = nodeBuilder.'hudson.plugins.gradle.Gradle' {
                description ''
                switches switchesArg?:''
                tasks tasksArg?:''
                rootBuildScriptDir ''
                buildFile ''
                useWrapper useWrapperArg==null?'true':useWrapperArg.toString()
                wrapperScript ''
            }
            // Apply Context
            if (configure) {
                WithXmlAction action = new WithXmlAction(configure)
                action.execute(gradleNode)
            }
            stepNodes << gradleNode
        }

        /**
         <hudson.tasks.Ant>
            <targets>target</targets>
            <antName>Ant 1.8</antName>
            <antOpts>-Xmx1g -XX:MaxPermSize=128M -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false</antOpts>
            <buildFile>build.xml</buildFile>
            <properties>test.jvmargs=-Xmx=1g
test.maxmemory=2g
multiline=true</properties>
         </hudson.tasks.Ant>

         Empty:
         <hudson.tasks.Ant>
            <targets/>
            <antName>(Default)</antName>
         </hudson.tasks.Ant>
         */
        def ant(Closure antClosure = null) {
            ant(null, null, null, antClosure)
        }

        def ant(String targetsStr, Closure antClosure = null) {
            ant(targetsStr, null, null, antClosure)
        }

        def ant(String targetsStr, String buildFileStr, Closure antClosure = null) {
            ant(targetsStr, buildFileStr, null, antClosure)
        }

        def ant(String targetsArg, String buildFileArg, String antInstallation, Closure antClosure = null) {
            AntContext antContext = new AntContext()
            AbstractContextHelper.executeInContext(antClosure, antContext)

            def targetList = []

            if (targetsArg) {
                targetList.addAll targetsArg.contains('\n') ? targetsArg.split('\n') : targetsArg.split(' ')
            }
            targetList.addAll antContext.targets

            // Build File
            if (!buildFileArg && antContext.buildFile) { // Fall back to context
                buildFileArg = antContext.buildFile
            }

            def antOptsList = antContext.antOpts

            if(!antInstallation) {
                antInstallation = antContext.antName?:'(Default)'
            }

            def propertiesList = []
            propertiesList += antContext.props

            def nodeBuilder = NodeBuilder.newInstance()
            def antNode = nodeBuilder.'hudson.tasks.Ant' {
                targets targetList.join(' ')

                antName antInstallation

                if (antOptsList) {
                    antOpts antOptsList.join('\n')
                }

                if (buildFileArg) {
                    buildFile buildFileArg
                }
            }

            if(propertiesList) {
                antNode.appendNode('properties', propertiesList.join('\n'))
            }

            stepNodes << antNode
        }

        def static class AntContext implements Context {
            def targets = []
            def props = []
            def buildFile = null
            def antOpts = []
            def antName = null

            def target(String target) {
                targets << target
            }

            def targets(Iterable<String> addlTargets) {
                addlTargets.each {
                    target(it)
                }
            }

            def prop(Object key, Object value) {
                props << "${key}=${value}"
            }

            def props(Map<String, String> map) {
                map.entrySet().each {
                    prop(it.key, it.value)
                }
            }

            def buildFile(String buildFile) {
                this.buildFile = buildFile
            }
{'fraction_non_alphanumeric': 0.0963019378860963, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 1.5736062717770034, 'pattern_counts': {'":': 0, '<': 117, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5329049', 'n_tokens_mistral': 3193, 'n_tokens_neox': 2985, 'n_words': 587}