1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| plugins { id 'war' id 'java' id 'org.hidetake.ssh' version '2.9.0' id 'org.akhikhl.gretty' version '2.0.0' }
gretty { httpPort = 8080 contextPath = '' servletContainer = 'tomcat8'
inplaceMode = 'hard' debugSuspend = false managedClassReload = true recompileOnSourceChange = true
jvmArgs = ["-javaagent:${project.projectDir}/springloaded-1.2.8.RELEASE.jar", '-noverify'] }
repositories { mavenCentral() }
ext { environment = System.getProperty("env", "development") war.archiveName = 'Fox.zip' }
ext.versions = [ spring : '5.0.2.RELEASE', springSecurity: '5.0.0.RELEASE', springSession : '1.3.1.RELEASE', servlet : '4.0.0', lombok : '1.16.18', fastjson : '1.2.41', thymeleaf : '3.0.9.RELEASE', mysql : '5.1.21', mybatis : '3.4.5', mybatisSpring : '1.3.1', druid : '1.1.5', validator : '6.0.5.Final', commonsLang : '3.7', commonsFileupload: '1.3.3', snakeyaml : '1.19', easyOkHttp : '1.1.3', logback : '1.2.3', junit : '4.12', jclOverSlf4j : '1.7.25' ]
dependencies { compile( "org.springframework:spring-webmvc:${versions.spring}", "org.springframework:spring-context-support:${versions.spring}", "org.springframework.security:spring-security-web:${versions.springSecurity}", "org.springframework.security:spring-security-config:${versions.springSecurity}", "org.springframework.session:spring-session-data-redis:${versions.springSession}", "com.alibaba:fastjson:${versions.fastjson}", "org.thymeleaf:thymeleaf-spring5:${versions.thymeleaf}", "mysql:mysql-connector-java:${versions.mysql}", "org.springframework:spring-jdbc:${versions.spring}", "org.mybatis:mybatis-spring:${versions.mybatisSpring}", "org.mybatis:mybatis:${versions.mybatis}", "com.alibaba:druid:${versions.druid}", "org.hibernate.validator:hibernate-validator:${versions.validator}", "org.apache.commons:commons-lang3:${versions.commonsLang}", "commons-fileupload:commons-fileupload:${versions.commonsFileupload}", "org.yaml:snakeyaml:${versions.snakeyaml}", "com.mzlion:easy-okhttp:${versions.easyOkHttp}", "ch.qos.logback:logback-classic:${versions.logback}", "org.slf4j:jcl-over-slf4j:${versions.jclOverSlf4j}" )
compileOnly("org.projectlombok:lombok:${versions.lombok}") compileOnly("javax.servlet:javax.servlet-api:${versions.servlet}") testCompile("org.springframework:spring-test:${versions.spring}") testCompile("junit:junit:${versions.junit}") }
processResources { println "==> Load configuration for '${environment}'" def configFile = file('config.groovy') def props = new ConfigSlurper(environment).parse(configFile.toURI().toURL()).toProperties()
from(sourceSets.main.resources.srcDirs) { filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: props) } }
remotes { server { host = '192.168.82.133' user = 'root' identity = file("${System.properties['user.home']}/.ssh/id_rsa") } }
ssh.settings { knownHosts = allowAnyHosts }
task deploy(dependsOn: war) { def targetDir = '/data/xtuer.com' doLast { ssh.run { session(remotes.server) { put from: "${buildDir}/libs/${war.archiveName}", into: "${targetDir}" execute """ source /root/.bash_profile; /usr/local/tomcat/bin/shutdown.sh; rm -rf ${targetDir}/ROOT; unzip -u ${targetDir}/${war.archiveName} -d ${targetDir}/ROOT > /dev/null; kill `ps aux | grep -i tomcat | grep -v grep | awk '{print \$2}'`; /usr/local/tomcat/bin/startup.sh; rm -rf ${targetDir}/${war.archiveName}; """ } } } }
sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile) { options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' }
|