Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Nothing here. spread retract

Clone or download
build.gradle 9.43 KB
Copy Edit Web IDE Raw Blame History
yanggang authored 2020-09-11 12:52 . * integration the webase
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
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"
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'signing'
group = 'com.webank'
version = "0.0.0"
def versionFile = file("VERSION")
versionFile.eachLine { line ->
version = line
}
def repo ="${repoType}"
// 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()) {
maven {
url 'dependencies'
}
} else {
mavenLocal()
if ("cn" == repo) {
println "use cn repo"
maven {url "http://maven.aliyun.com/nexus/content/groups/public/"}
} else {
println "use default repo"
mavenCentral()
}
maven { url "https://dl.bintray.com/ethereum/maven/" }
maven { url "https://oss.sonatype.org/content/groups/public/" }
}
}
List lombok = [
"org.projectlombok:lombok:1.18.12"
]
List jcommander = [
"com.beust:jcommander:1.72"
]
List log4j = [
"org.apache.logging.log4j:log4j-api:2.13.3",
"org.apache.logging.log4j:log4j-web:2.13.3",
"org.apache.logging.log4j:log4j-core:2.13.3",
"org.apache.logging.log4j:log4j-jcl:2.13.3",
"org.apache.logging.log4j:log4j-slf4j-impl:2.13.3",
"org.slf4j:jul-to-slf4j:1.7.30",
"org.slf4j:slf4j-api:1.7.30"
]
List json = [
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0",
"com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0",
"com.fasterxml.jackson.core:jackson-databind:2.11.0",
"com.fasterxml.jackson.core:jackson-annotations:2.11.0",
"com.fasterxml.jackson.core:jackson-core:2.11.0",
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.0"
]
List mysql_driver = [
"mysql:mysql-connector-java:8.0.20"
]
List http_proxy = [
"org.mitre.dsmiley.httpproxy:smiley-http-proxy-servlet:1.7"
]
List redis_driver = [
"org.redisson:redisson:3.13.1"
]
def spring_version = "5.2.2.RELEASE"
List spring = [
"org.springframework:spring-aop:$spring_version",
"org.springframework:spring-beans:$spring_version",
"org.springframework:spring-context:$spring_version",
"org.springframework:spring-core:$spring_version",
"org.springframework:spring-jcl:$spring_version",
"org.springframework:spring-jdbc:$spring_version",
"org.springframework:spring-test:$spring_version",
"org.springframework:spring-messaging:$spring_version",
"org.springframework:spring-tx:$spring_version"
]
def gson_version = "2.8.6"
List gson = [
"com.google.code.gson:gson:$gson_version"
]
configurations {
localDeps
all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
all*.exclude group: "ch.qos.logback"
all*.exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
}
// In this section you declare the dependencies for your production and test code
dependencies {
localDeps lombok
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-websocket")
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy
compile("com.webank:weid-java-sdk:${weidSdkVersion}") {
exclude group: "org.springframework", module: "*"
exclude group: "javax.validation", module: "validation-api"
}
}
}
if (gradleVer.startsWith("5")) {
if (!gradle.startParameter.isOffline()) {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
compile lombok, jcommander, log4j, spring, gson, json, mysql_driver, redis_driver, http_proxy
compile("com.webank:weid-java-sdk:${weidSdkVersion}") {
exclude group: "org.springframework", module: "*"
exclude group: "javax.validation", module: "validation-api"
}
} else {
compileOnly files('dist/lib/lombok-1.18.12.jar')
annotationProcessor files('dist/lib/lombok-1.18.12.jar')
}
}
compile fileTree(dir: 'common/ext', include: '*.jar')
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
excludes = ["*.xml", "*.properties", "*.crt", "*.key"]
}
}
}
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
}
bootRun {
systemProperty "jdk.tls.namedGroups", "${jdkTlsNamedGroups}"
}
eclipse {
classpath {
downloadSources = false
}
}
clean {
delete "dist"
delete "resources/fisco.properties"
delete "resources/weidentity.properties"
}
jar {
enabled = true
baseName = 'weid-build-tools'
destinationDir file('dist/app')
archiveName project.name + '-' + version + '.jar'
// 这句会改变maven包的包名,谨慎
// classifier = 'boot'
into('file/tools') {
from fileTree(file("tools/")){
excludes = ["test_data"]
}
}
into('file/common/script') {
from fileTree(file("common/script/")){
excludes = ["build_tools_ci.sh", "install_build_tool.sh", "**/*.properties", "install"]
}
}
into('file/resources') {
from 'src/main/resources/log4j2.xml'
}
into('file/dist/conf') {
from 'src/main/resources/application.properties'
}
into('file/dist/lib') {
from fileTree(file("./common/ext")){
//自定义过滤规则
includes = ["*.jar"]
}
}
into('file/dist/app') {
from 'resources/.gitkeep'
}
into('file') {
from fileTree(file("./")){
//自定义过滤规则
includes = ["*.sh", "VERSION"]
excludes = ["build.sh"]
}
from 'common/script/tpl/run.config.tpl'
rename('run.config.tpl', 'run.config')
}
doLast {
copy {
from file('src/main/resources/log4j2.xml')
into 'resources/'
}
copy {
from file('src/main/resources/application.properties')
into 'dist/conf'
}
if (!gradle.startParameter.isOffline()) {
copy {
from configurations.runtime
from configurations.localDeps
into 'dist/lib'
}
}
}
}
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 'weid-build-tools'
packaging 'jar'
description 'Java sdk for WeIdentity.'
url 'https://github.com/WeBankFinTech/weidentity-contract'
scm {
url 'scm:git@github.com:WeBankFinTech/weidentity-contract.git'
connection 'scm:git@github.com:WeBankFinTech/weidentity-contract.git'
developerConnection 'git@github.com:WeBankFinTech/weidentity-contract.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