]> source.dussan.org Git - vaadin-framework.git/commitdiff
Compile and unit test SASS during build (#9223)
authorHenri Sara <hesara@vaadin.com>
Wed, 8 Aug 2012 10:25:44 +0000 (13:25 +0300)
committerHenri Sara <hesara@vaadin.com>
Wed, 8 Aug 2012 11:34:10 +0000 (14:34 +0300)
build/build.xml
build/ivy/buildhelpers-ivy.xml

index f7d910e4b0052436515562c24e0a7a8faa2cd558..39d27464fcbe430f4667c49ee3c3d1fea30994b3 100644 (file)
        
     <target name="init-deps" depends="common.init-deps" >
         <property name="ivy.resolved" value="1" />
+       
         <ivy:resolve file="build/ivy/ivy.xml" resolveid="common" conf="ss.compile, cs.compile, ss.test.compile"/>
         <ivy:cachepath pathid="ivy.compile.classpath.server-side" conf="ss.compile"/>
         <ivy:cachepath pathid="ivy.compile.classpath.client-side" conf="cs.compile"/>
         <ivy:cachepath pathid="ivy.compile.classpath.server-side-tests" conf="ss.test.compile"/>
+
+        <ivy:cachepath pathid="buildhelpers.dependencies" resolveId="buildhelpers" conf="compile" file="build/ivy/buildhelpers-ivy.xml"/>        
+
        <!-- Extra JARs for custom builds - taken into account before JARs from Ivy. -->
        <!-- Note that this should not be used for permanent build dependencies. -->
         <path id="additional.jar.path">
             <pathelement location="${gwt.user.jar}" />
             <pathelement location="${gwt.dev.jar}" />
 
-               <!-- GWT dependencies - included in gwt-user.jar -->
-               <!--
-            <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
-            <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar" />
-            -->
-
             <path refid="ivy.compile.classpath.server-side" />
         </path>
         <path id="compile.classpath.client-side">
             <pathelement location="${gwt.user.jar}" />
             <pathelement location="${gwt.dev.jar}" />
 
-               <!-- GWT dependencies - included in gwt-user.jar -->
-               <!--
-            <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
-            <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar" />
-            -->
-
                <path refid="ivy.compile.classpath.client-side" />
         </path>
         <path id="compile.classpath.server-side-tests">
 
             <path refid="ivy.compile.classpath.server-side-tests" />
         </path>
+
+       <path id="compile.classpath.buildhelpers">
+            <path refid="additional.jar.path" />
+
+               <!-- GWT -->
+            <pathelement location="${gwt.user.jar}" />
+            <pathelement location="${gwt.dev.jar}" />
+
+            <path refid="buildhelpers.dependencies" />
+        </path>
     </target>
 
     <!-- Clean results - - - - - - - - - - - - - - - - - - - - - - - - - -->
                <property name="result-src-core" value="${result-path}/src/core"/>
                <property name="result-src-junit" value="${result-path}/src/junit"/>
                <property name="result-src-testbench" value="${result-path}/src/testbench"/>
+               <property name="result-src-sass" value="${result-path}/src/sass"/>
+               <property name="result-src-sass-junit" value="${result-path}/src/sass-junit"/>
                <property name="result-classes-core" value="${result-path}/classes/core"/>
                <property name="result-classes-junit" value="${result-path}/classes/junit"/>
                <property name="result-classes-testbench" value="${result-path}/classes/testbench"/>
+               <property name="result-classes-sass" value="${result-path}/classes/sass"/>
+               <property name="result-classes-sass-junit" value="${result-path}/classes/sass-junit"/>
                <property name="result-precompiled-widgetsets" value="${result-path}/classes/widgetsets"/>
                <!-- Folder where Emma instrumented classes are placed (if Emma is used)-->
                <property name="result-classes-core-for-emma-war" value="${result-path}/classes/emma-war"/>
        <property name="buildhelpers-src" value="build/buildhelpers" />
        <property name="buildhelpers-classes" value="${result-path}/buildhelpers/classes" />
 
-        <!-- Create Output Directory Hierarchy -->
+       <!-- Sass -->
+       <property name="sass-src" value="sass/src" />
+       <property name="sass-classes" value="${result-classes-sass}" />
+
+       <!-- Create Output Directory Hierarchy -->
         <mkdir dir="${output-dir}/WebContent" />
         <mkdir dir="${output-dir}/WebContent/demo" />
         <mkdir dir="${output-dir}/WebContent/docs" />
         <!--
         Source directories in the project are
          * src (Vaadin core)
+         * sass/src (SASS compiler)
          * tests/testbench (TestBench test cases)
          * tests/server-side (Server-side JUnit test cases)
          * tests/client-side (Client-side JUnit test cases)
 
         These are copied to 
          * ${result-path}/src/core
+         * ${result-path}/src/sass
          * ${result-path}/src/tests
          * ${result-path}/src/junit
 
         And compiled to 
          * ${result-path}/classes/core
+         * ${result-path}/classes/sass
          * ${result-path}/classes/tests
          * ${result-path}/classes/junit
          
         <loadfile property="VaadinApache2LicenseForJavaFiles" srcFile="build/VaadinApache2LicenseForJavaFiles.txt" />
         
         <mkdir dir="${result-path}/src" />
+        <mkdir dir="${result-src-sass}/src" />
         <mkdir dir="${result-src-core}" />
         <mkdir dir="${result-src-testbench}" />
         <mkdir dir="${result-src-junit}" />
+        <mkdir dir="${result-src-sass-junit}" />
 
         <patternset id="preprocessable-files">
             <include name="**/*.java" />
             </fileset>
         </copy>
 
+        <copy todir="${result-src-sass}" overwrite="yes">
+            <filterset refid="version-and-license"/>
+            <filterset refid="pre-css-style"/>
+            <fileset dir="sass/src">
+                <patternset refid="preprocessable-files" />
+            </fileset>
+        </copy>
+
         <copy todir="${result-src-testbench}">
             <filterset refid="version-and-license"/>
             <fileset dir="tests/testbench">
                 <patternset refid="preprocessable-files" />
             </fileset>
         </copy>
+        <copy todir="${result-src-sass-junit}">
+            <filterset refid="version-and-license"/>
+            <fileset dir="tests/sass/src">
+                <patternset refid="preprocessable-files" />
+            </fileset>
+        </copy>
                 
         <!-- Add other files such as images, these are not filtered or processed by fixcrlf task -->
         <echo>Copying non java/html/css/xml files such as images.</echo>
                 <patternset refid="non-preprocessable-files" />
             </fileset>
         </copy>
+        <copy todir="${result-src-sass}">
+            <fileset dir="${sass-src}">
+                <patternset refid="non-preprocessable-files" />
+            </fileset>
+        </copy>
         <copy todir="${result-src-testbench}">
             <fileset dir="tests/testbench">
                 <patternset refid="non-preprocessable-files" />
                 <patternset refid="non-preprocessable-files" />
             </fileset>
         </copy>
+        <copy todir="${result-src-sass-junit}">
+            <fileset dir="tests/sass/src">
+                <patternset refid="non-preprocessable-files" />
+            </fileset>
+            <fileset dir="tests/sass/resources">
+               <!-- test resources (files to compile and compare etc.) -->
+            </fileset>
+        </copy>
 
     </target>
 
             <src path="${result-src-junit}"/>
         </javac>
        
+        <echo>Compiling SASS JUnit tests</echo>
+       <!-- Compile server and client side JUnit tests -->
+        <mkdir dir="${result-classes-sass-junit}" />
+        <javac source="${required.java.version}" target="${required.java.version}" classpathref="compile.classpath.server-side-tests" destdir="${result-classes-sass-junit}" debug="true" encoding="UTF-8" includeantruntime="false">
+               <classpath path="${result-classes-sass}"></classpath>
+            <src path="${result-src-sass-junit}"/>
+        </javac>
+       
         <echo>Compiling src (TestBench tests)</echo>
        <!-- Compile TestBench tests -->
         <mkdir dir="${result-classes-testbench}" />
        
     </target>
 
-    <target name="compile-helpers" depends="init">
+    <target name="compile-helpers" depends="init, compile-sass">
        <mkdir dir="${buildhelpers-classes}" />
-        <ivy:cachepath pathid="buildhelpers.dependencies" resolveId="buildhelpers" conf="compile" file="build/ivy/buildhelpers-ivy.xml"/>        
-        <javac source="${required.java.version}" target="${required.java.version}" includeantruntime="false" srcdir="${buildhelpers-src}" 
-                       classpathref="buildhelpers.dependencies" destdir="${buildhelpers-classes}" debug="true" encoding="UTF-8" />
+        <javac source="${required.java.version}" target="${required.java.version}" includeantruntime="false" classpathref="compile.classpath.buildhelpers" destdir="${buildhelpers-classes}" debug="true" encoding="UTF-8" >
+               <!-- SASS -->
+            <classpath path="${result-classes-sass}" />
+
+            <src path="${buildhelpers-src}"/>
+               </javac>
     </target>
     
-    <target name="defaulttheme" depends="init, compile-helpers" description="Compile all included themes">
+    <target name="compile-sass" depends="init, preprocess-src">
+       <!-- TODO also perform javacc compilation of the parser -->
+        <mkdir dir="${result-classes-sass}" />
+        <javac source="${required.java.version}" target="${required.java.version}" includeantruntime="false" srcdir="${result-src-sass}" 
+                       classpathref="compile.classpath.server-side" destdir="${result-classes-sass}" debug="true" encoding="UTF-8" />
+    </target>
+    
+    <target name="defaulttheme" depends="init, compile-sass, compile-helpers" description="Compile all included themes">
         <echo>Combining default themes css files</echo>
         <java classname="com.vaadin.buildhelpers.CompileDefaultTheme" failonerror="yes" fork="yes">
             <arg value="-version" />
             <arg value="${version.full}"/>
             <classpath>
+               <!-- SASS -->
+                <path path="${result-classes-sass}" />
                 <path location="${buildhelpers-classes}" />
-                <path refid="buildhelpers.dependencies" />
+               <path refid="compile.classpath.buildhelpers" />
             </classpath>
             <jvmarg value="-Djava.awt.headless=true"/>
         </java>
             <!-- Include any instrumented class files before the normal classes -->
             <fileset dir="${result-classes-core-for-emma-war}" />
             <fileset dir="${result-classes-core}"/>
+            <fileset dir="${result-classes-sass}"/>
             <!-- add sources -->
             <fileset dir="${result-src-core}"/>
+            <fileset dir="${result-src-sass}"/>
             <fileset dir="${output-dir}/WebContent">
                 <patternset>
                     <include name="VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/**/*" />
                     <include name="**/*.java" />
                 </patternset>
             </fileset>
+            <fileset dir="${result-src-sass}">
+                <patternset>
+                    <include name="**/*.java" />
+                </patternset>
+            </fileset>
             <fileset dir="${output-dir}/WebContent">
                 <patternset>
                     <include name="release-notes.html" />
                </sequential>
             <antcall inheritrefs="true" inheritall="true" target="testbench-tests"></antcall>
             <antcall inheritrefs="true" inheritall="true" target="server-side-tests"></antcall>
+            <antcall inheritrefs="true" inheritall="true" target="sass-tests"></antcall>
         </parallel>
         
         <!-- Create a combined report from each test's sub report -->
         <echo>##teamcity[publishArtifacts '${result-path}/coverage']</echo>
     </target>
 
+    <!-- Assumes java classes have been compiled but depends does not work out well as this is run from a <parallel> task-->
+    <target name="sass-tests" unless="tests.serverside.skip" depends="compile-tests">
+        <junit printsummary="yes"> 
+            <classpath> 
+                <pathelement path="${result-src-sass-junit}" />
+                <pathelement path="${result-classes-sass}" />
+                <pathelement path="${result-classes-sass-junit}" />
+               <path refid="compile.classpath.server-side-tests"></path>
+            </classpath>
+
+            <batchtest fork="yes">
+                <fileset dir="${result-src-sass-junit}" includes="**/*.java" />
+            </batchtest>
+        </junit>
+    </target>
+
     <!-- Assumes java classes have been compiled but depends does not work out well as this is run from a <parallel> task-->
     <target name="testbench-tests" unless="tests.testbench.skip">
         <fail unless="product-file" message="The 'product-file' property must be defined."/>
index afccd85973c503ba83262e2e499c3bfb395e594c..13e89eb73472818aa80391034d47f23a9f3f601c 100644 (file)
@@ -8,6 +8,12 @@
     </configurations>
     <publications />        
     <dependencies>
-         <dependency org="com.carrotsearch" name="smartsprites" rev="0.2.3-itmill" conf="compile->compile(*),master(*)"/>
+        <dependency org="com.carrotsearch" name="smartsprites" rev="0.2.3-itmill" conf="compile->compile(*),master(*)"/>
+        
+        <!-- These come with GWT for Vaadin JAR but are needed to compile CompileDefaultTheme -->
+        <!-- 
+        <dependency org="org.w3c.css" name="sac" rev="1.3" conf="compile->compile(*),master(*)"/>
+        <dependency org="org.w3c" name="flute" rev="1.2" conf="compile->compile(*),master(*)"/>
+        -->
     </dependencies>
 </ivy-module>
\ No newline at end of file