Index: ssts-web/build.gradle =================================================================== diff -u -r16471 -r16504 --- ssts-web/build.gradle (.../build.gradle) (revision 16471) +++ ssts-web/build.gradle (.../build.gradle) (revision 16504) @@ -31,15 +31,40 @@ } } - +sourceSets { + main { + resources { + // 条件排除spring security配置文件 + exclude getExcludeSpringSecurityXmlFilePath() + } + } +} ext.webAppClassesDir = "../ssts-web/src/main/webapp/WEB-INF/classes" war{ - exclude 'WEB-INF/lib/*' + // 排除lib和classes文件夹,因为war命令会把src\main\java和src\main\resources的所有文件打包进war文件 + // 如果不排除,会导致war包内的文件重复 + exclude 'WEB-INF/lib/*' + exclude 'WEB-INF/classes/**' + } +// 返回打包时需要排除的sping security xml配置文件的路径 +// 做了单点登录后,中大五院的spring security有自己的xml配置,打包时需要根据项目类型进行选择性的打包 +// 如果是中大五院的项目,Spring Security的XML配置文件,使用在projects\zd5y文件夹下的 +def getExcludeSpringSecurityXmlFilePath() { + println "war cmd 项目名称:" + projectName + if (projectName == 'zd5y'){ + + return 'spring/applicationContext-acegi-security.xml' + } + else{ + return 'spring/projects/zd5y/applicationContext-acegi-security.xml' + } +} + task cleanDir { doLast { @@ -63,28 +88,7 @@ from './build/resources/main' into webAppClassesDir include '**/*.*' - - /* 如果是中大五院的项目,Spring Security的XML配置文件,使用在projects\zd5y文件夹下的, - 因此通过下面的代码删除在resources下面的文件 - */ - - //获取web项目的文件夹路径 - def webProjectDir = this.projectDir.getAbsolutePath() - - def props = new Properties() - - new File(webProjectDir + "/src/main/resources/jdbc.properties").withInputStream { - stream -> props.load(stream) - } - // 获取jdbc.properties文件中定义的项目的名字 - def projectName = props["project"] - - if (projectName == 'zd5y'){ - println "war 项目名称:" + projectName - - exclude "**/spring/applicationContext-acegi-security.xml" - } - + exclude getExcludeSpringSecurityXmlFilePath() } }