import org.h2.tools.Console; buildscript { repositories { mavenCentral() } dependencies { classpath group: "com.h2database", name: "h2", version: "1.4.200" } } plugins { id "war" id "application" } application { mainClass="Start" } repositories { mavenCentral() } dependencies { providedCompile group: "javax.servlet", name: "javax.servlet-api", version: "4.0.1" // jetty 10 supports servlet 4 def jettyVer = "10.+" implementation group: "org.eclipse.jetty", name: "jetty-webapp", version: jettyVer implementation group: "org.eclipse.jetty", name: "jetty-annotations", version: jettyVer implementation group: "org.eclipse.jetty", name: "apache-jsp", version: jettyVer implementation group: "org.eclipse.jetty", name: "jetty-slf4j-impl", version: jettyVer implementation group: "com.h2database", name: "h2", version: "1.4.200" implementation group: "ch.qos.logback", name: "logback-classic", version: "1.2.5" implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69' } tasks.register("deployWar", Sync) { into "${projectDir}/deploy" with war } tasks.register("db") { doLast { new org.h2.tools.Console().runTool("-user", "sa", "-url", "jdbc:h2:${projectDir}/db/db/users;AUTO_SERVER=TRUE;IFEXISTS=TRUE"); } } clean { delete "${projectDir}/deploy" } // Skip the war task (since NetBeans uses it when you have a web app open), // and make it call the run task instead war { onlyIf { false } // add db to WAR from 'db' dependsOn run } // Make run only run if we explicitly run it (or NetBeans runs war) run { onlyIf { project.gradle.startParameter.taskNames.intersect(["war","run"]) } dependsOn deployWar }