1 Star 0 Fork 32

何一然 / WeIdentity

forked from WeBank / WeIdentity 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle 9.78 KB
一键复制 编辑 原始数据 按行查看 历史
chaoxinhu 提交于 2019-11-01 11:45 . Fix version and add changelog
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 = "1.4.1"
// 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/" }
} else {
maven {
url 'dependencies'
}
}
}
List lombok = [
"org.projectlombok:lombok:1.18.10"
]
List logger = [
"org.slf4j:jul-to-slf4j:1.7.10",
"org.apache.logging.log4j:log4j-api:2.1",
"org.apache.logging.log4j:log4j-core:2.1",
"org.apache.logging.log4j:log4j-slf4j-impl:2.1",
"org.apache.logging.log4j:log4j-web:2.1",
"org.apache.logging.log4j:log4j-jcl:2.3"
]
// 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.9"
]
List json = [
"com.fasterxml.jackson.core:jackson-databind:2.8.8.1",
"com.github.fge:json-schema-validator:2.2.6",
"com.github.reinert:jjschema:1.16"
]
List mysql_driver = [
"mysql:mysql-connector-java:5.1.44",
"org.apache.commons:commons-dbcp2:2.5.0"
]
List zxing = [
"com.google.zxing:core:3.3.0"
]
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"
]
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
compile("com.webank:weid-contract-java:1.2.9") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
testCompile logger, lombok, apache_commons, json, junit, jmockit, rpc, pdfbox
} 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
compile("com.webank:weid-contract-java:1.2.9") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
testCompile logger, apache_commons, json, junit, jmockit, rpc, pdfbox
} 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'
}
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
}
}
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'
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: System.getenv('SONATYPE_USERNAME'), password: System.getenv('SONATYPE_PASSWORD'))
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: System.getenv('SONATYPE_USERNAME'), password: System.getenv('SONATYPE_PASSWORD'))
}
pom.project {
name 'weid-java-sdk'
packaging 'jar'
description 'Java SDK for WeIdentity.'
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
}
}
import org.gradle.plugins.signing.Sign
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
allprojects { ext."signing.keyId" = System.getenv('GPG_KEY_ID') }
allprojects { ext."signing.secretKeyRingFile" = System.getenv('GPG_KEY_LOCATION') }
allprojects { ext."signing.password" = System.getenv('GPG_PASSPHRASE') }
}
// Do not sign archives by default (a local build without gpg keyring should succeed)
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
}
}
}
1
https://gitee.com/rrgg_admin/WeIdentity.git
git@gitee.com:rrgg_admin/WeIdentity.git
rrgg_admin
WeIdentity
WeIdentity
master

搜索帮助