How to refer to resources folder in debug mode?


(malini kennady) #1

I want to debug my web application in Jetty using gradle. I have some of my property files in source code. Since these files are not copied to WAR, I used the below code to use resources folder,

sourceSets.main.resources { 
	srcDirs = ["src/main/java"]; include "**/*.*" 
}

This includes properties files in WAR. But when I debug in eclipse, it points to classes folder which doesnot contain properties folder. How to make debug to point to resources folder?

Build.gradle:

war {
    	doFirst {
    		def propertyFile = file "src/main/java/com/properties/about/About.properties"
    		def props = new Properties()
    		propertyFile.withReader { props.load(it) }
    		println "Before setProperty:"
    		println props.getProperty('releaseDate')
    		props.setProperty('releaseDate', new Date().format('yyyy-MM-dd-HH:mm:ss'))
        	propertyFile.withWriter { props.store(it, null) }
    		println "After setProperty:"
    		println props.getProperty('releaseDate')
    	} 
    	buildDir = new File(rootProject.projectDir, "gradleBuild/" + project.name)
    }

(malini kennady) #2

I solved this by creating src/main/resources folder and included all files other than class files in it. Say, I created properties\sample.properties and referred this path in code. Now there occurs no issue while debugging and also when deployed as WAR. By having resources folder all the files are included in WAR without having to modify build.gradle