|
| 1 | +import java.text.SimpleDateFormat |
| 2 | + |
| 3 | +def getDevelopmentVersion() { |
| 4 | + def output = new StringBuilder() |
| 5 | + def error = new StringBuilder() |
| 6 | + def gitShortHash = "git -C ${projectDir} rev-parse --short HEAD".execute() |
| 7 | + gitShortHash.waitForProcessOutput(output, error) |
| 8 | + def gitHash = output.toString().trim() |
| 9 | + if (gitHash.isEmpty()) { |
| 10 | + println "git hash is empty: error: ${error.toString()}" |
| 11 | + throw new IllegalStateException("git hash could not be determined") |
| 12 | + } |
| 13 | + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash |
| 14 | +} |
| 15 | + |
| 16 | +buildscript { |
| 17 | + repositories { |
| 18 | + jcenter() |
| 19 | + } |
| 20 | + dependencies { |
| 21 | + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +subprojects { |
| 26 | + |
| 27 | + apply plugin: 'com.jfrog.bintray' |
| 28 | + apply plugin: 'java' |
| 29 | + apply plugin: 'maven' |
| 30 | + apply plugin: 'maven-publish' |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + sourceCompatibility = 1.8 |
| 35 | + targetCompatibility = 1.8 |
| 36 | + def releaseVersion = System.env.RELEASE_VERSION |
| 37 | + version = releaseVersion ? releaseVersion : getDevelopmentVersion() |
| 38 | + group = 'com.graphql-java' |
| 39 | + |
| 40 | + |
| 41 | + repositories { |
| 42 | + mavenCentral() |
| 43 | + mavenLocal() |
| 44 | + } |
| 45 | + |
| 46 | + apply plugin: 'groovy' |
| 47 | + |
| 48 | + |
| 49 | + task sourcesJar(type: Jar) { |
| 50 | + dependsOn classes |
| 51 | + classifier 'sources' |
| 52 | + from sourceSets.main.allSource |
| 53 | + } |
| 54 | + |
| 55 | + task javadocJar(type: Jar, dependsOn: javadoc) { |
| 56 | + classifier = 'javadoc' |
| 57 | + from javadoc.destinationDir |
| 58 | + } |
| 59 | + |
| 60 | + javadoc { |
| 61 | + options.encoding = 'UTF-8' |
| 62 | + } |
| 63 | + |
| 64 | + artifacts { |
| 65 | + archives sourcesJar |
| 66 | + archives javadocJar |
| 67 | + } |
| 68 | + |
| 69 | + publishing { |
| 70 | + |
| 71 | + publications { |
| 72 | + |
| 73 | + graphqlJava(MavenPublication) { |
| 74 | + version version |
| 75 | + from components.java |
| 76 | + |
| 77 | + artifact sourcesJar { |
| 78 | + classifier "sources" |
| 79 | + } |
| 80 | + artifact javadocJar { |
| 81 | + classifier "javadoc" |
| 82 | + } |
| 83 | + pom.withXml { |
| 84 | + asNode().children().last() + { |
| 85 | + resolveStrategy = Closure.DELEGATE_FIRST |
| 86 | + description 'GraphQL Java Spring' |
| 87 | + url "https://github.com/graphql-java/graphql-java-spring" |
| 88 | + scm { |
| 89 | + url "https://github.com/graphql-java/graphql-java-spring" |
| 90 | + connection "https://github.com/graphql-java/graphql-java-spring" |
| 91 | + developerConnection "https://github.com/graphql-java/graphql-java-spring" |
| 92 | + } |
| 93 | + licenses { |
| 94 | + license { |
| 95 | + name 'MIT' |
| 96 | + url 'https://github.com/graphql-java/graphql-java-spring/blob/master/LICENSE.md' |
| 97 | + distribution 'repo' |
| 98 | + } |
| 99 | + } |
| 100 | + developers { |
| 101 | + developer { |
| 102 | + id 'andimarek' |
| 103 | + name 'Andreas Marek' |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + |
| 113 | + bintray { |
| 114 | + user = System.env.BINTRAY_USER ?: project["bintray.user"] |
| 115 | + key = System.env.BINTRAY_API_KEY ?: project["bintray.key"] |
| 116 | + publications = ['graphqlJava'] |
| 117 | + publish = true |
| 118 | + pkg { |
| 119 | + repo = 'graphql-java' |
| 120 | + name = 'graphql-java-spring' |
| 121 | + desc = 'GraphQL Java Spring integration' |
| 122 | + licenses = ['MIT'] |
| 123 | + vcsUrl = 'https://github.com/graphql-java/graphql-java-spring' |
| 124 | + |
| 125 | + version { |
| 126 | + name = project.version |
| 127 | + desc = project.description |
| 128 | + released = new Date() |
| 129 | + vcsTag = 'v' + project.version |
| 130 | + gpg { |
| 131 | + sign = true |
| 132 | + } |
| 133 | + mavenCentralSync { |
| 134 | + sync = true |
| 135 | + user = System.env.MAVEN_CENTRAL_USER |
| 136 | + password = System.env.MAVEN_CENTRAL_PASSWORD |
| 137 | + close = '1' |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | +// all publish tasks depend on the build task |
| 144 | + tasks.withType(PublishToMavenRepository) { |
| 145 | + dependsOn build |
| 146 | + } |
| 147 | + |
| 148 | +} |
| 149 | + |
| 150 | +task wrapper(type: Wrapper) { |
| 151 | + gradleVersion = '4.10.2' |
| 152 | + distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" |
| 153 | +} |
| 154 | + |
0 commit comments