forked from SolaceSamples/solace-samples-java-jcsmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
155 lines (138 loc) · 6.57 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
plugins {
id 'java'
id 'application'
id 'idea'
id 'eclipse'
}
// 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
}
// 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 = 1.8
targetCompatibility = 1.8
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
mavenCentral()
// temporary, for testing
flatDir {
dirs 'lib'
}
}
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.29.0'
implementation group: 'io.opentelemetry', name: 'opentelemetry-semconv', version: '1.29.0-alpha'
}
sourceSets {
main {
java {
srcDir 'src/main/java'
srcDir 'src/dist/config' // so eclipse can find the log4j2.xml file
}
}
}
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'
]
// 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