欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Gradle中如何部署上傳項(xiàng)目

這篇文章給大家分享的是有關(guān)Gradle中如何部署上傳項(xiàng)目的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

成都創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)營(yíng)銷推廣、網(wǎng)站重做改版、魚臺(tái)網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)商城網(wǎng)站建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為魚臺(tái)等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

方法如下: 

一、build.gradle

buildscript {
 ext {
 env = System.getProperty("env") ?: "test"
 jvmArgs = "-server -Xms128m -Xmx128m -XX:NewRatio=4 -XX:SurvivorRatio=16 -XX:MaxTenuringThreshold=15 -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+ExplicitGCInvokesConcurrent -XX:+DoEscapeAnalysis -XX:-HeapDumpOnOutOfMemoryError"
 if (env == "prod") {
 jvmArgs = "-server -Xms2g -Xmx2g -XX:NewRatio=4 -XX:SurvivorRatio=16 -XX:MaxTenuringThreshold=15 -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+ExplicitGCInvokesConcurrent -XX:+DoEscapeAnalysis -XX:-HeapDumpOnOutOfMemoryError"
 }
 userHome = System.getProperty("user.home")
 osName = System.getProperty("os.name")
 }

 repositories {
 jcenter()
 }
 dependencies {
 classpath 'org.hidetake:gradle-ssh-plugin:2.7.0'
 classpath 'co.tomlee.gradle.plugins:gradle-thrift-plugin:0.0.6'
 }
}

allprojects {
 apply plugin: 'idea'
 apply plugin: 'eclipse'
 apply plugin: 'org.hidetake.ssh'
 group = 'com.mwee.information.core'
 version = '1.0-SNAPSHOT'
 ssh.settings {
 timeoutSec = 60
 knownHosts = allowAnyHosts
 }
 defaultTasks 'clean', 'copyPartDependencies'

 //排除Log4j依賴
 configurations {
 compile.exclude module: 'slf4j-log4j12'
 compile.exclude module: 'org.apache.logging.log4j'
 compile.exclude module: 'log4j'
 all*.exclude group: 'org.apache.logging.log4j'
 all*.exclude group: 'log4j'
 }


}

subprojects {
 apply plugin: 'java'
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
 repositories {
 mavenLocal()
 maven { url "http://114.80.88.52:9001/nexus/content/groups/public/" }
 }
 sourceSets {
 main {
 java {
 srcDirs = ['src/main/java']
 }
 resources {
 srcDirs = ["src/main/resources", "src/main/profile/$env"]
 }
 }
 }
 dependencies {
 compile("org.codehaus.groovy:groovy-all:2.2.1")
 compile 'org.codehaus.groovy:groovy-backports-compat23:2.4.5'
 compile("org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE")
 compile("org.apache.commons:commons-lang3:3.4")
 compile("org.apache.commons:commons-collections4:4.1")
 compile "org.apache.commons:commons-pool2:2.4.2"
 compile group: 'com.alibaba', name: 'fastjson', version: '1.2.12'
 // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
 compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
 // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
 compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.6'
 compile group: 'org.aspectj', name: 'aspectjrt', version: '1.8.7'
 compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.7'
 compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.1'
 compile(group: 'org.mortbay.jetty', name: 'jetty', version: '6.1.26')
 compile group: 'org.projectlombok', name: 'lombok', version: '1.16.8'
 compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
 compile group: 'com.google.guava', name: 'guava', version: '18.0'
 compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
 compile group: 'com.jcraft', name: 'jsch', version: '0.1.53'
 testCompile group: 'junit', name: 'junit', version: '4.12'
 testCompile "org.springframework:spring-test:4.3.4.RELEASE"
 compile "javax.validation:validation-api:1.1.0.Final"
 compile "org.hibernate:hibernate-validator:5.2.4.Final"
 }
 //gradle utf-8 compile
 tasks.withType(JavaCompile) {
 options.encoding = 'UTF-8'
 }

 task copyAllDependencies(type: Copy, dependsOn: jar) {
 description = "拷貝全部依賴的jar包"
 from configurations.runtime
 into 'build/libs'
 }

 task copyPartDependencies(type: Copy, dependsOn: jar) {
 description = "拷貝部分依賴的jar"
 from configurations.runtime
 into 'build/libs'
 doLast {
 file("build/libs").listFiles({ !it.name.endsWith("-SNAPSHOT.jar") } as FileFilter).each {
 it.delete()
 }
 }
 }
}

二、對(duì)應(yīng)模塊下的build.gradle

def mainClass = "com.hzgj.information.rest.user.run.UserServiceProvider"
def appHome = "/home/appsvr/apps/rest_user"
def javaCommand = "nohup java $jvmArgs -Djava.ext.dirs=$appHome/libs -Denv=$env $mainClass >$appHome/shell.log 2>&1 &"
def index = System.getProperty("index")


