dependencies {
	compile(
		'commons-io:commons-io:2.4',
		'org.json:json:20160212',
		project(':com.ibm.wala.cast'),
		project(':com.ibm.wala.cast.js'),
		project(':com.ibm.wala.cast.js.rhino'),
		project(':com.ibm.wala.core'),
		project(':com.ibm.wala.util'),
		)
}

task downloadNodeJS(type: de.undercouch.gradle.tasks.download.Download) {
	src 'https://api.github.com/repos/nodejs/node/zipball/0a604e92e258c5ee2752d763e50721e35053f135'
	dest new File(temporaryDir, 'nodejs.zip')
	overwrite false
}

task verifyNodeJS(type: VerifyWithStamp, dependsOn: downloadNodeJS) {
	src files(downloadNodeJS)[0]
	checksum '33c5ba7a5d45644e70d268d8ad3e57df'
}

task unpackNodeJSLib(type: Copy, dependsOn: verifyNodeJS) {
	from(zipTree(verifyNodeJS.src)) {
		include 'nodejs-node-0a604e9/lib/*.js'
		eachFile {
			relativePath new RelativePath(!directory, relativePath.lastName)
		}
	}

	into 'dat/core-modules'
	includeEmptyDirs false
}

task cleanUnpackNodeJSLib(type: Delete) {
	delete fileTree(dir: 'dat/core-modules', include: '*.js')
}

processResources.dependsOn unpackNodeJSLib
clean.dependsOn cleanUnpackNodeJSLib

sourceSets.main {
	java.srcDirs = ['src']
	resources.srcDirs = ['dat']
}
