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两个包