-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathbuild.gradle
More file actions
240 lines (209 loc) · 10.5 KB
/
build.gradle
File metadata and controls
240 lines (209 loc) · 10.5 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
plugins {
id 'java'
id 'application'
id 'idea'
id 'eclipse'
id 'org.jsonschema2pojo' version '1.2.1'
}
// Don't need these tasks, so disabling them. Makes it possible to avoid
// declaring a single application main class.
startScripts.enabled = false
run.enabled = false
// Also don't need the regular application distribution packages since
// this is just a set of samples. So disabling to make the build output
// cleaner
distTar.enabled=false
distZip.enabled=false
applicationName = 'solace-samples-java-jcsmp'
//version = ''
jar {
archiveBaseName = 'solace-samples-java-jcsmp'
archiveVersion = ''
manifest {
attributes 'Implementation-Title': 'Solace JCSMP Getting Started Samples',
'Implementation-Version': ''
}
exclude '**/log4j2.xml' // don't put it inside the JAR file, we'll have it external in config dir
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// Download context sensitive help and/or source code for eclipse and idea
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
jdt {
//if you want to alter the java versions (by default they are configured with gradle java plugin settings):
sourceCompatibility = 11
targetCompatibility = 11
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
sourceCompatibility = 11
targetCompatibility = 11
}
}
repositories {
mavenCentral()
// temporary, for testing
flatDir {
dirs 'lib'
}
}
configurations {
avroTools
}
dependencies {
// Solace Messaging API for Java Dependencies
implementation group: 'com.solacesystems', name: 'sol-jcsmp', version: '10.+'
// new improved logging framework, log4j2
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.+'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+'
// needed to 'bridge' the JCSMP API logs from JCL to log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-jcl', version: '2.+'
// include this next one if you want to use JsonLayout for log4j
//implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.4'
//implementation group: 'org.fusesource.jansi', name: 'jansi', version: '2.4.1'
//implementation fileTree(dir: 'lib', include: '*.jar') // temporary, for testing of stuff
// Use JUnit test framework.
//testImplementation 'junit:junit:4.13'
//Distributed Tracing Dependency on OpenTelemetry and Solace OpenTelemetry JCSMP Integration
implementation group: 'com.solace', name: 'solace-opentelemetry-jcsmp-integration', version: '1.1.0'
implementation group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp', version: '1.47.+'
implementation group: 'io.opentelemetry.semconv', name: 'opentelemetry-semconv', version: '1.29.+'
// Solace SERDES Dependencies
implementation group: 'com.solace', name: 'solace-serdes', version: '1.+'
implementation(platform("com.solace:solace-schema-registry-serdes-bom:1.+"))
implementation("com.solace:solace-schema-registry-avro-serde")
implementation("com.solace:solace-schema-registry-jsonschema-serde")
// Avro tools for schema code generation
avroTools group: 'org.apache.avro', name: 'avro-tools', version: '1.12.0'
}
// Define generated source directories for schema compilation
def avroDestDir = layout.buildDirectory.dir("generated-sources/avro").get().asFile
def jsonDestDir = layout.buildDirectory.dir("generated-sources/jsonschema").get().asFile
task generateAvro(type: JavaExec) {
description = 'Generates Java classes from Avro schema files'
group = 'build'
classpath = configurations.avroTools
mainClass = 'org.apache.avro.tool.Main'
def avroSrcDir = "${projectDir}/src/main/resources/avro-schema"
def userSchemaFile = file("${avroSrcDir}/user.avsc")
// Create output directory if it doesn't exist
doFirst {
file(avroDestDir).mkdirs()
// Make sure the file exists before trying to compile it
if (!userSchemaFile.exists()) {
throw new GradleException("Schema file ${userSchemaFile} does not exist!")
}
}
args = [
'compile',
'schema',
userSchemaFile.absolutePath,
avroDestDir
]
inputs.file(userSchemaFile)
outputs.dir(avroDestDir)
}
// Configure the jsonschema2pojo extension
jsonSchema2Pojo {
source = files("${projectDir}/src/main/resources/json-schema")
targetDirectory = jsonDestDir
targetPackage = 'com.solace.samples.serdes.jsonschema'
propertyWordDelimiters = ['_'] as char[]
}
compileJava {
dependsOn generateAvro
dependsOn generateJsonSchema2Pojo
}
sourceSets {
main {
java {
srcDir 'src/main/java'
srcDir 'src/dist/config' // so eclipse can find the log4j2.xml file
srcDir avroDestDir // generated Avro classes
srcDir jsonDestDir // generated JSON Schema classes
}
}
}
tasks.withType(JavaCompile).all {
options.compilerArgs.add("-Xlint:all")
}
// used to make the various start/run scripts
def scripts = [
'HelloWorld':'com.solace.samples.jcsmp.HelloWorld',
'DirectProcessor':'com.solace.samples.jcsmp.patterns.DirectProcessor',
'DirectPublisher':'com.solace.samples.jcsmp.patterns.DirectPublisher',
'DirectReplier':'com.solace.samples.jcsmp.patterns.DirectReplier',
'DirectRequestorBlocking':'com.solace.samples.jcsmp.patterns.DirectRequestorBlocking',
'DirectSubscriber':'com.solace.samples.jcsmp.patterns.DirectSubscriber',
'GuaranteedProcessor':'com.solace.samples.jcsmp.patterns.GuaranteedProcessor',
'GuaranteedPublisher':'com.solace.samples.jcsmp.patterns.GuaranteedPublisher',
'GuaranteedSubscriber':'com.solace.samples.jcsmp.patterns.GuaranteedSubscriber',
'TransactedProcessor':'com.solace.samples.jcsmp.patterns.TransactedProcessor',
'featureMessageSelectorsOnQueue':'com.solace.samples.jcsmp.features.MessageSelectorsOnQueue',
'featureMessageTTLAndDeadMessageQueue':'com.solace.samples.jcsmp.features.MessageTTLAndDeadMessageQueue',
'featureQueueProvisionAndBrowse':'com.solace.samples.jcsmp.features.QueueProvisionAndBrowse',
'featureQueueProvisionAndRequestActiveFlowIndication':'com.solace.samples.jcsmp.features.QueueProvisionAndRequestActiveFlowIndication',
'featureTransactions':'com.solace.samples.jcsmp.features.Transactions',
'featureMessageReplay':'com.solace.samples.jcsmp.features.MessageReplay',
'featureSecureSession':'com.solace.samples.jcsmp.features.SecureSession',
'topicPublisher':'com.solace.samples.jcsmp.features.TopicPublisher',
'topicSubscriber':'com.solace.samples.jcsmp.features.TopicSubscriber',
'queueProducer':'com.solace.samples.jcsmp.features.QueueProducer',
'queueConsumer':'com.solace.samples.jcsmp.features.QueueConsumer',
'basicRequestor':'com.solace.samples.jcsmp.features.BasicRequestor',
'basicReplier':'com.solace.samples.jcsmp.features.BasicReplier',
'confirmedPublish':'com.solace.samples.jcsmp.features.ConfirmedPublish',
'topicToQueueMapping':'com.solace.samples.jcsmp.features.TopicToQueueMapping',
'dtDirectPublisher':'com/solace/samples/jcsmp/features/distributedtracing/DirectPublisherWithManualInstrumentation',
'GuaranteedSubscriberWithSettle':'com.solace.samples.jcsmp.patterns.GuaranteedSubscriberWithSettle',
'dtDirectSubscriber':'com/solace/samples/jcsmp/features/distributedtracing/DirectSubscriberWithManualInstrumentation',
'HelloWorldJCSMPStringSerdes':'com.solace.samples.jcsmp.features.serdes.generic.HelloWorldJCSMPStringSerdes',
'HelloWorldJCSMPAvroSerde':'com.solace.samples.jcsmp.features.serdes.avro.HelloWorldJCSMPAvroSerde',
'AvroSerializeProducer':'com.solace.samples.jcsmp.features.serdes.avro.AvroSerializeProducer',
'AvroDeserializeConsumer':'com.solace.samples.jcsmp.features.serdes.avro.AvroDeserializeConsumer',
'AvroSerializeProducerSpecificRecord':'com.solace.samples.jcsmp.features.serdes.avro.AvroSerializeProducerSpecificRecord',
'AvroDeserializeConsumerSpecificRecord':'com.solace.samples.jcsmp.features.serdes.avro.AvroDeserializeConsumerSpecificRecord',
'AvroSerdesRequestor':'com.solace.samples.jcsmp.features.serdes.avro.AvroSerdesRequestor',
'AvroSerdesReplier':'com.solace.samples.jcsmp.features.serdes.avro.AvroSerdesReplier',
'JsonSchemaSerializeProducer':'com.solace.samples.jcsmp.features.serdes.jsonschema.JsonSchemaSerializeProducer',
'JsonSchemaDeserializeConsumerToPojo':'com.solace.samples.jcsmp.features.serdes.jsonschema.JsonSchemaDeserializeConsumerToPojo',
'JsonSchemaDeserializeConsumerToJsonNode':'com.solace.samples.jcsmp.features.serdes.jsonschema.JsonSchemaDeserializeConsumerToJsonNode',
'HelloWorldJCSMPJsonSchemaSerde':'com.solace.samples.jcsmp.features.serdes.jsonschema.HelloWorldJCSMPJsonSchemaSerde',
'JsonSchemaSerdesRequestor':'com.solace.samples.jcsmp.features.serdes.jsonschema.JsonSchemaSerdesRequestor',
'JsonSchemaSerdesReplier':'com.solace.samples.jcsmp.features.serdes.jsonschema.JsonSchemaSerdesReplier'
]
// for each of those array entries, let's make a start script
scripts.each() { scriptName, className ->
def t = tasks.create(name: scriptName+'StartScript', type: CreateStartScripts) {
mainClass = className
applicationName = scriptName
outputDir = new File(project.buildDir, 'scripts')
classpath = jar.outputs.files + project.configurations.runtimeClasspath
classpath += files('src/dist/config') // this is where our log4j2.xml file will be
doLast { // necessary since Gradle assumes all classpath are under 'lib', need to modify
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\config', '%APP_HOME%\\config')
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/config', '$APP_HOME/config')
}
defaultJvmOpts = ['-ea'] // enable assertions
}
applicationDistribution.into("bin") {
from(t)
fileMode = 0755
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
installDist {
destinationDir = new File(project.buildDir, 'staged')
}
assemble.dependsOn installDist