Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
build.gradle 11.40 KB
Copy Edit Web IDE Raw Blame History
def gradleVer = "4"
if (gradle.gradleVersion.startsWith("6")
|| gradle.gradleVersion.startsWith("5")
|| gradle.gradleVersion.startsWith("4.10")
|| gradle.gradleVersion.startsWith("4.9")
|| gradle.gradleVersion.startsWith("4.8")
|| gradle.gradleVersion.startsWith("4.7")) {
println "Gradle with version >= 4.7 detected"
gradleVer = "5"
} else {
println "Gradle with version < 4.7 detected"
}
// Due to a bug of spotbugs, the following lines have to be defined on top as well
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.5"
}
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
if (!gradle.startParameter.isOffline()) {
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: "com.github.spotbugs"
apply plugin: 'signing'
}
group 'com.webank'
version = "0.0.0"
def versionFile = file("VERSION")
versionFile.eachLine { line ->
version = line
}
println 'Current product version: ' + version
// Specify JDK version - may vary in different scenarios
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
// In this section you declare where to find the dependencies of your project
repositories {
if (!gradle.startParameter.isOffline()) {
mavenLocal()
mavenCentral()
maven { url "https://dl.bintray.com/ethereum/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/groups/public/" }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
} else {
maven {
url 'dependencies'
}
}
}
List lombok = [
"org.projectlombok:lombok:1.18.10"
]
List logger = [
"org.slf4j:jul-to-slf4j:1.7.30",
"org.apache.logging.log4j:log4j-api:2.13.3",
"org.apache.logging.log4j:log4j-core:2.13.3",
"org.apache.logging.log4j:log4j-slf4j-impl:2.13.3",
"org.apache.logging.log4j:log4j-web:2.13.3",
"org.apache.logging.log4j:log4j-jcl:2.13.3",
"com.lmax:disruptor:3.3.7"
]
// junit test
List junit = [
"junit:junit:4.12"
]
List apache_commons = [
"org.apache.commons:commons-collections4:4.1",
"org.apache.commons:commons-lang3:3.5",
"commons-cli:commons-cli:1.3.1"
]
List jmockit = [
"org.jmockit:jmockit:1.47"
]
List json = [
"com.fasterxml.jackson.core:jackson-databind:2.11.0",
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.0",
"com.github.fge:json-schema-validator:2.2.6",
"com.github.reinert:jjschema:1.16",
"org.jsonschema2pojo:jsonschema2pojo-core:1.0.1"
]
List mysql_driver = [
"mysql:mysql-connector-java:8.0.20",
"org.apache.commons:commons-dbcp2:2.5.0"
]
List zxing = [
"com.google.zxing:core:3.3.3",
"com.google.zxing:javase:3.3.3"
]
List rpc = [
'org.smartboot.socket:aio-core:1.4.2',
'org.smartboot.socket:aio-pro:1.4.2'
]
List pdfbox = [
"org.apache.pdfbox:pdfbox:2.0.16"
]
List protobuf = [
"com.google.protobuf:protobuf-java:3.9.1"
]
List caffeine = [
"com.github.ben-manes.caffeine:caffeine:2.8.0"
]
List oval = [
"net.sf.oval:oval:1.90"
]
configurations {
localDeps
}
dependencies {
localDeps 'org.projectlombok:lombok:1.18.10'
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.21") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
// exclude group: "org.fisco-bcos", module: "web3sdk"
// exclude group: "org.fisco-bcos", module: "web3sdk-weevent"
}
// Uncomment these two lines and exclude those above to specify web3sdk versions
// compile("org.fisco-bcos:web3sdk:2.4.1")
// compile("org.fisco-bcos:web3sdk-weevent:1.2.6")
compile fileTree(dir: 'lib', include: '*.jar')
testCompile logger, lombok, apache_commons, json, junit, jmockit, rpc, pdfbox, protobuf, caffeine, oval
} else {
compile fileTree(dir: 'dist/lib', include: '*.jar')
}
}
if (gradleVer.startsWith("5")) {
if (!gradle.startParameter.isOffline()) {
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
compile logger, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.21") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
// exclude group: "org.fisco-bcos", module: "web3sdk"
// exclude group: "org.fisco-bcos", module: "web3sdk-weevent"
}
// Uncomment these two lines and exclude those above to specify web3sdk versions
// compile("org.fisco-bcos:web3sdk:2.4.1")
// compile("org.fisco-bcos:web3sdk-weevent:1.2.6")
compile fileTree(dir: 'lib', include: '*.jar')
testCompile logger, apache_commons, json, junit, jmockit, rpc, pdfbox, protobuf, caffeine, oval
} else {
compileOnly files('dist/lib/lombok-1.18.10.jar')
annotationProcessor files('dist/lib/lombok-1.18.10.jar')
testAnnotationProcessor files('dist/lib/lombok-1.18.10.jar')
testCompileOnly files('dist/lib/lombok-1.18.10.jar')
compile fileTree(dir: 'dist/lib', include: '*.jar')
}
}
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
processResources {
exclude '**/**'
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
test {
systemProperty "jdk.tls.namedGroups", "${jdkTlsNamedGroups}"
jvmArgs "-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}"
doFirst {
copy {
from file('src/main/resources/WeDPR_dynamic_lib')
into 'src/test/resources/WeDPR_dynamic_lib'
}
}
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
jar {
baseName = project.name
destinationDir file('dist/app')
archiveName project.name + "-" + version + ".jar"
exclude '**/*.xml'
exclude '**/*.properties'
doLast {
copy {
from file('src/main/resources/')
into 'dist/conf'
}
copy {
from file('dist/lib/NotoSansCJKtc-Regular.ttf')
into 'src/main/resources/'
}
copy {
from file('dist/lib/NotoSansCJKtc-Regular.ttf')
into 'src/test/resources/'
}
if (!gradle.startParameter.isOffline()) {
copy {
from configurations.runtime
from configurations.testCompile.allArtifacts.files
from configurations.testCompile
from configurations.localDeps
into 'dist/lib'
}
}
}
}
if (!gradle.startParameter.isOffline()) {
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
jacoco {
toolVersion = "0.8.5"
}
check.dependsOn jacocoTestReport
checkstyle {
ignoreFailures false
showViolations true
toolVersion '8.12'
configProperties.projectDir = project.projectDir
checkstyleMain.configFile = new File(project.projectDir, '/config/checkstyle/webank_google_checks.xml')
checkstyleTest.configFile = new File(project.projectDir, '/config/checkstyle/webank_google_checks.xml')
}
tasks.withType(Checkstyle) {
include '**/*.java'
exclude '**/contract/deploy/*.java'
exclude '**/contract/deploy/v1/*.java'
exclude '**/contract/deploy/v2/*.java'
exclude '**/contract/v1/*.java'
exclude '**/contract/v2/*.java'
exclude '**/protocol/response/timestamp/wesign/*.java'
exclude '**/protocol/request/timestamp/wesign/*.java'
reports {
xml.enabled false
html.enabled true
}
}
spotbugs {
ignoreFailures = true
showProgress = true
toolVersion = "3.1.8"
effort = "max"
reportLevel = "low"
excludeFilter = file("${project.rootDir}/config/spotbugs/spotbugs_filter.xml")
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled false
html.enabled true
html.stylesheet resources.text.fromFile('config/spotbugs.xsl')
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name project.name
packaging 'jar'
description 'WeIdentity Java SDK'
url 'https://github.com/WeBankFinTech/WeIdentity'
scm {
url 'scm:git@github.com:WeBankFinTech/WeIdentity.git'
connection 'scm:git@github.com:WeBankFinTech/WeIdentity.git'
developerConnection 'git@github.com:WeBankFinTech/WeIdentity.git'
}
licenses {
license {
name 'GNU Lesser General Public License version 3'
url 'https://opensource.org/licenses/LGPL-3.0'
distribution 'repo'
}
}
developers {
developer {
id 'tonychen'
name 'tonychen'
}
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it.name == 'build' || it.name == 'assemble' }) {
tasks.findAll {
it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar'
}.each { task ->
task.enabled = false
}
}
}

Comment ( 0 )

Sign in for post a comment