├── ant ├── clean.xml ├── docs.xml ├── test.xml ├── prepare.xml ├── bootstrap.xml ├── package.xml └── compile.xml ├── ivy ├── ivy.xml └── ivysettings.xml ├── mkproject.sh └── README.txt /ant/clean.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ant/docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ivy/ivy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ant/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ivy/ivysettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ant/prepare.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /ant/bootstrap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /mkproject.sh: -------------------------------------------------------------------------------- 1 | 2 | inject_dep() { 3 | org=$1 4 | name=$2 5 | rev=$3 6 | 7 | cat ivy/ivy.xml | \ 8 | awk "/ <\/dependencies>/ { print \" \" } { print }" \ 9 | > ivy/ivy2.xml && \ 10 | mv ivy/ivy2.xml ivy/ivy.xml 11 | } 12 | 13 | reset_dep() { 14 | cat ivy/ivy.xml | awk "!// { print }" > ivy/ivy2.xml && mv ivy/ivy2.xml ivy/ivy.xml 15 | } 16 | 17 | echo 18 | echo "Let's create a new scala project." 19 | read -p " package root (like 'com.example'): " -e package_root 20 | read -p " project name (like 'echod'): " -e project_name 21 | read -p " description for humans: " -e description 22 | echo " ----------" 23 | read -p " using thrift? [n]: " -e use_thrift 24 | read -p " using jmock? [n]: " -e use_jmock 25 | 26 | test "x$package_root" = "x" && package_root="com.example" 27 | test "x$project_name" = "x" && project_name="echod" 28 | test "x$description" = "x" && description="sample project" 29 | test "x$use_thrift" = "x" && use_thrift="n" 30 | test "x$use_jmock" = "x" && use_jmock="n" 31 | package_path=$(echo ${package_root} | sed -e 's/\./\//g') 32 | 33 | echo 34 | echo "Creating project ${package_root}.${project_name}" 35 | reset_dep 36 | 37 | cat ivy/ivy.xml | \ 38 | sed -e "s/organisation=\".*\"/organisation=\"${package_root}\"/" \ 39 | -e "s/module=\".*\"/module=\"${project_name}\"/" \ 40 | -e "s/e:buildpackage=\".*\"/e:buildpackage=\"${package_root}.${project_name}\"/" \ 41 | -e "s/e:testclass=\".*\"/e:testclass=\"${package_root}.${project_name}.TestRunner\"/" \ 42 | -e "s/e:jarclassname=\".*\"/e:jarclassname=\"${package_root}.${project_name}.Main\"/" \ 43 | -e "s/e:thriftpackage=\".*\"/e:thriftpackage=\"${package_root}.${project_name}.gen\"/" \ 44 | > ivy/ivy2.xml && \ 45 | mv ivy/ivy2.xml ivy/ivy.xml 46 | 47 | cat build.xml | \ 48 | sed -e "s/.*<\/description>/${description}<\/description>/" \ 50 | > build2.xml && \ 51 | mv build2.xml build.xml 52 | 53 | mkdir -p src/main/scala/${package_path}/${project_name} 54 | mkdir -p src/test/scala/${package_path}/${project_name} 55 | test $use_thrift = "n" || { 56 | mkdir -p src/test/thrift 57 | inject_dep thrift libthrift 20080411p1 58 | } 59 | 60 | # temporarily needed due to bug in specs: 61 | inject_dep junit junit 4.4 62 | 63 | test $use_jmock = "n" || { 64 | inject_dep org.jmock jmock 2.4.0 65 | inject_dep org.hamcrest hamcrest-all 1.1 66 | inject_dep cglib cglib 2.1_3 67 | inject_dep asm asm 1.5.3 68 | inject_dep objenesis objenesis 1.1 69 | } 70 | 71 | cat >src/main/scala/${package_path}/${project_name}/Main.scala <<__EOF__ 72 | package ${package_root}.${project_name} 73 | 74 | object Main { 75 | def main(args: Array[String]) { 76 | println("Hello, world!") 77 | } 78 | } 79 | __EOF__ 80 | 81 | cat >src/test/scala/${package_path}/${project_name}/TestRunner.scala <<__EOF__ 82 | package ${package_root}.${project_name} 83 | 84 | import org.specs.runner.SpecsFileRunner 85 | 86 | object TestRunner extends SpecsFileRunner("src/test/scala/**/*.scala", ".*", 87 | System.getProperty("system", ".*"), System.getProperty("example", ".*")) 88 | __EOF__ 89 | 90 | echo "Done." 91 | echo 92 | 93 | # 94 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | 2 | Folder layout: 3 | ant/ -- boilerplate ant files 4 | src/ -- source code 5 | main/ 6 | scala/ 7 | java/ 8 | jni/ 9 | thrift/ 10 | resources/ -- files to copy into dist 11 | test/ 12 | scala/ 13 | resources/ -- files needed only for tests 14 | scripts/ 15 | ivy/ 16 | ivy.xml -- package description 17 | ivysettings.xml -- repositories 18 | config/ -- items to package in the distribution but not in jars 19 | 20 | To configure, search through build.xml and ivy/ivy.xml for the 21 | string CONFIG and modify accordingly. The Ivy settings are also 22 | documented below. 23 | 24 | Created during the build: 25 | target/ -- compiled files 26 | classes/ 27 | test-classes/ 28 | resources/ -- copied from src/test/resources/ 29 | gen-java/ -- generated from thrift 30 | scripts/ 31 | dist/ 32 | -/ 33 | -.jar 34 | *.so -- if jni stuff was compiled 35 | *.jnilib -- if jni stuff was compiled 36 | libs/ -- dependent jars (and any extra) 37 | config/ -- copied over from config/ 38 | resources/ -- from src/main/resources/ 39 | 40 | 41 | Primary targets 42 | --------------- 43 | - clean 44 | - erase all generated/built files 45 | - distclean 46 | - clean *everything* 47 | - prepare 48 | - resolve dependencies and download them 49 | - compile 50 | - build any java/scala source 51 | - test 52 | - build and run test suite (requires e:testclass) 53 | - stress 54 | - (optional) run stress test suite (requires e:stresstestclass) 55 | - docs 56 | - generate documentation 57 | - package 58 | - copy all generated/built files into distribution folder 59 | (requires "local" repo) 60 | - push 61 | - copy all generated/built files into a final repository 62 | (requires "push" repo) 63 | 64 | 65 | Properties that can change behavior 66 | ----------------------------------- 67 | 68 | - skip.download 69 | if defined, don't download ivy; assume it's present 70 | - skip.test 71 | if defined, don't run test suite 72 | - skip.docs 73 | if defined, don't build docs 74 | - libs.extra 75 | any extra files to copy into dist/

