plugins { id 'war' id 'java' id "de.undercouch.download" version "4.1.2" } group 'ch.hevs.sdi' version '1.0-SNAPSHOT' repositories { mavenCentral() } dependencies { providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.3' } task downloadTomcat(type: Download) { onlyIf { !file('tomcat').exists() && !file('tomcat.zip').exists() } src "https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.zip" dest new File("tomcat.zip") } task installTomcat(dependsOn: downloadTomcat, type: Copy) { onlyIf { !file('tomcat').exists() } from zipTree(downloadTomcat.dest) into projectDir fileMode 0777 doLast { delete("tomcat.zip") file("apache-tomcat-9.0.56").renameTo(file("tomcat")) } } clean.doFirst { delete 'tomcat' }