Could not find method set() for arguments [config.env, config] on root project


(Gary Mason) #1

Hi, I’m new to gradle and am trying my first build using a colleague’s 2.3 build script with 3.1. I’m getting an error at line 21:
A problem occurred evaluating root project ‘GMDatahub’.

Could not find method set() for arguments [config.env, config.dev] on root project ‘GMDatahub’ of type org.gradle.api.Project.

I’m running with gradle -Penv=dev. The first 21 lines of the build.gradle file are below. Any help appreciated.

apply plugin: 'java’
apply plugin: ‘eclipse’

task deployToTomcat(dependsOn: [‘loadEnvironmentProperties’, ‘cleanTomcat’, ‘copyConfig’, ‘copyEncrypton’]) << {
description ‘Copies the various datahub config files and the war to tomcat. Use the -Penv parameter to specify an environment’
}

task loadEnvironmentProperties {
description ‘Loads the environment specific properties. Use the -Penv parameter to specify an environment’

logger.info('Loading environment config')

// Load the environment specific properties
Properties props = new Properties()
if (project.hasProperty('env')) {
	def folder = new File( 'config.' + env)

	if (folder.isDirectory()) {
		logger.info('config.' + env + ' is a folder, using ' + env + ' config')
		props.load(new FileInputStream('config.' + env + '/gradle.properties'))
		project.set('config.env', 'config.' + env)