Skip to content

Commit 3e9268f

Browse files
committed
More build related work
1 parent d10a9d9 commit 3e9268f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

build.gradle

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.text.SimpleDateFormat
2+
13
buildscript {
24
repositories {
35
mavenCentral()
@@ -13,9 +15,26 @@ apply plugin: 'groovy'
1315
apply plugin: 'maven-publish'
1416
apply plugin: 'com.jfrog.bintray'
1517

18+
def getDevelopmentVersion() {
19+
def output = new StringBuilder()
20+
def error = new StringBuilder()
21+
def gitShortHash = "git -C ${projectDir} rev-parse --short HEAD".execute()
22+
gitShortHash.waitForProcessOutput(output, error)
23+
def gitHash = output.toString().trim()
24+
if (gitHash.isEmpty()) {
25+
println "git hash is empty: error: ${error.toString()}"
26+
throw new IllegalStateException("git hash could not be determined")
27+
}
28+
new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash
29+
}
30+
31+
32+
def releaseVersion = System.env.RELEASE_VERSION
33+
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
1634
group = 'com.graphql-java'
17-
version = '0.0.1-SNAPSHOT'
35+
1836
sourceCompatibility = 1.8
37+
targetCompatibility = 1.8
1938

2039
repositories {
2140
mavenCentral()
@@ -50,9 +69,9 @@ publishing {
5069
publications {
5170
maven(MavenPublication) {
5271
from components.java
53-
groupId 'com.graphql-java'
72+
groupId group
5473
artifactId 'graphql-java-extended-scalars'
55-
version project.version
74+
version version
5675

5776
artifact sourcesJar
5877
artifact javadocJar

0 commit comments

Comments
 (0)