Skip to content

Commit 4dd6a2b

Browse files
authored
Merge pull request #50 from lfoppiano/feature/version
Add github revision in /version
2 parents 45bf842 + b5e72d1 commit 4dd6a2b

12 files changed

Lines changed: 744 additions & 50 deletions

File tree

Dockerfile.software

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY resources/lexicon software-mentions-source/resources/lexicon
2121
COPY build.gradle software-mentions-source/
2222
COPY gradle software-mentions-source/gradle/
2323
COPY gradlew software-mentions-source/
24-
#COPY .git software-mentions-source/.git
24+
COPY .git software-mentions-source/.git
2525
COPY localLibs software-mentions-source/localLibs
2626

2727
# Preparing models

build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,36 @@ apply plugin: 'java-library'
3737
apply plugin: 'base'
3838
apply 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+
4070
group = "org.grobid.software"
4171
version = '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+
302344
task copyModels(type: Copy) {
303345
from "${rootDir}/resources/models/"
304346
include "**"

0 commit comments

Comments
 (0)