gradle-使用系列1

gradle 编译java或者scala的工程:

1.简单的编译代码,打包成jar 这只需要配置: 

project(':data-client') {
}

打包后的jar包 在 build/libs/目录下 

2.编译部署,打包所有的代码和依赖包到tar或者zip中:

project(':xxx-server') {
    apply plugin: 'application'
    // project start script name
    applicationName = 'xxx-service'
    // project main class name
    mainClassName = 'com.xxx.Server'

    // project runtimes JVM options
    applicationDefaultJvmArgs = ["-server",
                     "-Xms8g",
                     "-Xmx16g",
                     "-XX:MaxTenuringThreshold=0",
                     "-XX:+UseG1GC",
                     "-XX:MaxGCPauseMillis=50",
                     "-XX:G1HeapRegionSize=32m",
                     "-XX:InitiatingHeapOccupancyPercent=70",
                     "-XX:G1HeapWastePercent=5",
                     "-XX:+ParallelRefProcEnabled",
                     "-XX:G1MixedGCCountTarget=16",
                     "-XX:+UnlockExperimentalVMOptions",
                     "-XX:G1OldCSetRegionThresholdPercent=5",
                     "-XX:G1NewSizePercent=5",
                     "-XX:G1MaxNewSizePercent=15",
                     "-verbose:gc",
                     "-verbose:jni",
                     "-XX:+PrintGCDetails",
                     "-XX:+PrintGCDateStamps",
                     "-XX:+PrintGCApplicationStoppedTime",
                     "-XX:+PrintHeapAtGC",
                     "-XX:+PrintGCCause",
                     "-XX:+PrintTenuringDistribution",
                     "-XX:+PrintReferenceGC",
                     "-XX:+PrintPromotionFailure",
                     "-XX:+PrintJNIGCStalls",
                     "-XX:+PrintAdaptiveSizePolicy",
                     "-Xloggc:./logs/jvm/gc.log",
                     "-Dorg.jboss.netty.epollBugWorkaround=true",
                     "-Dio.netty.epollBugWorkaround=true",
                     "-XX:+UnlockDiagnosticVMOptions",
                     "-XX:+UnlockCommercialFeatures",
                     "-XX:+FlightRecorder",
                     "-XX:FlightRecorderOptions=defaultrecording=true,disk=true,maxchunksize=32m,repository=./logs/jvm/jfr,maxage=168h,maxsize=8g,dumponexit=true,dumponexitpath=./logs/jvm/jfr"]
    distributions {
        main {
        contents {
            into('conf') {
            from { 'src/main/resources/xxx.conf' }
            }
        }
        }
    }

    buildscript {
        repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        }
        dependencies {
        classpath "gradle.plugin.com.github.maiflai:gradle-scalatest:0.13"
        }
    }

}

编译打包后的工程文件在build/distributions/ 下面, 有tar 和zip两个包

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值