-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
202 lines (185 loc) · 7.38 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
plugins {
id 'java-library'
id 'maven-publish'
id "com.github.bjornvester.xjc" version "1.7.1"
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
*/
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 {
// for Cargo-XML 8th Edition, the path is
// "%LOCALAPPDATA%\IATA\Reader\1.0.0.0\Library\CXML 8th\Downloads\Schemas"
// for Cargo-XML 4th Edition, the path is
// "%APPDATA%\IATA\IATA Cargo-XML Message Manual and Toolkit 4th Edition\Downloads\Schemas"
// default is set to Cargo-XML 8th Edition
schemadir = project.findProperty("schemadir") ?: (System.getenv("LOCALAPPDATA") + "\\IATA\\Reader\\1.0.0.0\\Library\\CXML 8th\\Downloads\\Schemas")
// packagePrefix = "org.iata.cargoxml.schema"
packagePrefix = "com.riege.cargoxml.schema"
specVendor = 'International Air Transport Association (IATA)'
product = 'Cargo-XML'
specTitle = product + ' Specification'
implVendor = 'Riege Software'
implTitle = product + ' JAXB Java Library'
implDescription = implVendor + ' ' + product + ' JAXB Java Library'
implVersion = version
javaTarget = JavaVersion.VERSION_1_8
}
dependencies {
/*
* The following bindings are not required to BUILD or JAR this project
* but the generated classes in the jar depend upon them.
* (although included in Java 8)
* In order to publish properly, the dependencies are declared.
*/
// NOTE: DO NOT UPGRADE TO
// 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1'
// nor 'com.sun.xml.bind:jaxb-impl:3.0.2'
// since it might break other projects
api 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
api 'com.sun.xml.bind:jaxb-impl:2.3.3' // oder 2.3.8
}
jar {
exclude("**/schema/CXML-*/**")
exclude("**/schema/X*-*.00/**")
}
task unzipschema(type: Copy) {
def thedirectory = new File(schemadir)
// fileTree(dir: new File(thedirectory), includes: ['**/*.zip']).each { zipFile ->
fileTree(dir: thedirectory, includes: ['X*-*.00/*.zip']).each { zipFile ->
from zipTree(zipFile)
}
into thedirectory
}
xjc {
xjcVersion.set("2.3.3")
bindingFiles = project.files("$projectDir/src/main/bindings.xjb")
groups {
//
// The full CargoXML schema are not in this project
// Nevertheless if they are copies into subdirectories under
// src/main/resources/schema, then the following entries could
// be used to register them in order to generate JAXB classed
// from the schema.
// Example path:
// For XFWB3.00, the full schema should be copied so that
// there exists a file
// src/main/resources/schema/CXML-XFWB-3/Waybill_1.xsd
//
// Additional the next 4 lines need to be activate to include the
// copies CXML-XWB-3 files:
//
// register("xfwb3") {
// xsdFiles = xsdDir.asFileTree.matching { include("**/CXML-XWB-3/**/*.xsd") }
// defaultPackage.set("org.iata.cargoxml.xfwb3")
// }
// The official Cargo-XML Toolkit ZIP archives differ in their
// subdirectory structure and naming convensions.
// Take extra care to match the actual unzipped path/file when adding more.
register("XFWB3") {
xsdFiles = files(new File(schemadir + '/CXML-XFWB-3/Waybill Schema/Waybill_1.xsd').absolutePath)
defaultPackage.set("${packagePrefix}.xfwb3")
}
register("XFSU3") {
xsdFiles = files(new File(schemadir + '/XFSU-3.00/StatusMessage_1.xsd').absolutePath)
defaultPackage.set("${packagePrefix}.xfsu3")
}
register("XFZB3") {
xsdFiles = files(new File(schemadir + '/CXML-XFZB-3/CXML-XFZB-3/HouseWaybill_1.xsd').absolutePath)
defaultPackage.set("${packagePrefix}.xfzb3")
}
register("XFNM3") {
xsdFiles = files(new File(schemadir + '/CXML-XFNM-3/Response/Response_3.xsd').absolutePath)
defaultPackage.set("${packagePrefix}.xfnm3")
}
// register("XSDG6") {
// xsdFiles = files(new File(schemadir + '/CXML-XSDG-6.00/ShippersDeclarationForDangerousGoods_2p0.xsd').absolutePath)
// defaultPackage.set("${packagePrefix}.xsdg6")
// }
}
}
group = 'com.riege'
sourceCompatibility = javaTarget
targetCompatibility = javaTarget
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 classifier to null:
archiveClassifier = null
}
tasks.withType(Jar) {
manifest {
attributes(
"Built-By" : System.properties['user.name'],
"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,
"Implementation-Title" : implTitle,
"Implementation-Vendor" : implVendor,
"Implementation-Version" : implVersion
)
}
}
repositories {
mavenCentral()
}
publishing {
publications {
thisLibrary(MavenPublication) {
publication -> project.shadow.component(publication)
groupId group
// from components.java
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")
}
}
}
}