-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
185 lines (150 loc) · 5.28 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
///////////////////////////////////////////////////////////////////////////////
//
// Build Script for building JavaPOS Configuration Loader (JCL) Library
//
// Author: [email protected] (2021)
//
///////////////////////////////////////////////////////////////////////////////
plugins {
id 'java-library'
id 'signing'
id 'eclipse'
id 'maven-publish'
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id 'project-report'
}
wrapper {
gradleVersion = '8.4'
}
///////////////////////////////////////////////////////////////////////////////
// Names and Versions
///////////////////////////////////////////////////////////////////////////////
def artifactName = 'javapos-config-loader'
group='org.javapos'
version='4.0.0' // if version is going to be changed, first add "-SNAPSHOT" to test publishing to MavenCentral's Snapshot repo
///////////////////////////////////////////////////////////////////////////////
// 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.')
def testResourceDir = file("${System.properties['java.io.tmpdir']}/javapos-config-loader-test/resources")
dependencies {
api 'org.javapos:javapos-contracts:1.6.0'
testImplementation("junit:junit:4.13.2")
testRuntimeOnly files(testResourceDir)
}
///////////////////////////////////////////////////////////////////////////////
// Project Configurations
///////////////////////////////////////////////////////////////////////////////
def javaposManifest = java.manifest {
attributes('Specification-Title': 'UnifiedPOS Standard',
'Specification-Vendor': 'UnifiedPOS Committee',
'Implementation-Title': 'JavaPOS Configuration Loader',
'Implementation-Vendor': 'github.com/JavaPOSWorkingGroup',
'Implementation-Version': version,
'Main-Class': 'jpos.config.Version')
}
///////////////////////////////////////////////////////////////////////////////
// Build Tasks
///////////////////////////////////////////////////////////////////////////////
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_1_8
}
jar {
archiveBaseName = artifactName
manifest = javaposManifest
from ('CHANGELOG.md') {
into 'META-INF'
}
}
sourcesJar {
manifest = javaposManifest
from ('CHANGELOG.md') {
into 'META-INF'
}
}
///////////////////////////////////////////////////////////////////////////////
// Test Tasks
///////////////////////////////////////////////////////////////////////////////
task prepareTestConfiguration {
description = 'copies the initial jpos.properties file to the resource directory where generated jpos.properties files are written to'
doLast {
testResourceDir.mkdirs()
copy {
from ("$projectDir/src/test/resources/") {
include "jpos/res/jpos_junit.properties"
}
into testResourceDir
rename 'jpos_junit.properties', 'jpos.properties'
}
}
}
test.dependsOn prepareTestConfiguration
// Note: prepareTestConfiguration is needed to be called too before JUnit tests are started in Eclipse
///////////////////////////////////////////////////////////////////////////////
// Artifact Upload
///////////////////////////////////////////////////////////////////////////////
nexusPublishing {
repositories {
sonatype()
}
}
def githubProjectUrl = 'https://github.com/JavaPOSWorkingGroup/javapos-config-loader'
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = artifactName
description = 'JavaPOS Configuration Loader 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
}