-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
219 lines (179 loc) · 6.78 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
///////////////////////////////////////////////////////////////////////////////
//
// Build Script for building aggregated JavaPOS library from
// JavaPOS Contracts, JavaPOS Controls, and JCL libraries
//
// Author: [email protected]
//
///////////////////////////////////////////////////////////////////////////////
plugins {
id 'java-library'
id 'signing'
id 'eclipse'
id 'maven-publish'
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id 'project-report'
}
wrapper {
gradleVersion = '8.4'
}
///////////////////////////////////////////////////////////////////////////////
// Names and Versions
///////////////////////////////////////////////////////////////////////////////
def artifactName = 'javapos'
group='org.javapos'
def uposVersion = '1.15'
version="${uposVersion}.2" // the last part after dot is the build/release version
// dependency versions
def javaposContractsVersion = "$uposVersion.2"
def javaposControlsVersion = "$uposVersion.0"
def jclVersion = '3.1.0'
def xercesVersion = '1.2.3' // artificial dependency inherited from javapos-config-loader - take over from there
///////////////////////////////////////////////////////////////////////////////
// Build Dependencies
///////////////////////////////////////////////////////////////////////////////
repositories {
mavenCentral()
// for resolving snapshots from MavenCentral if not going for a real release
if (!isReleaseRun())
{
logger.warn("WARN: Seems not to be a release, so Maven Central snapshot repository is fetched!");
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
if (!System.getenv('CI')) {
mavenLocal()
}
}
// this gets true if Github Actions workflow defines github.event.action project variable at Gradle command line
// AND the event action is 'released' (see release.yml)
def boolean isReleaseRun() {
return System.getenv('CI') && null != findProperty('github.event.action') && 'released'.equals(getProperty('github.event.action'))
}
// check whether github.event.action is defined on CI
if (System.getenv('CI') && null == findProperty('github.event.action'))
logger.warn('WARN: Project property github.event.action is not defined, so, it cannot be determined whether a release is ongoing.')
configurations {
javaposLibs
javaposSources
}
dependencies {
api "xerces:xerces:$xercesVersion" // artificial dependency inherited from javapos-config-loader
javaposLibs ("org.javapos:javapos-contracts:$javaposContractsVersion") { transitive = false }
javaposLibs ("org.javapos:javapos-controls:$javaposControlsVersion") { transitive = false }
javaposLibs ("org.javapos:javapos-config-loader:$jclVersion") { transitive = false }
javaposSources ("org.javapos:javapos-contracts:$javaposContractsVersion:sources") { transitive = false }
javaposSources ("org.javapos:javapos-controls:$javaposControlsVersion:sources") { transitive = false }
javaposSources ("org.javapos:javapos-config-loader:$jclVersion:sources") { transitive = false }
}
///////////////////////////////////////////////////////////////////////////////
// Build Tasks
///////////////////////////////////////////////////////////////////////////////
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_1_8
}
def javaposManifest = java.manifest {
attributes('Specification-Title': 'UnifiedPOS Standard',
'Specification-Vendor': 'UnifiedPOS Committee',
'Specification-Version': uposVersion,
'Implementation-Title': 'JavaPOS Library (Contracts, Controls, JCL)',
'Implementation-Vendor': 'github.com/JavaPOSWorkingGroup',
'Implementation-Version': version)
}
def changelogFile = file('build/CHANGELOG.md')
task createChangelog {
group = 'build'
description = 'creates CHANGELOG.md, listing incoprorated JavaPOS libraries'
// ensure jar is rebuild in case project version has changed
inputs.property 'javaposContractsVersion', javaposContractsVersion
inputs.property 'javaposControlsVersion', javaposControlsVersion
inputs.property 'jclVersion', jclVersion
doLast {
changelogFile.parentFile.mkdirs()
changelogFile.text =
"""\
# JavaPOS Library $version
Incorporates sub component versions
- javapos-contracts-$javaposContractsVersion
- javapos-controls-$javaposControlsVersion
- javapos-config-loader-$jclVersion
"""
}
}
def jarContentFrom = { configuration ->
copySpec {
configuration.each {
def dependencyName = it.name.replace('.jar', '')
from(zipTree(it)) {
exclude 'META-INF/MANIFEST.MF'
rename 'CHANGELOG.md', "${dependencyName}.CHANGELOG.md"
}
}
from (changelogFile) {
into 'META-INF'
}
}
}
jar {
archiveBaseName = artifactName
manifest = javaposManifest
duplicatesStrategy = DuplicatesStrategy.FAIL
dependsOn createChangelog
// ensure jar is rebuild in case project version has changed
inputs.property 'version', project.version
with jarContentFrom(configurations.javaposLibs)
}
sourcesJar {
manifest = javaposManifest
duplicatesStrategy = DuplicatesStrategy.FAIL
dependsOn createChangelog
with jarContentFrom(configurations.javaposSources)
}
///////////////////////////////////////////////////////////////////////////////
// Artifact Upload
///////////////////////////////////////////////////////////////////////////////
nexusPublishing {
repositories {
sonatype()
}
}
def githubProjectUrl = 'https://github.com/JavaPOSWorkingGroup/javapos'
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = artifactName
description = 'JavaPOS Library'
url = githubProjectUrl
licenses {
license {
name = 'Common Public License (CPL) -- V1.0'
url = 'https://www.eclipse.org/legal/cpl-v10.html'
}
}
developers {
developer {
id = 'javapos'
name = 'JavaPOS Working Group'
email = '[email protected]'
}
}
scm {
connection = "scm:${githubProjectUrl}.git"
developerConnection = "scm:git:${githubProjectUrl}.git"
url = "${githubProjectUrl}.git"
}
}
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}