|
1 | 1 | import java.text.SimpleDateFormat
|
2 | 2 |
|
3 |
| -buildscript { |
4 |
| - repositories { |
5 |
| - jcenter() |
6 |
| - } |
7 |
| - dependencies { |
8 |
| - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' |
9 |
| - } |
| 3 | +plugins { |
| 4 | + id 'java' |
| 5 | + id 'java-library' |
| 6 | + id 'maven' |
| 7 | + id 'maven-publish' |
| 8 | + id 'signing' |
| 9 | + id "io.github.gradle-nexus.publish-plugin" version "1.0.0" |
10 | 10 | }
|
11 | 11 |
|
12 |
| -apply plugin: 'maven-publish' |
13 | 12 |
|
14 |
| -publishing { |
15 |
| - repositories { |
16 |
| - maven { |
17 |
| - url 'https://dl.bintray.com/bbakerman/maven' |
18 |
| - } |
| 13 | +def getDevelopmentVersion() { |
| 14 | + def output = new StringBuilder() |
| 15 | + def error = new StringBuilder() |
| 16 | + def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute() |
| 17 | + gitShortHash.waitForProcessOutput(output, error) |
| 18 | + def gitHash = output.toString().trim() |
| 19 | + if (gitHash.isEmpty()) { |
| 20 | + println "git hash is empty: error: ${error.toString()}" |
| 21 | + throw new IllegalStateException("git hash could not be determined") |
19 | 22 | }
|
| 23 | + def version = new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash |
| 24 | + println "created development version: $version" |
| 25 | + version |
20 | 26 | }
|
21 | 27 |
|
22 |
| -ext { |
23 |
| - junitVersion = '4.12' |
24 |
| - slf4jVersion = '1.7.25' |
| 28 | +if (JavaVersion.current() != JavaVersion.VERSION_1_8) { |
| 29 | + 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", |
| 30 | + JavaVersion.current(), System.getenv("JAVA_HOME")) |
| 31 | + throw new IllegalStateException(msg) |
25 | 32 | }
|
26 | 33 |
|
27 |
| -apply plugin: 'java' |
28 |
| -apply plugin: 'maven' |
29 |
| -apply plugin: 'osgi' |
30 |
| -apply from: "$projectDir/gradle/publishing.gradle" |
| 34 | + |
| 35 | +sourceCompatibility = 1.8 |
| 36 | +targetCompatibility = 1.8 |
| 37 | +def slf4jVersion = '1.7.30' |
| 38 | +def releaseVersion = System.env.RELEASE_VERSION |
| 39 | +version = releaseVersion ? releaseVersion : getDevelopmentVersion() |
| 40 | +group = 'com.graphql-java' |
| 41 | +description = 'A pure Java 8 port of Facebook Dataloader' |
31 | 42 |
|
32 | 43 | repositories {
|
33 |
| - mavenLocal() |
34 | 44 | mavenCentral()
|
35 |
| - jcenter() |
36 |
| - maven { |
37 |
| - url 'https://dl.bintray.com/engagingspaces/maven' |
38 |
| - } |
| 45 | + mavenLocal() |
39 | 46 | }
|
40 | 47 |
|
41 |
| -def releaseVersion = System.properties.RELEASE_VERSION |
42 |
| -version = releaseVersion ? releaseVersion : new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) |
43 |
| -group = 'org.dataloader' |
44 |
| -description = 'A pure Java 8 port of Facebook Dataloader' |
45 |
| - |
46 |
| -compileJava { |
47 |
| - sourceCompatibility = 1.8 |
48 |
| - targetCompatibility = 1.8 |
| 48 | +apply plugin: 'groovy' |
49 | 49 |
|
50 |
| - options.compilerArgs = ["-Xlint:unchecked", "-Xdiags:verbose", "-Xdoclint:none"] |
51 |
| -} |
52 |
| - |
53 |
| -task myJavadocs(type: Javadoc) { |
54 |
| - source = sourceSets.main.allJava |
55 |
| - options.addStringOption('Xdoclint:none', '-quiet') |
| 50 | +jar { |
| 51 | + manifest { |
| 52 | + attributes('Automatic-Module-Name': 'com.graphql-java') |
| 53 | + } |
56 | 54 | }
|
57 | 55 |
|
58 | 56 | dependencies {
|
59 | 57 | compile 'org.slf4j:slf4j-api:' + slf4jVersion
|
60 | 58 | testCompile 'org.slf4j:slf4j-simple:' + slf4jVersion
|
61 |
| - testCompile "junit:junit:$junitVersion" |
| 59 | + testCompile "junit:junit:4.12" |
62 | 60 | testCompile 'org.awaitility:awaitility:2.0.0'
|
63 | 61 | }
|
64 | 62 |
|
65 |
| -task wrapper(type: Wrapper) { |
66 |
| - gradleVersion = '4.0' |
67 |
| - distributionUrl = "https://services.gradle.org/distributions/gradle-4.0-all.zip" |
| 63 | +task sourcesJar(type: Jar) { |
| 64 | + dependsOn classes |
| 65 | + classifier 'sources' |
| 66 | + from sourceSets.main.allSource |
| 67 | +} |
| 68 | + |
| 69 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 70 | + classifier = 'javadoc' |
| 71 | + from javadoc.destinationDir |
| 72 | +} |
| 73 | + |
| 74 | +javadoc { |
| 75 | + options.encoding = 'UTF-8' |
| 76 | +} |
| 77 | + |
| 78 | +artifacts { |
| 79 | + archives sourcesJar |
| 80 | + archives javadocJar |
| 81 | +} |
| 82 | + |
| 83 | +test { |
| 84 | + testLogging { |
| 85 | + exceptionFormat = 'full' |
| 86 | + } |
68 | 87 | }
|
| 88 | + |
| 89 | +publishing { |
| 90 | + publications { |
| 91 | + graphqlJava(MavenPublication) { |
| 92 | + from components.java |
| 93 | + groupId 'com.graphql-java' |
| 94 | + artifactId 'java-dataloader' |
| 95 | + version project.version |
| 96 | + |
| 97 | + artifact sourcesJar |
| 98 | + artifact javadocJar |
| 99 | + |
| 100 | + pom.withXml { |
| 101 | + asNode().children().last() + { |
| 102 | + resolveStrategy = Closure.DELEGATE_FIRST |
| 103 | + name 'java-dataloader' |
| 104 | + description 'A pure Java 8 port of Facebook Dataloader' |
| 105 | + url 'https://github.com/graphql-java/java-dataloader' |
| 106 | + inceptionYear '2017' |
| 107 | + |
| 108 | + scm { |
| 109 | + url 'https://github.com/graphql-java/java-dataloader' |
| 110 | + connection 'scm:[email protected]:graphql-java/java-dataloader.git' |
| 111 | + developerConnection 'scm:[email protected]:graphql-java/java-dataloader.git' |
| 112 | + } |
| 113 | + |
| 114 | + licenses { |
| 115 | + license { |
| 116 | + name 'The Apache Software License, Version 2.0' |
| 117 | + url 'https://www.apache.org/licenses/LICENSE-2.0.txt' |
| 118 | + distribution 'repo' |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + developers { |
| 123 | + developer { |
| 124 | + id 'bbakerman' |
| 125 | + name 'Brad Baker' |
| 126 | + |
| 127 | + } |
| 128 | + developer { |
| 129 | + id 'aschrijver' |
| 130 | + name 'Arnold Schrijver' |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | +} |
| 138 | + |
| 139 | +nexusPublishing { |
| 140 | + repositories { |
| 141 | + sonatype { |
| 142 | + username = System.env.MAVEN_CENTRAL_USER |
| 143 | + password = System.env.MAVEN_CENTRAL_PASSWORD |
| 144 | + } |
| 145 | + } |
| 146 | +} |
| 147 | + |
| 148 | +signing { |
| 149 | + def signingKey = System.env.MAVEN_CENTRAL_PGP_KEY |
| 150 | + useInMemoryPgpKeys(signingKey, "") |
| 151 | + sign publishing.publications |
| 152 | +} |
| 153 | + |
| 154 | + |
| 155 | +// all publish tasks depend on the build task |
| 156 | +tasks.withType(PublishToMavenRepository) { |
| 157 | + dependsOn build |
| 158 | +} |
| 159 | + |
| 160 | + |
| 161 | +task myWrapper(type: Wrapper) { |
| 162 | + gradleVersion = '6.6.1' |
| 163 | + distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" |
| 164 | +} |
| 165 | + |
0 commit comments