1 Star 0 Fork 0

WY830 / graphql-java

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle 10.11 KB
一键复制 编辑 原始数据 按行查看 历史
import java.text.SimpleDateFormat
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'antlr'
id 'signing'
id "com.github.johnrengelman.shadow" version "6.1.0"
id "biz.aQute.bnd.builder" version "5.1.2"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
}
def getDevelopmentVersion() {
def gitCheckOutput = new StringBuilder()
def gitCheckError = new StringBuilder()
def gitCheck = ["git", "rev-parse", "--is-inside-work-tree"].execute()
gitCheck.waitForProcessOutput(gitCheckOutput, gitCheckError)
def isGit = gitCheckOutput.toString().trim()
if (isGit != "true") {
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-no-git"
println "created development version: $version"
return version
}
def gitHashOutput = new StringBuilder()
def gitHashError = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(gitHashOutput, gitHashError)
def gitHash = gitHashOutput.toString().trim()
if (gitHash.isEmpty()) {
println "git hash is empty: error: ${error.toString()}"
throw new IllegalStateException("git hash could not be determined")
}
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash
println "created development version: $version"
version
}
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
def msg = String.format("This build must be run with java 1.8 - you are running %s - gradle finds the JDK via JAVA_HOME=%s",
JavaVersion.current(), System.getenv("JAVA_HOME"))
throw new GradleException(msg)
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
def reactiveStreamsVersion = '1.0.2'
def slf4jVersion = '1.7.30'
def releaseVersion = System.env.RELEASE_VERSION
def antlrVersion = '4.9.2'
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
group = 'com.graphql-java'
gradle.buildFinished { buildResult ->
println "*******************************"
println "*"
if (buildResult.failure != null) {
println "* FAILURE - ${buildResult.failure}"
} else {
println "* SUCCESS"
}
println "* Version: $version"
println "*"
println "*******************************"
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'groovy'
jar {
from "LICENSE.md"
from "src/main/antlr/Graphql.g4"
from "src/main/antlr/GraphqlOperation.g4"
from "src/main/antlr/GraphqlSDL.g4"
from "src/main/antlr/GraphqlCommon.g4"
manifest {
attributes('Automatic-Module-Name': 'com.graphqljava')
}
}
dependencies {
compileOnly 'org.jetbrains:annotations:20.1.0'
implementation 'org.antlr:antlr4-runtime:' + antlrVersion
implementation 'org.slf4j:slf4j-api:' + slf4jVersion
api 'com.graphql-java:java-dataloader:3.0.0'
api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
antlr 'org.antlr:antlr4:' + antlrVersion
implementation 'com.google.guava:guava:30.0-jre'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'org.codehaus.groovy:groovy:3.0.8'
testImplementation 'cglib:cglib-nodep:3.3.0'
testImplementation 'org.objenesis:objenesis:2.1'
testImplementation 'com.google.code.gson:gson:2.8.0'
testImplementation 'org.eclipse.jetty:jetty-server:9.4.26.v20200117'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.2'
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
testImplementation 'org.awaitility:awaitility-groovy:3.0.0'
testImplementation 'com.github.javafaker:javafaker:0.13'
testImplementation 'org.reactivestreams:reactive-streams-tck:' + reactiveStreamsVersion
testImplementation "io.reactivex.rxjava2:rxjava:2.1.5"
testImplementation 'org.testng:testng:6.1.1' // use for reactive streams test inheritance
testImplementation 'org.openjdk.jmh:jmh-core:1.25'
testAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.25'
}
shadowJar {
minimize()
archiveClassifier.set('')
configurations = [project.configurations.compileClasspath]
relocate('com.google.common', 'graphql.com.google.common') {
include 'com.google.common.collect.*'
include 'com.google.common.base.*'
include 'com.google.common.math.*'
include 'com.google.common.primitives.*'
}
dependencies {
include(dependency('com.google.guava:guava:30.0-jre'))
}
from "LICENSE.md"
from "src/main/antlr/Graphql.g4"
from "src/main/antlr/GraphqlOperation.g4"
from "src/main/antlr/GraphqlSDL.g4"
from "src/main/antlr/GraphqlCommon.g4"
manifest {
attributes('Automatic-Module-Name': 'com.graphqljava')
}
//Apply biz.aQute.bnd.builder plugin logic to shadowJar as in BndBuilderPlugin
convention.plugins.bundle = new aQute.bnd.gradle.BundleTaskConvention(it)
doLast {
//Call bnd after the ShadowJar was built to update the MANIFEST.MF
buildBundle()
}
//Configure bnd for shadowJar
// -exportcontents: graphql.* Adds all packages of graphql and below to the exported packages list
// -removeheaders: Private-Package Removes the MANIFEST.MF header Private-Package, which contains all the internal packages and
// also the repackaged pckages like guava, which would be wrong after repackaging.
// Import-Package: Changes the imported packages header, to exclude guava and dependencies from the import list (! excludes packages)
// Guava was repackaged and included inside the jar, so we need remove it.
// The last ,* copies all the existing imports from the other dependencies, which is required.
bnd('''
-exportcontents: graphql.*
-removeheaders: Private-Package
Import-Package: !com.google.*,!org.checkerframework.*,!javax.annotation.*,!graphql.com.google.*,*
''')
}
task removeNotNeededGuava(type: Zip) {
from({ zipTree({ "build/libs/graphql-java-${project.version}.jar" }) }) {
exclude('/com/**')
}
archiveFileName = "graphql-java-tmp.jar"
destinationDirectory = file("${project.buildDir}/libs")
doLast {
delete("build/libs/graphql-java-${project.version}.jar")
file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${project.version}.jar"))
}
}
shadowJar.finalizedBy removeNotNeededGuava
task testng(type: Test) {
useTestNG()
}
check.dependsOn testng
compileJava.source file("build/generated-src"), sourceSets.main.java
generateGrammarSource {
includes = ['Graphql.g4']
maxHeapSize = "64m"
arguments += ["-visitor"]
outputDirectory = file("${project.buildDir}/generated-src/antlr/main/graphql/parser/antlr")
}
generateGrammarSource.inputs.dir('src/main/antlr')
task sourcesJar(type: Jar) {
dependsOn classes
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
options.encoding = 'UTF-8'
}
artifacts {
archives sourcesJar
archives javadocJar
}
test {
testLogging {
exceptionFormat = 'full'
}
}
allprojects {
tasks.withType(Javadoc) {
exclude('**/antlr/**')
}
}
publishing {
publications {
graphqlJava(MavenPublication) {
version version
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
pom.withXml {
// The ANTLR-related code below--introduced in `1ac98bf`--addresses an issue with
// the Gradle ANTLR plugin. `1ac98bf` can be reverted and this comment removed once
// that issue is fixed and Gradle upgraded. See https://goo.gl/L92KiF and https://goo.gl/FY0PVR.
//
// We are removing here guava because the classes we want to use is "shaded" into the jar itself
// via the shadowJar task
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.artifactId.text() == 'antlr4' || it.artifactId.text() == 'guava'
}.each() {
it.parent().remove(it)
}
pomNode.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'graphql-java'
description 'GraphqL Java'
url "https://github.com/graphql-java/graphql-java"
scm {
url "https://github.com/graphql-java/graphql-java"
connection "https://github.com/graphql-java/graphql-java"
developerConnection "https://github.com/graphql-java/graphql-java"
}
licenses {
license {
name 'MIT'
url 'https://github.com/graphql-java/graphql-java/blob/master/LICENSE.md'
distribution 'repo'
}
}
developers {
developer {
id 'andimarek'
name 'Andreas Marek'
}
}
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
username = System.env.MAVEN_CENTRAL_USER
password = System.env.MAVEN_CENTRAL_PASSWORD
}
}
}
// to publish to local maven repo skip signing: ./gradlew publishToMavenLocal -x signGraphqlJavaPublication
signing {
def signingKey = System.env.MAVEN_CENTRAL_PGP_KEY
useInMemoryPgpKeys(signingKey, "")
sign publishing.publications
}
// all publish tasks depend on the build task
tasks.withType(PublishToMavenRepository) {
dependsOn build
}
test {
useJUnitPlatform()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/MneeuQ/graphql-java.git
git@gitee.com:MneeuQ/graphql-java.git
MneeuQ
graphql-java
graphql-java
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891