import org.apache.commons.configuration2.builder.fluent.Parameters import org.apache.commons.configuration2.* import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler buildscript { repositories { mavenCentral() } } plugins { id 'org.springframework.boot' version '2.7.18' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'war' } sourceCompatibility = '1.8' test { reports { junitXml.enabled = true junitXml.destination = file('build/test-results/folder') } //ignoreFailures = true //use this to allow build to continue for CI purposes useJUnit() /* if (project.hasProperty("seleniumTests")){ filter { includeTestsMatching "test.forgon.disinfectsystem.selenium.ALL" } } else{ exclude "test.forgon.disinfectsystem.selenium.ALL" exclude "test.forgon.disinfectsystem.selenium2.ALL" } */ filter { if (project.hasProperty("seleniumTests")){ includeTestsMatching "test.forgon.disinfectsystem.selenium.ALL" }else if(project.hasProperty("seleniumTestsForDivideTestCases")){ includeTestsMatching "test.forgon.disinfectsystem.selenium3.AllTests" }else{ includeTestsMatching "test.forgon.AllTests" } } //reports.html.enabled = false ignoreFailures = true //use this to allow build to continue for CI purposes //{ // suites 'src/test/resources/test/forgon/AllTests.xml' //} // set a system property for the test JVM(s) // 设置文件编码为UTF-8,基础数据准备的json文件中有中文 systemProperty "file.encoding", "utf-8" // explicitly include or exclude tests include 'test/forgon/**' //exclude 'org/boo/**' // show standard out and standard error of the test JVM(s) on the console testLogging.showStandardStreams = true // set heap size for the test JVM(s) minHeapSize = "128m" maxHeapSize = "1024m" // set JVM arguments for the test JVM(s) jvmArgs '-XX:MaxPermSize=512m -XX:MaxNewSize=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 ) } } sourceSets { main { resources { //资源文件夹,gradle会复制到WEB-INF/classes文件夹 srcDirs = ['src/main/resources'] //TODO:以下的文件夹,移动到了ROOT\disinfectsystem\config文件夹下,要考虑是否需要修改路径 /* // 排除spring security配置的备份文件 exclude 'spring/security/*.back' // 遍历src/main/resources/spring/projects文件夹,如果不是本项目的文件夹,则添加exclude命令 new File(webProjectDir + "/src/main/resources/spring/projects").eachDir{ if (it.name != projectName){ exclude 'spring/projects/' + it.name + '/**' } } // 遍历src/main/resources/config文件夹,如果不是本项目的文件夹,则添加exclude命令 new File(webProjectDir + "/src/main/resources/config").eachDir{ if (it.name != projectName){ exclude 'config/' + it.name + '/**' } } */ } } } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } ext.webAppClassesDir = "../ssts-web/src/main/webapp/WEB-INF/classes" //configurations { // // other configurations e.g. - providedCompile.exclude module: 'commons-logging' // all*.transitive = false //} // 1. Get dependencies from Maven local repository // 2. Get dependencies from Maven central repository repositories { ivy { // URL can refer to a local directory url "../localrepo/" } mavenLocal() mavenCentral() maven { url "https://maven.aliyun.com/repository/jcenter" } // 阿里云 JCenter maven { url "https://maven.aliyun.com/repository/public" } // 阿里云公共仓库 maven { url "https://maven.aliyun.com/repository/google" } // 阿里云 Google 仓库 maven { url "https://maven.aliyun.com/repository/gradle-plugin" } // Gradle 插件仓库 } //Project dependencies dependencies { // sqlserver 12.0.0的驱动性能更好,在高并发或长时间运行的场景下带来大约 5%-15% 的性能提升 // 在某些复杂查询或频繁建立/关闭连接的场景中,较新的驱动可能更高效,减少了额外的开销 // 修复了一些潜在的内存泄漏和性能瓶颈问题,长期运行时能保持更稳定的性能 // 默认URL连接是加密的,需要数字证书,否则要在连接URL上声明encrypt=false // 完整的声明要加上:;encrypt=false;characterEncoding=UTF-8;sendStringParametersAsUnicode=true runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc:12.10.0.jre8' implementation('org.apache.neethi:neethi:3.0.2') { exclude group: 'org.codehaus.woodstox', module: 'woodstox-core-asl' } providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' runtime group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.14.1' runtime group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.14.1' runtime group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.14.1' runtime 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.14.1' runtime 'org.quartz-scheduler:quartz:2.2.1' //runtime 'com.mchange:c3p0:0.9.2.1' runtime 'com.mchange:c3p0:0.9.5.5' runtime 'com.mchange:mchange-commons-java:0.2.11' runtime 'javax.transaction:jta:1.1' //runtime 'net.sourceforge.jtds:jtds:1.3.1' // runtime 'com.microsoft.sqlserver:sqljdbc4:4.0' runtime 'dom4j:dom4j:1.6.1' runtime 'bsh:bsh:2.0b1' runtime 'activation:activation:1.1' runtime 'antlr:antlr:2.7.7' runtime 'net.sf.ezmorph:ezmorph:1.0.4' runtime 'wsdl4j:wsdl4j:1.6.2' // runtime 'org.freemarker:freemarker:2.3.16' runtime 'ognl:ognl:3.0.6' runtime 'cglib:cglib:3.2.0' runtime 'cglib:cglib-nodep:3.2.0' runtime 'xom:xom:1.2.5' runtime 'xml:xmlschema-core:2.0.3' // 这个包依赖了org.springframework:spring:2.0.3,会导致spring版本冲突,因此先移除 //runtime 'org.springmodules:spring-modules-validation:0.8' runtime 'commons-attributes:commons-attributes-api:2.1' runtime 'commons-chain:commons-chain:1.1' runtime 'commons-cli:commons-cli:1.0' runtime 'commons-codec:commons-codec:1.3' runtime 'commons-discovery:commons-discovery:0.2' runtime 'commons-el:commons-el:1.0' runtime 'commons-httpclient:commons-httpclient:3.0' runtime 'commons-jxpath:commons-jxpath:1.2' runtime 'commons-validator:commons-validator:1.3.1' runtime 'xalan:xalan:2.7.2' runtime 'xalan:serializer:2.7.2' runtime 'org.codehaus.groovy:groovy-all:3.0.18' runtime 'xml-resolver:xml-resolver:1.2' // runtime 'xerces:xercesImpl:2.7.1' runtime 'xml-apis:xml-apis:1.4.01' runtime 'xml:xmlsec:1.5.7' runtime 'org.apache.xmlbeans:xmlbeans:2.5.0' // runtime 'org.opensaml:xmltooling:1.3.2' // runtime 'woodstox:woodstox-core-asl:4.4.0' // runtime 'woodstox:stax2-api:3.1.4' // // implementation 'com.fasterxml.woodstox:woodstox-core:6.5.1' runtime 'org.apache.velocity:velocity:1.6.3' runtime 'org.apache.commons:commons-jci-core:1.1' runtime 'org.apache.commons:commons-jci-fam:1.1' runtime group: 'javax.el', name: 'javax.el-api', version: '3.0.1-b06' runtime files ('../localrepo/libs/ojdbc6.jar') runtime group: 'fckeditor', name: 'FCKeditor', version:'2.3' testCompile group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.13.1' } // 更新发布包的版本号信息,便于识别 def updateVersionFile(){ Parameters params = new Parameters() char aChar = ',' FileBasedConfigurationBuilder versionFileBuilder = new FileBasedConfigurationBuilder(PropertiesConfiguration.class) .configure(params.properties() .setFileName("${webProjectDir}/src/main/webapp/version.properties") .setListDelimiterHandler(new DefaultListDelimiterHandler(aChar))); Configuration versionConfig = versionFileBuilder.getConfiguration() versionConfig.setProperty("globalVersion", globalVersion) versionConfig.setProperty("svnRevision", svnRevision) versionConfig.setProperty("buildDateTime", buildDateTime) // 保存properties文件 versionFileBuilder.save() } def copyToWebappClasses_Method(){ println "运行任务3:copyToWebappClasses:拷贝classes与资源文件到WEB-INF/classes" // 直接拷贝resources文件夹的内容到WEB-INF/classes copy { from webProjectDir + "/src/main/resources" into webAppClassesDir include '**/*.*' } // TODO:需要把classes文件拷贝到WIN-INF/classes下面 copy { from './build/classes/java/main' into webAppClassesDir include '**/*.*' } }