Index: build.gradle =================================================================== diff -u -r16692 -r16831 --- build.gradle (.../build.gradle) (revision 16692) +++ build.gradle (.../build.gradle) (revision 16831) @@ -90,37 +90,6 @@ } } - test { - // set heap size for the test JVM(s) - minHeapSize = "128m" - maxHeapSize = "512m" - - // show standard out and standard error of the test JVM(s) on the console - testLogging.showStandardStreams = true - - // set JVM arguments for the test JVM(s) - jvmArgs '-XX:MaxPermSize=256m' - - // listen to events in the test execution lifecycle - beforeTest { descriptor -> - logger.lifecycle("Running test: " + descriptor) - } - - // listen to standard out and standard error of the test JVM(s) - onOutput { descriptor, event -> - logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) - } - - ignoreFailures = true //use this to allow build to continue for CI purposes - useTestNG(){ - suites "src/test/resources/test/forgon/AllTests.xml" //pick up centralized xml suite for each sub project - } - //useTestNG() { - // runlist to executed. path is relative to current folder - //suites 'src/test/java/test/forgon/AllTests.xml' - //} - } - configurations { all*.transitive = false Index: ssts-web/build.gradle =================================================================== diff -u -r16739 -r16831 --- ssts-web/build.gradle (.../build.gradle) (revision 16739) +++ ssts-web/build.gradle (.../build.gradle) (revision 16831) @@ -20,6 +20,71 @@ } +test { + /* + // set heap size for the test JVM(s) + minHeapSize = "128m" + maxHeapSize = "1024m" + + // show standard out and standard error of the test JVM(s) on the console + testLogging.showStandardStreams = true + + // set JVM arguments for the test JVM(s) + jvmArgs '-XX:MaxPermSize=512m' + + // listen to events in the test execution lifecycle + beforeTest { descriptor -> + logger.lifecycle("Running test: " + descriptor) + } + + // listen to standard out and standard error of the test JVM(s) + onOutput { descriptor, event -> + logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) + } + + ignoreFailures = true //use this to allow build to continue for CI purposes + + if (System.getProperty('DEBUG', 'false') == 'true') { + jvmArgs '-Xdebug', + '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009' + } +*/ + ignoreFailures = true //use this to allow build to continue for CI purposes + useTestNG() + //{ + // suites 'src/test/resources/test/forgon/AllTests.xml' + //} +} + + +tasks.withType(Test) { + testLogging { + // set options for log level LIFECYCLE + events "passed", "skipped", "failed", "standardOut" + showExceptions true + exceptionFormat "full" + showCauses true + showStackTraces true + + // set options for log level DEBUG and INFO + debug { + events "started", "passed", "skipped", "failed", "standardOut", "standardError" + exceptionFormat "full" + } + info.events = debug.events + info.exceptionFormat = debug.exceptionFormat + + afterSuite { desc, result -> + if (!desc.parent) { // will match the outermost suite + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" + def startItem = '| ', endItem = ' |' + def repeatLength = startItem.length() + output.length() + endItem.length() + println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) + } + } + } +} + apply plugin: 'rebel' buildscript { repositories { @@ -162,15 +227,7 @@ } -task deleteWebAppClassesDir(type: Delete) { - def dirName = webAppClassesDir - file( dirName ).list().each{ - f -> - delete "${dirName}/${f}" - } -} -// task定义的名字后加上 <<,这样不会每次build都自动运行task - task cleanDir << { +def cleanDir_Method(){ println "运行任务1:cleanDir,删除WEB-INF/lib与WEB-INF/classes文件夹下的所有文件" FileTree tree = fileTree (dir: webAppLibDir); tree.each { File file -> @@ -180,7 +237,7 @@ delete webAppClassesDir } -task prepareSpringSecurityXmlFile << { +def prepareSpringSecurityXmlFile_Method(){ println "运行任务2:准备spring security xml文件,使用标准的或者项目定制的xml文件" // spring security.xml文件名的后缀,applicationContext-acegi-security-standard.xml.back def suffix = 'standard' @@ -197,21 +254,8 @@ } } -task copyToWebappClasses << { +def copyToWebappClasses_Method(){ println "运行任务3:copyToWebappClasses:拷贝classes与资源文件到WEB-INF/classes" - - // 从gradle的build文件夹拷贝资源文件和class文件到WEB-INF/classes,由于gradle的build夹的文件没有及时更新 - // 所有暂时改为拷贝bin文件夹里面的内容 - //copy { - // from './build/classes/main' - // into webAppClassesDir - // include '**/*.*' - //} - //copy { - // from './build/resources/main' - // into webAppClassesDir - // include '**/*.*' - //} // 直接拷贝resources文件夹的内容到WEB-INF/classes copy { @@ -227,8 +271,7 @@ } } - -task copyDependenciesToLibDir << { +def copyDependenciesToLibDir_Method(){ println "运行任务4:copyDependenciesToLibDir:拷贝依赖jar包到WEB-INF/lib" copy { from configurations.runtime @@ -239,7 +282,7 @@ } } -task prepareWebXmlFile << { +def prepareWebXmlFile_Method(){ println "运行任务5:prepareWebXmlFile:准备web.xml文件,使用标准的或者项目定制的web.xml文件" // web.xml文件名的后缀 def suffix = 'standard' @@ -255,6 +298,47 @@ } } +task cleanDir0 { + cleanDir_Method() +} + +task prepareSpringSecurityXmlFile0 { + prepareSpringSecurityXmlFile_Method() +} + +task copyToWebappClasses0 { + copyToWebappClasses_Method() +} + +task copyDependenciesToLibDir0 { + copyDependenciesToLibDir_Method() +} + +task prepareWebXmlFile0 { + prepareWebXmlFile_Method() +} + +// task定义的名字后加上 <<,这样不会每次build都自动运行task,也可改为doLast +task cleanDir << { + cleanDir_Method() +} + +task prepareSpringSecurityXmlFile << { + prepareSpringSecurityXmlFile_Method() +} + +task copyToWebappClasses << { + copyToWebappClasses_Method() +} + +task copyDependenciesToLibDir << { + copyDependenciesToLibDir_Method() +} + +task prepareWebXmlFile << { + prepareWebXmlFile_Method() +} + prepareSpringSecurityXmlFile.dependsOn cleanDir copyToWebappClasses.dependsOn prepareSpringSecurityXmlFile