1.安装jdk、ant、gradle(参考http://www.cnblogs.com/274914765qq/p/4401525.html)
2.下载Fitnesse
https://github.com/unclebob/fitnesse/
3.下载完成后,解压,并双击gradlew.bat,然后等待完成(时间较长)。
4.完成后,通过命令行进入fitnesse-master并使用下面的命令运行(会下载很多包,时间较长):
.\gradlew run
5.eclipse 安装gradle插件
参考:http://blog.csdn.net/buqutianya/article/details/50226721
6.将Fitnesse导入eclipse
a. File -> Import... -> Gradle Project
b. 选择fitnesse-master目录,确认后导入
7 例子
参考 http://www.cnblogs.com/moonpool/p/5547549.html
上面的例子中是使用ant工具构建的,现在新的fitnesse是使用gradle工具构建,所以在使用第三方的jar包时有些变化。
修改build.gradle文件
1 /* Plan: 2 - Create multi-module repo: 3 - fit (deps: common) 4 - slim (deps: common, networking) 5 - common 6 - networking 7 - ant 8 - fitnesse, the wiki server 9 - Move file creation to plugin 10 */ 11 12 buildscript { 13 repositories { 14 mavenCentral() 15 } 16 dependencies { 17 classpath ‘info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.9‘ 18 } 19 } 20 21 plugins { 22 id ‘java‘ 23 id "maven-publish" 24 id "com.jfrog.bintray" version "1.6" 25 } 26 27 apply plugin: "info.solidsoft.pitest" 28 29 30 version = new Date().format(‘yyyyMMdd‘) 31 32 println "Building FitNesse v${project.version}..." 33 34 repositories { 35 mavenCentral() 36 } 37 38 configurations { 39 lesscss 40 optional 41 compile { 42 transitive = false 43 extendsFrom optional 44 } 45 runtime { 46 transitive = false 47 } 48 } 49 50 sourceSets { 51 main { 52 java.srcDir ‘src‘ 53 resources.srcDir ‘src‘ 54 output.resourcesDir output.classesDir 55 } 56 test { 57 java.srcDir ‘test‘ 58 } 59 } 60 61 sourceCompatibility = ‘1.7‘ 62 targetCompatibility = ‘1.7‘ 63 64 dependencies { 65 compile "org.htmlparser:htmlparser:2.1" 66 compile "org.htmlparser:htmllexer:2.1" 67 compile "org.apache.velocity:velocity:1.7" 68 compile "commons-lang:commons-lang:2.6" 69 compile "commons-collections:commons-collections:3.2.2" 70 compile "org.json:json:20151123" 71 compile "com.googlecode.java-diff-utils:diffutils:1.3.0" 72 optional "org.apache.ant:ant:1.9.6" 73 optional "junit:junit:4.12" 74 75 testCompile "junit:junit:4.12" 76 testCompile "org.mockito:mockito-core:1.10.19" 77 testCompile "org.hamcrest:hamcrest-all:1.3" 78 testCompile "net.javacrumbs.json-unit:json-unit:1.1.6" 79 80 compileOnly files(‘lib/joda-time-2.3.jar‘) 81 82 lesscss "org.mozilla:rhino:1.7.7.1" 83 } 84 85 task fitNesseVersion { 86 def versionFile = new File("${sourceSets.main.output.resourcesDir}/META-INF/FitNesseVersion.txt") 87 versionFile.parentFile.mkdirs() 88 versionFile.text="v${version}" 89 } 90 91 task compileBootstrap(type: LessCompiler) { 92 inputDir file(‘src/fitnesse/resources/bootstrap/less‘) 93 mainLessFile = ‘fitnesse-bootstrap.less‘ 94 cssFile file("${sourceSets.main.output.resourcesDir}/fitnesse/resources/bootstrap/css/fitnesse-bootstrap.css") 95 classpath configurations.lesscss 96 } 97 98 task createUpdateLists(type: WikiFileListBuilderTask) { 99 outputDirectory = "${sourceSets.main.output.resourcesDir}/Resources" 100 doNotReplaceFiles = [ 101 "FitNesseRoot/FrontPage/content.txt", 102 "FitNesseRoot/FrontPage/properties.xml", 103 "FitNesseRoot/PageHeader/content.txt", 104 "FitNesseRoot/PageHeader/properties.xml", 105 "FitNesseRoot/PageFooter/content.txt", 106 "FitNesseRoot/PageFooter/properties.xml", 107 "FitNesseRoot/PageFooter/properties.xml", 108 "FitNesseRoot/TemplateLibrary/content.txt", 109 "FitNesseRoot/TemplateLibrary/properties.xml", 110 "FitNesseRoot/TemplateLibrary/StaticPage/content.txt", 111 "FitNesseRoot/TemplateLibrary/StaticPage/properties.xml", 112 "FitNesseRoot/TemplateLibrary/SuitePage/content.txt", 113 "FitNesseRoot/TemplateLibrary/SuitePage/properties.xml", 114 "FitNesseRoot/TemplateLibrary/TestPage/content.txt", 115 "FitNesseRoot/TemplateLibrary/TestPage/properties.xml" ] 116 mainDirectories = [ 117 "FitNesseRoot/FitNesse", 118 "FitNesseRoot/FrontPage", 119 "FitNesseRoot/PageFooter", 120 "FitNesseRoot/PageHeader", 121 "FitNesseRoot/TemplateLibrary" ] 122 } 123 124 processResources.dependsOn "fitNesseVersion", "compileBootstrap", "createUpdateLists" 125 126 task copyRuntimeLibs(type: Copy) { 127 into "lib" 128 from configurations.runtime 129 } 130 131 test { 132 dependsOn copyRuntimeLibs 133 maxParallelForks 1 134 } 135 136 pitest { 137 targetClasses = [‘fit.*‘, ‘fitnesse.*‘] 138 pitestVersion = "1.1.10" 139 threads = 1 // We can not deal with parallel execution yet 140 outputFormats = [‘XML‘, ‘HTML‘] 141 } 142 143 task run(type: JavaExec) { 144 dependsOn classes, copyRuntimeLibs 145 classpath = sourceSets.main.runtimeClasspath 146 main "fitnesseMain.FitNesseMain" 147 args "-p", "8001", "-e", "0" 148 } 149 150 jar { 151 dependsOn createUpdateLists 152 into(‘Resources‘) { 153 from(‘.‘) { 154 include ‘FitNesseRoot/FitNesse/**/content.txt‘ 155 include ‘FitNesseRoot/FitNesse/**/properties.xml‘ 156 include ‘FitNesseRoot/FrontPage/**/content.txt‘ 157 include ‘FitNesseRoot/FrontPage/**/properties.xml‘ 158 include ‘FitNesseRoot/PageFooter/**/content.txt‘ 159 include ‘FitNesseRoot/PageFooter/**/properties.xml‘ 160 include ‘FitNesseRoot/PageHeader/**/content.txt‘ 161 include ‘FitNesseRoot/PageHeader/**/properties.xml‘ 162 include ‘FitNesseRoot/TemplateLibrary/**/content.txt‘ 163 include ‘FitNesseRoot/TemplateLibrary/**/properties.xml‘ 164 } 165 } 166 manifest { 167 attributes("Main-Class": "fitnesseMain.FitNesseMain", 168 "Implementation-Version": version) 169 } 170 } 171 172 task standaloneJar(type: Jar, dependsOn: jar) { 173 baseName = ‘fitnesse‘ 174 classifier = ‘standalone‘ 175 from { 176 (configurations.compile - configurations.optional).collect { zipTree(it) } 177 } { 178 exclude ‘META-INF/**‘ 179 } 180 from jar.outputs.files.collect { 181 zipTree(it) 182 } 183 manifest { 184 attributes("Main-Class": "fitnesseMain.FitNesseMain", 185 "Implementation-Version": version) 186 } 187 } 188 189 task acceptanceTest(type: JavaExec) { 190 mustRunAfter test 191 onlyIf { dependsOnTaskDidWork() } 192 classpath = standaloneJar.outputs.files 193 main "fitnesseMain.FitNesseMain" 194 args "-o", "-c", "FitNesse.SuiteAcceptanceTests?suite&format=text" 195 } 196 197 check.dependsOn acceptanceTest 198 199 task javadocJar(type: Jar) { 200 mustRunAfter check 201 classifier = ‘javadoc‘ 202 from javadoc 203 } 204 205 task sourcesJar(type: Jar) { 206 mustRunAfter check 207 classifier = ‘sources‘ 208 from sourceSets.main.allSource 209 } 210 211 clean{ 212 delete "lib" 213 } 214 215 publishing { 216 publications { 217 FitNesseRelease(MavenPublication) { 218 from components.java 219 artifact sourcesJar 220 artifact javadocJar 221 artifact standaloneJar 222 groupId ‘org.fitnesse‘ 223 artifactId ‘fitnesse‘ 224 pom.withXml { 225 asNode().get(‘version‘) + { url(‘http://fitnesse.org‘) } 226 asNode().appendNode(‘description‘, ‘The fully integrated standalone wiki, and acceptance testing framework.‘) 227 asNode().append(pomLicenses()) 228 asNode().append(pomScm()) 229 asNode().append(pomDevelopers()) 230 231 // Clean up scope entries added by the pom generator: 232 asNode().dependencies.‘*‘.findAll() { 233 if (it.scope.text() == ‘runtime‘) { 234 it.remove(it.scope) 235 } 236 } 237 } 238 } 239 } 240 } 241 242 bintray { 243 user = System.getenv("BINTRAY_USER") ?: ‘Define your Bintray user name in BINTRAY_USER‘ 244 key = System.getenv("BINTRAY_API_KEY") ?: ‘Define your Bintray BINTRAY_API_KEY‘ 245 publications = [‘FitNesseRelease‘] 246 publish = true 247 pkg { 248 repo = System.getenv("BINTRAY_API_KEY") ?: ‘edge‘ 249 name = ‘fitnesse‘ 250 userOrg = ‘fitnesse‘ 251 licenses = [‘CPL-1.0‘] 252 websiteUrl = ‘http://fitnesse.org‘ 253 vcsUrl = ‘https://github.com/unclebob/fitnesse.git‘ 254 publicDownloadNumbers = true 255 githubRepo = ‘unclebob/fitnesse‘ 256 version { 257 name = project.version 258 desc = "FitNesse release ${project.version}" 259 vcsTag = project.version 260 gpg { 261 sign = true 262 } 263 } 264 } 265 } 266 267 wrapper { 268 gradleVersion = ‘2.13‘ 269 } 270 271 def pomLicenses() { 272 new NodeBuilder().licenses { 273 license { 274 name ‘Common Public License version 1.0‘ 275 url ‘http://www.opensource.org/licenses/cpl1.0‘ 276 distribution ‘repo‘ 277 } 278 } 279 } 280 281 def pomScm() { 282 new NodeBuilder().scm { 283 connection ‘scm:git:git://github.com/unclebob/fitnesse.git‘ 284 developerConnection ‘scm:git:[email protected]:unclebob/fitnesse.git‘ 285 url ‘scm:git:http://github.com/unclebob/fitnesse‘ 286 } 287 } 288 289 def pomDevelopers() { 290 new NodeBuilder().developers { 291 developer { 292 id ‘unclebob‘ 293 name ‘Robert C. Martin‘ 294 email ‘[email protected]‘ 295 } 296 } 297 }
上面代码中compileOnly files(‘lib/joda-time-2.3.jar‘)就是加入第三方jar的方法。
时间: 2024-10-13 15:53:01