gradle war task customizing

gradle 2020. 9. 22. 18:00


- webapp 폴더가 필요한경우
/src/main/webapp로 생성 (default 위치)



- war build시 include 되는 jar 파일명 변경

build.gradle
war {
	~~
	rootSpec.rename('spring-boot.jar', 'spring-boot-rename.jar')
}



stackoverflow.com/questions/52184459/gradle-spring-boot-project-how-to-rename-files-in-war


- war
war task에서는 ${profile}을 사용 못하나 봄

war {
	enabled=true
	archiveFileName=ROOT.war
	rootSpec.exclude('**/static/*') // 해당폴더 하위 파일 제외
	rootSpec.exclude('**/static')   // 해당폴더 및 하위 파일 제외
	rootSpec.exclude('static')      // resources/static 폴더 및 하위 파일 제외

	// 파일명 변경, 파일 교체하기
	rootSpec.exclude('WEB-INF/test.ini')
	//rootSpec.rename('test.ini.prd', 'test.ini')
	rootSpec.rename('(.+)(.+).prd', '$1$2') // *.*.prd -> *.* (ex. test.ini.prd -> test.ini)
}




https://docs.gradle.org/current/userguide/war_plugin.html#sec:war_customizing

The War Plugin

The default behavior of the War task is to copy the content of src/main/webapp to the root of the archive. Your webapp directory may of course contain a WEB-INF sub-directory, which may contain a web.xml file. Your compiled classes are compiled to WEB-INF/

docs.gradle.org



- file moving
https://docs.gradle.org/current/userguide/working_with_files.html#sec:moving_files_example

Working With Files

You may have a need to copy not just files, but the directory structure they reside in as well. This is the default behavior when you specify a directory as the from() argument, as demonstrated by the following example that copies everything in the reports

docs.gradle.org



- copy
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html



- bootJar OR bootWar 실행시 파일 copy

bootJar {
    dependsOn asciidoctor
    copy {
        from "${asciidoctor.outputDir}"
        into 'BOOT-INF/classes/static/docs'
    }
}



https://velog.io/@max9106/Spring-Spring-rest-docs%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%AC%B8%EC%84%9C%ED%99%94

- 해볼 것
https://pcloud.tistory.com/m/33









'gradle' 카테고리의 다른 글

eclipse에서 gradle refresh가 안될 때  (0) 2020.10.30
소스품질 plugin 설명  (0) 2020.09.26
Could not run phased build action using Gradle distribution  (0) 2020.09.15
executable jar 생성  (0) 2020.09.01
gradle 파일 관련 API  (0) 2020.07.31
Posted by 張's blog
,