-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
177 lines (161 loc) · 6.56 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
plugins {
id 'java-library'
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "8.1.1"
}
/*
* Gets the version name from the latest Git tag, omit leading "v" - yeah!
* Note: a plugin way to do this would be via https://plugins.gradle.org/plugin/net.nemerosa.versioning
* cmdlin:
* git describe --tags
*/
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
def tag = stdout.toString().trim()
return tag.startsWith("v") ? tag.substring(1) : tag
}
/*
* Gets the commit hash from the latest Git
* Note: a plugin way to do this would be via https://plugins.gradle.org/plugin/net.nemerosa.versioning
*/
def getGitCommitHash = {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--format="%H"'
standardOutput = stdout
}
return stdout.toString().trim().replace("\"", "")
}
version = version != null && version != "unspecified" ? version : getVersionName()
ext {
specVendor = 'International Air Transport Association (IATA)'
product = 'ONE Record Converter'
specTitle = 'ONE Record Ontology-Model'
implVendor = 'Riege Software'
implTitle = product + ' Java Library'
implDescription = implVendor + ' ' + product + ' Java Library'
specVersion = '1.1'
implVersion = version
javaTarget = JavaVersion.VERSION_1_8
}
group 'com.riege'
sourceCompatibility = javaTarget
targetCompatibility = javaTarget
java {
withSourcesJar() // to get a "sourcesJar" task
withJavadocJar() // to get a "javadocJar" task
}
tasks.withType(Jar) {
manifest {
attributes(
"Built-By" : System.properties['user.name'],
"Build-Revision" : getGitCommitHash(),
"Build-Timestamp" : new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
"Build-Jdk" : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
"Build-OS" : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
"Created-By" : "Gradle ${gradle.gradleVersion}",
"Specification-Title" : specTitle,
"Specification-Vendor" : specVendor,
"Specification-Version" : specVersion,
"Implementation-Title" : implTitle,
"Implementation-Vendor" : implVendor,
"Implementation-Version" : implVersion
)
}
}
dependencies {
// one-record-ontologymodel from riege.com is a public GitHub repository
// but not published on mavenCentral.
// Nevertheless it can be retrieved via https://jitpack.io
// See also
// https://jitpack.io/#riege/one-record-ontologydatamodel
// https://jitpack.io/#riege/one-record-jsonutils
//
// One can also find current versions under the "Commit" tab from above URL!
// -> get the "version id" from jitpack, replace dependency, done.
//
// jitpack dependency (version based):
// implementation('com.github.riege:one-record-ontologymodel:1.1.2') { transitive = false }
// jitpack dependency (commit hash (e.g. daec14a075) based, for unreleased development versions):
// implementation('com.github.riege:one-record-ontologymodel:daec14a075') { transitive = false }
// implementation('com.github.riege:one-record-ontologymodel:e9f5883a21') { transitive = false }
// github/riege internal dependency:
// implementation('com.riege:one-record-ontologymodel:2.0.1') { transitive = false }
implementation('com.github.riege:one-record-ontologydatamodel:0.2.5')
implementation('com.github.riege:one-record-jsonutils:0.9.5')
// cargoxml-jaxb from riege.com cannot be retrieved via https://jitpack.io
// because building it requires access to the Cargo-XML Toolkit schema files
// which are not included on GitHub and JitPack has not access to them!
// So we take it from local "lib" directory.
// Note: Package is available at https://github.com/riege/cargoxml-jaxb
implementation ":cargoxml-jaxb-8.1:"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}
test {
useJUnitPlatform()
}
shadowJar {
// When working with a Gradle project with the name myApp and version 1.0,
// the default shadowJar task will output a file at:
// build/libs/myApp-1.0-all.jar
//
// to remove the '-all', we set archiveClassifier to null (or "")
archiveClassifier = null
}
build.dependsOn(shadowJar)
/*
* With the following line, some build just fail with
*
* Reason: Task ':publishShadowPublicationToMavenLocal' uses this output of task ':jar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
*/
shadowJar.dependsOn(jar)
repositories {
flatDir dirs: "$rootProject.projectDir/lib"
mavenCentral()
mavenLocal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/riege/packages")
credentials {
username = (project.findProperty("github.packages.access.user") ?: System.getenv("GITHUB_PACKAGES_ACCESS_USER")).toString()
password = (project.findProperty("github.packages.access.token") ?: System.getenv("GITHUB_PACKAGES_ACCESS_TOKEN")).toString()
}
}
maven { url 'https://jitpack.io' }
}
publishing {
publications {
shadow(MavenPublication) { publication ->
from project.shadow.component(publication)
groupId group
pom {
name = implTitle
description = implDescription
url = System.getenv("PROJECT_URL")
}
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
repositories {
maven {
//name = "thisLibrary"
url = System.getenv("MAVEN_PUBLISH_URL")
credentials {
username = System.getenv("MAVEN_PUBLISH_USERNAME")
password = System.getenv("MAVEN_PUBLISH_PASSWORD")
}
}
}
}