/libs/ during compile 76 | - dist.extra 77 | any extra files to copy into dist/

during compile 78 | - config.extra 79 | any extra files to copy into config/ during compile 80 | - pack.deps 81 | if defined, pack dependent jars into the final dist jar, to remove dependencies 82 | - thrift.bin 83 | location of the "thrift" executable 84 | - push.build_name 85 | if defined, add the build name (and git revision) to jars when pushed to the repo 86 | - dist.build_name 87 | if defined, add the git revision to the name of the final distribution zip file 88 | - no.git 89 | if defined, don't try to fetch the current git head revision 90 | 91 | 92 | Extra ivy thingies 93 | ------------------ 94 | 95 | - e:buildpackage 96 | causes a build.properties file to be created in the named package 97 | (stores version #, etc -- used by RuntimeEnvironment in configgy) 98 | - e:thriftpackage 99 | output package for generated thrift classes; causes thrift DDLs to be 100 | compiled 101 | - e:testclass 102 | class to execute for unit tests -- required, in order to run tests 103 | - e:stresstestclass 104 | class to execute for stress tests (optional) 105 | - e:jarclassname 106 | creates an executable jar with this as the main class name 107 | 108 | 109 | JNI 110 | --- 111 | 112 | JNI will be built if there appears to be a `build.xml` file in src/main/jni/. 113 | That ant file should contain a "clean" target and a "compile" target. 114 | 115 | Post-compile, the jni/ folder is expected to look like this: 116 | src/ 117 | main/ 118 | jni/ 119 | build.xml -- used to build the jni packages 120 | / 121 | target/ 122 | *.so -- copied into dist/

/ 123 | *.jnilib -- copied into dist/

/ 124 | *.jar -- copied into dist/

/ 125 | 126 | There may be as many folders in jni/ as you desire. 127 | 128 | -------------------------------------------------------------------------------- /ant/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 105 | 106 | 107 | 108 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /ant/compile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 182 | 183 | 184 | --------------------------------------------------------------------------------