@@ -37,6 +37,36 @@ apply plugin: 'java-library'
3737apply plugin : ' base'
3838apply plugin : ' com.github.kt3k.coveralls'
3939
40+
41+ def getGitRevision () {
42+ def gitRevision = " unknown"
43+ try {
44+ def stdout = new ByteArrayOutputStream ()
45+ println (" Checking git under ${ rootProject.rootDir} " )
46+ exec {
47+ workingDir rootProject. rootDir
48+ commandLine ' git' , ' describe' , ' --tags' , ' --always' , ' --first-parent'
49+ standardOutput = stdout
50+ }
51+ gitRevision = stdout. toString(). trim()
52+ println " Current Git revision: ${ gitRevision} "
53+ } catch (Exception e) {
54+ println " Could not get Git revision: ${ e} "
55+ }
56+ return gitRevision
57+ }
58+
59+ project. ext. gitRevision = getGitRevision()
60+
61+ // Create a task to expose the revision for other tasks
62+ tasks. register(' collectGitRevision' ) {
63+ project. ext. gitRevision = getGitRevision()
64+ doLast {
65+ println " Git revision: ${ project.ext.gitRevision} "
66+ }
67+ }
68+
69+
4070group = " org.grobid.software"
4171version = ' 0.8.2-SNAPSHOT'
4272
@@ -140,6 +170,9 @@ dependencies {
140170 implementation(group : ' org.grobid' , name : ' grobid-core' , version : ' 0.8.2' ) {
141171 exclude group : ' org.slf4j' , module : " slf4j-log4j12"
142172 }
173+ api(group : ' org.grobid' , name : ' grobid-service' , version : ' 0.8.2' ) {
174+ exclude group : ' org.slf4j' , module : " slf4j-log4j12"
175+ }
143176 implementation(group : ' org.grobid' , name : ' grobid-trainer' , version : ' 0.8.2' ) {
144177 exclude group : ' org.slf4j' , module : " slf4j-log4j12"
145178 }
@@ -299,6 +332,15 @@ artifacts {
299332 archives shadowJar
300333}
301334
335+ processResources {
336+ filesMatching([" version.txt" , " revision.txt" ]) {
337+ expand(
338+ project_version : project. property(' version' ) ?: " unknown" ,
339+ project_revision : rootProject. ext. gitRevision
340+ )
341+ }
342+ }
343+
302344task copyModels (type : Copy ) {
303345 from " ${ rootDir} /resources/models/"
304346 include " **"
0 commit comments