Permalink
Browse files

Add some test build scripts

  • Loading branch information...
1 parent 79a2641 commit db6906cffa041be76ed0d5fcbbfa99c13723f41b @scryan7371 committed Aug 25, 2011
View
@@ -4,3 +4,4 @@
*.log
*.iml
.DS_STORE
+build
View
@@ -0,0 +1,142 @@
+apply plugin: 'java'
+
+version = "1.0.0-SNAPSHOT"
+archivesBaseName = 'numgen'
+
+ant.importBuild 'build.xml'
+
+// Concatenate the js and css files into one file excluding yepnope and jquery stuff
+task concatFiles << {
+ description = 'Concatenates the css and js files into a single file rui.css and rui.js excluding the external libs such as jquery,etc.'
+ ant.concat (destfile: 'build/css/numgen.css') {
+ fileset(dir: 'src/main/css') {
+ include(name: '**/**.css')
+ exclude(name: 'test/*.css')
+ }
+ }
+ ant.concat (destfile: 'build/javascript/numgen.js') {
+ fileset(dir: 'src/main/javascript') {
+ exclude(name: 'jquery/*.js')
+ include(name: '**/**.js')
+ }
+ }
+}
+
+// Copy the correct files to the new structure for distribution
+task copyTask(type: Copy) {
+ description = 'Copies html,images and third party javascript libraries for packaging.'
+ from 'src/main'
+ include '*.html'
+ include 'javascript/jquery/*.*'
+ include 'css/jquery/*.*'
+ include 'image/**/**.*'
+ exclude 'about.html'
+ into 'build'
+}
+
+task updateAbout(type:Copy) {
+ def env = System.getenv()
+ description = 'Copies and updates the about htm file.'
+ from 'src/main'
+ include 'about.html'
+ expand(hash:'git rev-list --max-count=1 HEAD'.execute().text.trim(),generated: new Date(),userName:env['USER'],version:version)
+ into 'build'
+}
+
+task makeManifest (dependsOn:[copyTask, minify, updateAbout, swapprod]) << {
+ // Open the manifest file
+ def manifestFile = new File("build/manifest.txt")
+ manifestFile.write("")
+ def buildDir = new File("build")
+ loadFileData(manifestFile,buildDir)
+ def cssDir = new File("css")
+ loadFileData(manifestFile,cssDir)
+ def jsDir = new File("javascript")
+ loadFileData(manifestFile,jsDir)
+}
+
+// Build the zip file
+task packageWeb(type: Zip, dependsOn:[concatFiles, copyTask, updateAbout, minify, swapprod, makeManifest]) {
+ description = 'This will zip up the app for distribution on the web.'
+ from 'build'
+ extension = 'war'
+ exclude 'distributions'
+ exclude 'stage'
+ exclude 'css/numgen.css'
+ exclude 'javascript/numgen.js'
+}
+
+ /*
+ * This is the beginning of the release process which includes the following steps.
+ * 1. Make sure all code is checked in and pushed to the master git repository.
+ * 2. Update to make sure you have the latest code. (The build cannot proceed if you have local changes)
+ * 3. Update the version parameter in the build.gradle file to remove the -SNAPSHOT prefix and use a real release number.
+ * 4. Commit and push the changes to the master repo.
+ * 5. Tag the code branch with the command: git tag -s <Version Number i.e. 1.0.0> -m 'version 1.0.0'
+ * 6. Push the tag up to the central repository with the command: git push --tags
+ * 7. Run the command - gradle clean
+ * 8. Run the command - gradle releaseNumGen
+ * 9. Locate the war or zip file in the build/distributions directory and send that to the app store server team for deployment.
+ * 10. Update the build.gradle file to reflect the next version number with the suffix -SNAPSHOT to indicate such.
+ */
+
+
+
+// This is the beginning of a release script that will check the commit status and process labels etc.
+task checkGit << {
+ if (hasLocalModifications())
+ {
+ def message = "GIT Repository has local modifications please commit,stash or revert before you can produce a build."
+ println message
+ throw new RuntimeException(message)
+ }
+ else
+ {
+ println "Repository is up to date with no local modifications"
+ }
+}
+
+task releaseNumgen(dependsOn:[checkGit,packageWeb]) << {
+description = "This will make sure all code is committed and then build numgen."
+}
+
+def getLocalModifications()
+{
+ def stdout = new ByteArrayOutputStream()
+ project.exec
+ {
+ executable = 'git'
+ args = ['status', '--porcelain']
+ standardOutput = stdout
+ }
+ if (stdout.toByteArray().length > 0)
+ {
+ return stdout.toString()
+ }
+}
+
+def hasLocalModifications()
+{
+ getLocalModifications() == null ? false : true
+}
+
+def loadFileData(inManifest,inDir)
+{
+ inDir.listFiles().each{file->
+ if (file.isDirectory())
+ {
+ loadFileData(inManifest,file)
+ }
+ else
+ {
+ def data = file.name
+ data = data.padRight(50)
+ data = data + new Date(file.lastModified())
+ data = data.padRight(80)
+ data = data + file.size()
+ //println data
+ data = data + "\n"
+ inManifest.append(data)
+ }
+ }
+}
View
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+
+<project name="rui" default="all" basedir=".">
+
+ <!-- Initialization variables -->
+ <property name="app.name" value="${ant.project.name}"/>
+ <property name="source.dir" value="src/main"/>
+ <property name="build.dir" value="build"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="staging.dir" value="${build.dir}/staging"/>
+ <property name="distribution.dir" value="${build.dir}/distribution"/>
+ <property name="jar.name" value="${app.name}.war"/>
+
+ <property name="css.concat.file" value="numgen.css"/>
+ <property name="css.min.file" value="numgen.min.css"/>
+ <property name="js.concat.file" value="numgen.js"/>
+ <property name="js.min.file" value="numgen.min.js"/>
+
+
+ <!-- files in lib.dir WILL be included in the final JAR -->
+ <!-- files in compile.lib.dir will NOT be included in the final JAR -->
+ <property name="lib.dir" value="lib"/>
+ <property name="compile.lib.dir" value="lib"/>
+
+ <!-- YUI Compressor JAR -->
+ <!-- Bummer that I have to declare this explicitly,
+ but I need it in the minify target -->
+ <property name="yui.compressor" value="${compile.lib.dir}/yuicompressor-2.4.2.jar"/>
+
+ <!-- ====================================== -->
+ <target name="minify" description="Minifies CSS and JS files">
+ <echo message="***** Minifying CSS *****"/>
+ <apply executable="java" parallel="false" verbose="true" dest="${build.dir}/css">
+ <fileset dir="${build.dir}/css">
+ <include name="${css.concat.file}"/>
+ </fileset>
+ <arg line="-jar"/>
+ <arg path="${yui.compressor}"/>
+ <arg value="--charset"/>
+ <arg value="ANSI"/>
+ <arg value="-o"/>
+ <targetfile/>
+ <mapper type="glob" from="${css.concat.file}" to="${css.min.file}"/>
+ </apply>
+
+ <echo message="***** Minifying JavaScript *****"/>
+ <apply executable="java" parallel="false" verbose="true" dest="${build.dir}/javascript">
+ <fileset dir="${build.dir}/javascript">
+ <include name="${js.concat.file}"/>
+ </fileset>
+ <arg line="-jar"/>
+ <arg path="${yui.compressor}"/>
+ <arg value="--charset"/>
+ <arg value="ANSI"/>
+ <arg value="-o"/>
+ <targetfile/>
+ <mapper type="glob" from="${js.concat.file}" to="${js.min.file}"/>
+ </apply>
+ </target>
+
+ <!-- ====================================== -->
+ <target name="swapprod" description="Replace dev CSS and JS calls with production">
+ <echo message="***** Swapping development JavaScript for production *****"/>
+ <replaceregexp match="&lt;!-- Start Dev Mode JS [\d\w\s\W]*?End Dev Mode JS --&gt;"
+ replace="&lt;script src=\'./javascript/${js.min.file}\'&gt;&lt;/script&gt;" flags="m">
+ <!-- grab everything html -->
+ <fileset dir="${build.dir}/" includes="**/*.html"/>
+ </replaceregexp>
+ <echo message="***** Swapping development CSS for production *****"/>
+ <replaceregexp match="&lt;!-- Start Dev Mode CSS [\d\w\s\W]*?End Dev Mode CSS --&gt;"
+ replace="&lt;link rel='stylesheet' href='./css/${css.min.file}' type='text/css'/&gt;" flags="m">
+ <!-- grab everything html -->
+ <fileset dir="${build.dir}/" includes="**/*.html"/>
+ </replaceregexp>
+ </target>
+</project>
View
@@ -0,0 +1 @@
+apacheDocRoot=/Library/WebServer/Documents
@@ -415,7 +415,9 @@
GCC_PREFIX_HEADER = "NumGen/NumGen-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES";
INFOPLIST_FILE = "NumGen/NumGen-Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -431,7 +433,9 @@
GCC_PREFIX_HEADER = "NumGen/NumGen-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES";
INFOPLIST_FILE = "NumGen/NumGen-Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app;
};
@@ -456,6 +460,7 @@
80E6081E13FCA61300E86A39 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Oops, something went wrong.

0 comments on commit db6906c

Please sign in to comment.