-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathbuild.gradle
207 lines (181 loc) · 7.11 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
/*
* Copyright 2018,2023 IBM Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
/*
* This file shows how to build and publish various artifacts for linking IBM MQ with Spring.
*/
/*
* The "JMSVERSION" environment variable can be set to "jms2" or "jms3" and that is used
* as the prefix for various control files and processing steps. We only build a single version
* from this file; to build both jms2 and jms3, you have to run gradle twice.
* The default is "jms3" if the env var is not set.
*/
ext.jmsVersionProperty = 'JMSVERSION'
ext.jmsVer = (System.getenv(jmsVersionProperty)== null?'jms3':System.getenv(jmsVersionProperty))
ext.propsFile = new File(rootDir, jmsVer + '.properties')
// Now we know the jms Version, load the specific properties
apply from: propsFile
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
// This is the MQ client version
ext.mqVersion = '9.4.1.0'
ext.mqGroup = 'com.ibm.mq'
// The groupid for the compiled jars when uploaded
group = mqGroup
version = mqStarterVersion
// Could enable access to early-release Spring packages if we need it
repositories {
mavenLocal()
//maven { url "https://repo.spring.io/snapshot" }
//maven { url "https://repo.spring.io/milestone" }
mavenCentral()
}
dependencies {
// Using "api" in this section means that the dependency ends up being listed
// with scope=compile in the generated POM. So users of this package end up with
// the transitive dependency Spring packages on their compile classpath too.
// The MQ Java client is accessed from Maven Central Repository. The name of the
// jar will vary for JMS2 and JMS3
api group:mqGroup, name: mqJar, version: mqVersion
// Spring
api group:'org.springframework', name: 'spring-core', version: springVersion
api group:'org.springframework', name: 'spring-context', version: springVersion
api group:'org.springframework', name: 'spring-beans', version: springVersion
api group:'org.springframework', name: 'spring-jms', version: springVersion
api group:'org.springframework.boot', name: 'spring-boot-starter', version: springBootVersion
api group: 'org.messaginghub', name: 'pooled-jms', version: pooledJmsVersion
// Testing
testImplementation group: 'junit', name: 'junit', version: jUnitVersion
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion
}
// Include variable debug info in the compiled classes
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
// Fail on javac warnings
compileJava.options.compilerArgs << "-Werror"
task mqPrereq(type:Exec) {
commandLine ("../prereqCheck.sh", mqGroup, mqJar, mqVersion)
}
// Always UTF-8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
task sourcesJar(type: Jar, dependsOn: ['mqPrereq',classes]) {
archiveClassifier = 'sources'
sourceSets.all {
into(name + "/java", { from allJava })
into(name + "/resources", { from resources })
}
}
javadoc {
failOnError = false
options.encoding 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
options.setMemberLevel JavadocMemberLevel.PROTECTED
/*
// Add a logging listener to check for javadoc warnings and fail the build if there are any
boolean hasJavaDocWarnings = false;
doFirst {
getLogging().addStandardErrorListener(new StandardOutputListener() {
void onOutput(CharSequence output) {
if (output =~ "warning:") {
hasJavaDocWarnings = true
}
}
})
}
doLast {
if (hasJavaDocWarnings) {
throw new GradleException("Build failed due to javadoc warnings.");
}
}
*/
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
// Load signing parameters from external properties
// This will probably be a "gradle.properties" file in this directory
['signing.keyId', 'signing.password', 'signing.secretKeyRingFile']
.each { propName ->
//set a property with the given name if the system property is set
//if the system property is not set then set the property to null if it isn't a signing one
if (System.properties.(propName.toString()) != null || !propName.startsWith("signing")) {
ext.(propName.toString()) = System.properties.(propName.toString())
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact(sourcesJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
pom {
name = rootProject.name
description = 'Spring configuration for the official IBM MQ library for Java'
inceptionYear = '2018'
packaging = 'jar'
url = 'https://github.com/ibm-messaging/mq-jms-spring'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
connection = 'scm:git:git://github.com/ibm-messaging/mq-jms-spring.git'
developerConnection = 'scm:git:[email protected]/ibm-messaging/mq-jms-spring.git'
url = 'https://github.com/ibm-messaging/mq-jms-spring.git'
}
properties = [
'project.build.sourceEncoding': 'UTF-8'
]
developers {
developer {
name = 'IBM MQ'
url = 'https://ibm.com/software/products/en/ibm-mq'
organization = 'IBM'
organizationUrl = 'http://www.ibm.com'
}
}
}
}
}
repositories {
maven {
def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
def releasesUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releasesUrl
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
signing {
println("Will sign the artifacts")
sign publishing.publications.mavenJava
}
}