Index: ssts-web/build.gradle =================================================================== diff -u -r27949 -r27959 --- ssts-web/build.gradle (.../build.gradle) (revision 27949) +++ ssts-web/build.gradle (.../build.gradle) (revision 27959) @@ -1,5 +1,8 @@ +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 - apply plugin: 'java' apply plugin: 'war' @@ -142,7 +145,8 @@ main { resources { - + //TODO:以下的文件夹,移动到了ROOT\disinfectsystem\config文件夹下,要考虑是否需要修改路径 + /* // 排除spring security配置的备份文件 exclude 'spring/security/*.back' @@ -159,6 +163,7 @@ exclude 'config/' + it.name + '/**' } } + */ } } } @@ -257,9 +262,46 @@ } +// 更新发布包的版本号信息,便于识别 +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) + + // 保存properties文件 + versionFileBuilder.save() + + /* + //File propsFile = new File("{${webProjectDir}/src/main/webapp/sstsVersion.properties") + def props1 = new Properties() + File propsFile = new FileInputStream("${webProjectDir}/src/main/webapp/sstsVersion.properties") + //props.load(propsFile.newDataInputStream()) + props1.load(propsFile) + + props1.setProperty("globalVersion", globalVersion) + props1.setProperty("svnRevision", svnRevision) + + props1.store(propsFile.newWriter(), null) + */ + +} + war{ - archiveName 'ssts-web-' + projectName + '-' + globalVersion + '.war' + updateVersionFile() + + archiveName 'ssts-web-' + projectName + '-' + globalVersion + '-R' + svnRevision + '.war' // 排除lib和classes文件夹,因为war命令会把src\main\java和src\main\resources的所有文件打包进war文件 // 如果不排除,会导致war包内的文件重复 exclude 'WEB-INF/lib/*' @@ -287,22 +329,37 @@ } def prepareSpringSecurityXmlFile_Method(){ - println "运行任务2:准备spring security xml文件,使用标准的或者项目定制的xml文件" - // spring security.xml文件名的后缀,applicationContext-acegi-security-standard.xml.back - def suffix = 'standard' - if (projectName == 'hzszxrmyy' || projectName == 'dysyy' || projectName == 'gdsy' || projectName == 'gzzyyfy' || projectName == 'bjdxzlyy' || projectName == 'gdsrmyyzhyy' || projectName == 'cszxyy'|| projectName == 'szsdsrmyy'){ - suffix = projectName - } + println "运行任务2:准备spring security xml文件,使用标准的或者项目定制的xml文件" + //将spring security xml从folder1或者folder2拷贝到WEB-INF/spring文件夹 + //folder1:src\main\webapp\disinfectsystem\config\{projectName}\spring-security + //folder2:src\main\webapp\WEB-INF\spring-security-standard + + def springSecurityFileCustomized = webProjectDir + "/src/main/webapp/disinfectsystem/config/" + projectName + "/spring/security/applicationContext-acegi-security.xml" + def springSecurityFileStandard = webProjectDir + "/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml" + + def existCustomizedFile = file(springSecurityFileCustomized).exists() + + println "项目个性化的springSecurity文件是否存在 = " + existCustomizedFile + def springSecurityFileSource = springSecurityFileStandard + if (existCustomizedFile){ + springSecurityFileSource = springSecurityFileCustomized + } + def springSecurityDirTarget = webProjectDir + "/src/main/webapp/WEB-INF/spring" + // 如果spring security的目标文件夹不存在,则创建 + File file = new File(springSecurityDirTarget); + if (!file.exists()) { + file.mkdir(); + } + + copy { + from springSecurityFileSource + into springSecurityDirTarget + } + - def springSecurityDir = webProjectDir + "/src/main/resources/spring/security" - // 拷贝各项目的applicationContext-acegi-security-standard.xml.back,更名为applicationContext-acegi-security.xml - copy { - from springSecurityDir + '/applicationContext-acegi-security-' + suffix + ".xml.back" - into springSecurityDir - rename ('applicationContext-acegi-security-' + suffix + '.xml.back', 'applicationContext-acegi-security.xml') - } - + //TODO:terry kwan,2020-05-18 // esbmq-config.xml文件名的目录 + /* if (projectName == 'bjcylyy' || projectName == 'stdxfsdyyy'){ suffix = projectName def MQConfigDir = webProjectDir + "/src/main/resources/mqConfig"; @@ -313,6 +370,7 @@ rename ('esbmq-config-' + suffix + '.xml.back', 'esbmq-config.xml') } } + */ } @@ -345,18 +403,23 @@ } def prepareWebXmlFile_Method(){ - println "运行任务5:prepareWebXmlFile:准备web.xml文件,使用标准的或者项目定制的web.xml文件" - // web.xml文件名的后缀 - def suffix = 'standard' - if (projectName == 'cszxyy' || projectName == 'stdxyxyfszlyy' || projectName == 'szsdsrmyy'){ - suffix = projectName - } + println "运行任务5:prepareWebXmlFile:准备web.xml文件,使用标准的或者项目定制的web.xml文件" - // 拷贝各项目的web.xml,更名为web.xml + def webXmlFileCustomized = webProjectDir + "/src/main/webapp/disinfectsystem/config/" + projectName + "/web-xml/web.xml" + def webXmlFileStandard = webProjectDir + "/src/main/webapp/WEB-INF/web-xml-standard/web.xml" + + def existCustomizedFile = file(webXmlFileCustomized).exists() + + println "项目个性化的web.xml文件是否存在 = " + existCustomizedFile + def webXmlFileSource = webXmlFileStandard + if (existCustomizedFile){ + webXmlFileSource = webXmlFileCustomized + } + + // 拷贝各项目的web.xml到WEB-INF文件夹 copy { - from webInfDir + '/web-' + suffix + ".xml" + from webXmlFileSource into webInfDir - rename ('web-' + suffix + ".xml", 'web.xml') } }