/*
 *	Run the InstallerUtil command inside ttc.jar
 */
apply plugin: 'java'

repositories {
	maven {
		url {{&RESOLVE_CONTEXTURL}} + {{&RESOLVE_REPO}}
		credentials {
			username = {{&REPO_USER}}
			password = {{&REPO_PASSWORD}}
		}
	}
}

dependencies {
	compile group: 'com.tooltwist', name: 'ttc', version: '{{TOOLTWIST_VERSION}}', transitive: true, changing: true
	compile 'org.mortbay.jetty:servlet-api:3.0.+'
}

// DEPLOY_FROM_LAUNCHPAD={{DEPLOY_FROM_LAUNCHPAD}}.

task(runSimple, dependsOn: 'classes', type: JavaExec) {
{{#DEPLOY_FROM_LAUNCHPAD}}
	// Controller install
	main = 'tooltwist.controller.util.InstallerUtil'
	classpath = sourceSets.main.runtimeClasspath
	args '{{&LAUNCHPAD}}'
	systemProperty 'TOOLTWIST_HOME', '{{&DESIGNER_DIR}}/site-conf'
	systemProperty 'LAUNCHPAD_DIR', '{{&PROJECT_ROOT}}'
{{/DEPLOY_FROM_LAUNCHPAD}}
{{^DEPLOY_FROM_LAUNCHPAD}}
	// Non-Controller install
	main = 'tooltwist.controller.util.NonControllerInstallerUtil'
	classpath = sourceSets.main.runtimeClasspath
	args '{{&HIDDEN_DIR}}/image'
	systemProperty 'TOOLTWIST_HOME', '{{&DESIGNER_DIR}}/site-conf'
	systemProperty 'LAUNCHPAD_DIR', '{{&PROJECT_ROOT}}'
{{/DEPLOY_FROM_LAUNCHPAD}}
}

defaultTasks 'runSimple'