def remote = remotes {
 test_0 {
 role 'test_0'
 host = '10.0.21.152'
 if (file("$userHome/.ssh/id_rsa").exists()) {
 user = 'appsvr'
 identity = file("$userHome/.ssh/id_rsa")
 } else {
 user = 'appsvr'
 password = 'xxx'
 }

 }


 test_1 {
 role 'test_1'
 host = '10.0.146.20'
 if (file("$userHome/.ssh/id_rsa").exists()) {
 user = 'appsvr'
 identity = file("$userHome/.ssh/id_rsa")
 } else {
 user = 'appsvr'
 password = 'xxx'
 }
 }
 home {
 role 'home'
 host = '192.168.109.130'
 user = 'appsvr'
 password = 'xxx'
 // identity = file('id_rsa')
 }


}
task deploy << {
 description = "拷貝jar包并啟動(dòng)java服務(wù)"
 def roles = remote.findAll {
 def currentEnv = index == null ? "$env" : "$env" + "_" + index
 it['roles'][0].toString().contains(currentEnv)
 }
 ssh.run {
 roles.each {
 def role = it['roles'][0].toString()
 session(remotes.role(role)) {
 try {
 execute("ls $appHome")
 } catch (Exception e) {
 println("#############目錄[$appHome]不存在,將自動(dòng)創(chuàng)建############")
 execute("mkdir -p $appHome")
 }
 finally {
 def r = '$1'
 def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'")
 if (pid) {
 execute("kill -9 $pid")
 }
 put from: 'build/libs', into: "$appHome"
 println("###############準(zhǔn)備啟動(dòng)java服務(wù)[$javaCommand]####################")
 execute("$javaCommand")
 sleep(10000)
 pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'")
 if (pid) {
 println("#####$mainClass [$pid] 啟動(dòng)成功...######")
 execute("rm -f $appHome/shell.log")
 } else {
 println("#$mainClass 啟動(dòng)失敗...輸出日志如下:#")
 execute("cat $appHome/shell.log")
 }
 }
 }
 }

 }
}

task stop << {
 def roles = remote.findAll {
 def currentEnv = index == null ? "$env" : "$env" + "_" + index
 it['roles'][0].toString().contains(currentEnv)
 }
 ssh.run {
 roles.each {
 session(remotes.role("$env")) {
 def r = '$1'
 def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'")
 if (pid) {
 execute("kill -9 $pid")
 }
 }
 }
 }
}
task start << {
 def roles = remote.findAll {
 def currentEnv = index == null ? "$env" : "$env" + "_" + index
 it['roles'][0].toString().contains(currentEnv)
 }
 ssh.run {
 roles.each {
 def role = it['roles'][0].toString()
 session(remotes.role(role)) {
 def r = '$1'
 def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'")
 if (pid) {
 execute("kill -9 $pid")
 }
 println("###############準(zhǔn)備啟動(dòng)java服務(wù)[$javaCommand]####################")
 execute("$javaCommand")
 sleep(10000)
 pid = execute("jps -l |grep '$main Class' |awk \'{print $r}\'")
 if (pid) {
 println("#$mainClass [$pid] 啟動(dòng)成功...#")
 execute("rm -f $appHome/shell.log")
 } else {
 println("#$mainClass 啟動(dòng)失敗...輸出日志如下:#")
 execute("cat $appHome/shell.log")
 }
 }
 }
 }
}

三、使用方式

1.先運(yùn)行gradle copyAll -x test 進(jìn)行打包操作,該操作會(huì)將該模塊所有的依賴的jar

2.進(jìn)入到對(duì)應(yīng)的模塊下 運(yùn)行gradle deploy -Denv=xxx -Dindex=xxx ,什么意思呢?-Denv代表哪一個(gè)環(huán)境 -Dindex指定該環(huán)境下哪個(gè)節(jié)點(diǎn)進(jìn)行發(fā)布

3.gradle start -Denv=xxx -Dindex=xxx 運(yùn)行當(dāng)前環(huán)境下的應(yīng)用

感謝各位的閱讀!關(guān)于“Gradle中如何部署上傳項(xiàng)目”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

本文名稱:Gradle中如何部署上傳項(xiàng)目
標(biāo)題來源:http://aaarwkj.com/article34/iggope.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、靜態(tài)網(wǎng)站、品牌網(wǎng)站制作、響應(yīng)式網(wǎng)站、關(guān)鍵詞優(yōu)化、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)
人妻日韩字幕一区二区| 日韩欧美亚洲国产一区久久精品 | 久久五十路六十路熟妇中出| 尤物视频网站在线观看| 亚洲国产精品一区二区成人| 国产一区二区成人精品| 少妇毛片一区二区三区| 91国内精品手机在线高清| 亚洲人妻激情一区二区| 亚洲激情一区在线观看| 亚洲女同中文字幕在线| 天天干夜夜操操操操| 欧美欧美一区二区三区| 欧美日韩一区二区综合在线视频| 国产精品一区二区高潮| 精品一区二区三区在线观看国产 | 日韩中文字幕一二一二区| 国产亚洲日本精品二区| 亚洲欧美日韩乱码综合久久| 精品一区二区久久久久久| 午夜性生活视频免费看| 亚洲国产精品一区二区| 国产在线精彩视频自拍| 日韩黄片大全在线观看| 国产成人啪精品视频免费| 99热视频在线观看免费| 国产精品_国产精品_k频道| 久久久国产精品视频一区| 一区二区在线视频中文字幕| 久亚洲精品色婷婷国产熟女| 国产一级二级三级久久| 欧美日韩亚洲精品亚洲欧洲| 久久婷婷欧美激情综合| 亚洲人妻av一区二区三区| 色偷偷亚洲精品一区二区| 成人精品国产一区二区| 成人精品午夜福利视频| 亚洲国产日韩中文字幕| 日韩欧美黄色三级视频| 国产精品一级片免费看| 懂色粉嫩蜜臀久久一区二区|