<commit_before><?xml version="1.0"?>

<!-- Works with Ant 1.7.0 and higher -->
<!-- These are useful combined with command line/ant test runners for mobile/smart client solutions exports; -->
<!-- see Servoy Wiki - Building A Software Factory for how to use test runners with ant on these exports -->
<!--<project name="Ant Solution Exporter" default="copy_fonts_dir" basedir=".">-->
<project name="Ant Solution Exporter" default="main" basedir=".">

    <property environment="env"/>
	<property file="build.properties"/>

    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="${ANT_CONTRIB_JAR}"/>
        </classpath>
    </taskdef>

    <import file="servoy_utils.xml"/>
    <import file="code_coverage.xml"/>

    <target name="main" depends="setup, code_coverage, export_and_test_solutions, export_result_package_war, collect_logs, finish"/>

    <target name="setup">
		<if>
        	 <equals arg1="${servoy.test_solution_name}" arg2=""/>
        	 <then>
        	 	<fail message="Test solution Name not specified (property 'test.solution')"/>
        	 </then>
		</if>

        <!-- setup some default dirs -->
        <echo level="info" message="*** Setting up folders and files for build***" />
        <delete>
            <dirset dir="${WORKSPACE}" includes="*/resources" excludes="resources/" />
        </delete>
        <delete quiet="true" dir="${general.log_dir}" />
        <mkdir dir="${general.log_dir}" />

        <!--
		<script language="javascript"><![CDATA[
			var TEST_SUFFIX = '_test'

			var testSolution = project.getProperty('test.solution')
			var solutionUnderTesting = project.getProperty('solution_under_testing')

			if (!testSolution) { //if 'test.solution' is not set, derive it from the Job name
				testSolution = project.getProperty('env.JOB_NAME') + TEST_SUFFIX
				project.setProperty('test.solution', testSolution)
			}

			if (!solutionUnderTesting) { //if 'solution_under_testing' is not set, derive it from the 'test.solution' value
				if (testSolution.slice(-5) === TEST_SUFFIX) {
					project.setProperty('solution_under_testing', testSolution.slice(0,-5))
				} else {
					project.setProperty('solution_under_testing', testSolution)
				}
			}
		]]></script>-->
	</target>

    <target name="export_and_test_solutions" depends="get_equinox_jar">
        <if>
            <not>
                <equals arg1="${servoy.junit_test.enabled}" arg2="true" />
            </not>
            <then>
               <echo level="info" message="Servoy JSUnit Test disabled" />
            </then>
            <else>
    	       <export-solution solutionNames="${servoy.test_solution_name}" workspace="${WORKSPACE}"/>
               <antcall target="run_servoy_jsunit_tests" />
           </else>
       </if>
    </target>

    <target name="run_servoy_jsunit_tests" unless="export.failed" depends="prepare_classpath">
        <run_servoy_jsunit_tests/>
    	<if>
    	    <not>
    	        <isset property="test.failed"/>
    	    </not>
    	    <then>
    	    	<antcall target="generate_code_coverage_reports"/>
    	    	<!-- <antcall target="generate_code_analysis_reports"/> -->
    	    </then>
       </if>
    </target>

    <target name="export_result_package_war" depends="get_equinox_jar" unless="test.failed">
        <export-war solutionNames="${servoy.solution_name}" workspace="${WORKSPACE}" warFileName="${war_file_name}"/>
        <if>
    	    <not>
    	        <isset property="texport.failed"/><commit_msg>Try to get delete working<commit_after><?xml version="1.0"?>

<!-- Works with Ant 1.7.0 and higher -->
<!-- These are useful combined with command line/ant test runners for mobile/smart client solutions exports; -->
<!-- see Servoy Wiki - Building A Software Factory for how to use test runners with ant on these exports -->
<!--<project name="Ant Solution Exporter" default="copy_fonts_dir" basedir=".">-->
<project name="Ant Solution Exporter" default="main" basedir=".">

    <property environment="env"/>
	<property file="build.properties"/>

    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="${ANT_CONTRIB_JAR}"/>
        </classpath>
    </taskdef>

    <import file="servoy_utils.xml"/>
    <import file="code_coverage.xml"/>

    <target name="main" depends="setup, code_coverage, export_and_test_solutions, export_result_package_war, collect_logs, finish"/>

    <target name="setup">
		<if>
        	 <equals arg1="${servoy.test_solution_name}" arg2=""/>
        	 <then>
        	 	<fail message="Test solution Name not specified (property 'test.solution')"/>
        	 </then>
		</if>

        <!-- setup some default dirs -->
        <echo level="info" message="*** Setting up folders and files for build***" />
        <delete includeemptydirs="true">
            <dirset dir="${WORKSPACE}" includes="**/resources" excludes="resources/" />
        </delete>
        <delete quiet="true" dir="${general.log_dir}" />
        <mkdir dir="${general.log_dir}" />

        <!--
		<script language="javascript"><![CDATA[
			var TEST_SUFFIX = '_test'

			var testSolution = project.getProperty('test.solution')
			var solutionUnderTesting = project.getProperty('solution_under_testing')

			if (!testSolution) { //if 'test.solution' is not set, derive it from the Job name
				testSolution = project.getProperty('env.JOB_NAME') + TEST_SUFFIX
				project.setProperty('test.solution', testSolution)
			}

			if (!solutionUnderTesting) { //if 'solution_under_testing' is not set, derive it from the 'test.solution' value
				if (testSolution.slice(-5) === TEST_SUFFIX) {
					project.setProperty('solution_under_testing', testSolution.slice(0,-5))
				} else {
					project.setProperty('solution_under_testing', testSolution)
				}
			}
		]]></script>-->
	</target>

    <target name="export_and_test_solutions" depends="get_equinox_jar">
        <if>
            <not>
                <equals arg1="${servoy.junit_test.enabled}" arg2="true" />
            </not>
            <then>
               <echo level="info" message="Servoy JSUnit Test disabled" />
            </then>
            <else>
    	       <export-solution solutionNames="${servoy.test_solution_name}" workspace="${WORKSPACE}"/>
               <antcall target="run_servoy_jsunit_tests" />
           </else>
       </if>
    </target>

    <target name="run_servoy_jsunit_tests" unless="export.failed" depends="prepare_classpath">
        <run_servoy_jsunit_tests/>
    	<if>
    	    <not>
    	        <isset property="test.failed"/>
    	    </not>
    	    <then>
    	    	<antcall target="generate_code_coverage_reports"/>
    	    	<!-- <antcall target="generate_code_analysis_reports"/> -->
    	    </then>
       </if>
    </target>

    <target name="export_result_package_war" depends="get_equinox_jar" unless="test.failed">
        <export-war solutionNames="${servoy.solution_name}" workspace="${WORKSPACE}" warFileName="${war_file_name}"/>
        <if>
    	    <not>
    	        <isset property="export.failed"/>
{'fraction_non_alphanumeric': 0.15160926030491248, 'fraction_numerical': 0.0033879164313946925, 'mean_word_length': 2.905733186328556, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 2, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '478872', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2082, 'n_words': 454}