Skip to content

Commit 55e6ae2

Browse files
committed
chore: More laziness on some Gradle configurations and jvmArgs
1 parent ec7b845 commit 55e6ae2

File tree

1 file changed

+52
-31
lines changed

1 file changed

+52
-31
lines changed

dd-smoke-tests/osgi/build.gradle

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import aQute.bnd.gradle.Bundle
2+
13
plugins {
2-
id 'biz.aQute.bnd.builder' version '6.1.0' apply false
4+
id 'biz.aQute.bnd.builder' version '6.1.0' apply true
35
}
46

57
repositories {
@@ -12,14 +14,12 @@ apply from: "$rootDir/gradle/java.gradle"
1214
description = 'OSGi Application Smoke Tests.'
1315

1416
configurations {
15-
equinox
16-
felix
17-
knopflerfish
18-
bundles
19-
}
20-
21-
configurations.named('bundles') {
22-
transitive = false
17+
register('equinox')
18+
register('felix')
19+
register('knopflerfish')
20+
register('bundles') {
21+
transitive = false
22+
}
2323
}
2424

2525
dependencies {
@@ -42,13 +42,18 @@ dependencies {
4242
testImplementation project(':dd-smoke-tests')
4343
}
4444

45-
tasks.named("jar", Jar) {
46-
include 'datadog/smoketest/osgi/app/**'
45+
// The bnd builder plugin modifies the jar task to post process it with bnd.
46+
// Since this cannot be disabled, we disable the jar task and create another one.
47+
tasks.named('jar', Jar) {
48+
enabled = false
4749
}
4850

49-
import aQute.bnd.gradle.Bundle
51+
def jarTask = tasks.register("appJar", Jar) {
52+
from sourceSets.main.output
53+
include 'datadog/smoketest/osgi/app/**'
54+
}
5055

51-
tasks.register('commonBundle', Bundle) {
56+
def commonBundle = tasks.register('commonBundle', Bundle) {
5257
archiveClassifier = 'common'
5358
from sourceSets.main.output
5459
include 'datadog/smoketest/osgi/common/**'
@@ -57,7 +62,7 @@ tasks.register('commonBundle', Bundle) {
5762
}
5863
}
5964

60-
tasks.register('clientBundle', Bundle) {
65+
def clientBundle = tasks.register('clientBundle', Bundle) {
6166
archiveClassifier = 'client'
6267
from sourceSets.main.output
6368
include 'datadog/smoketest/osgi/client/**'
@@ -66,7 +71,7 @@ tasks.register('clientBundle', Bundle) {
6671
}
6772
}
6873

69-
tasks.register('messagingBundle', Bundle) {
74+
def messagingBundle = tasks.register('messagingBundle', Bundle) {
7075
archiveClassifier = 'messaging'
7176
from sourceSets.main.output
7277
include 'datadog/smoketest/osgi/messaging/**'
@@ -75,7 +80,7 @@ tasks.register('messagingBundle', Bundle) {
7580
}
7681
}
7782

78-
tasks.register('publishingBundle', Bundle) {
83+
def publishingBundle = tasks.register('publishingBundle', Bundle) {
7984
archiveClassifier = 'publishing'
8085
from sourceSets.main.output
8186
include 'datadog/smoketest/osgi/publishing/**'
@@ -84,7 +89,7 @@ tasks.register('publishingBundle', Bundle) {
8489
}
8590
}
8691

87-
tasks.register('subscribingBundle', Bundle) {
92+
def subscribingBundle = tasks.register('subscribingBundle', Bundle) {
8893
archiveClassifier = 'subscribing'
8994
from sourceSets.main.output
9095
include 'datadog/smoketest/osgi/subscribing/**'
@@ -94,18 +99,34 @@ tasks.register('subscribingBundle', Bundle) {
9499
}
95100

96101
tasks.withType(Test).configureEach {
97-
dependsOn "commonBundle", "clientBundle", "messagingBundle", "publishingBundle", "subscribingBundle", "jar"
98-
99-
jvmArgs "-Ddatadog.smoketest.osgi.appJar.path=${tasks.jar.archiveFile.get()}"
100-
jvmArgs "-Ddatadog.smoketest.osgi.equinoxJar.path=${configurations.equinox.first().path}"
101-
jvmArgs "-Ddatadog.smoketest.osgi.felixJar.path=${configurations.felix.first().path}"
102-
jvmArgs "-Ddatadog.smoketest.osgi.knopflerfishJar.path=${configurations.knopflerfish.first().path}"
103-
104-
jvmArgs "-Ddatadog.smoketest.osgi.bundle.paths=" +
105-
"${tasks.commonBundle.archiveFile.get()}," +
106-
"${tasks.clientBundle.archiveFile.get()}," +
107-
"${tasks.messagingBundle.archiveFile.get()}," +
108-
"${tasks.publishingBundle.archiveFile.get()}," +
109-
"${tasks.subscribingBundle.archiveFile.get()}," +
110-
"${configurations.bundles*.path.join(',')}"
102+
dependsOn commonBundle, clientBundle, messagingBundle, publishingBundle, subscribingBundle, jarTask
103+
104+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
105+
@Override
106+
Iterable<String> asArguments() {
107+
// def jarTask = tasks.named('appJar', Jar).get()
108+
def equinoxJar = configurations.named('equinox').get().first().path
109+
def felixJar = configurations.named('felix').get().first().path
110+
def knopflerfishJar = configurations.named('knopflerfish').get().first().path
111+
112+
def bundlePaths = [
113+
commonBundle.get().archiveFile.get(),
114+
clientBundle.get().archiveFile.get(),
115+
messagingBundle.get().archiveFile.get(),
116+
publishingBundle.get().archiveFile.get(),
117+
subscribingBundle.get().archiveFile.get(),
118+
*configurations.named('bundles').get().collect {
119+
it.path
120+
}
121+
].join(',')
122+
123+
return [
124+
"-Ddatadog.smoketest.osgi.appJar.path=${jarTask.get().archiveFile.get()}",
125+
"-Ddatadog.smoketest.osgi.equinoxJar.path=${equinoxJar}",
126+
"-Ddatadog.smoketest.osgi.felixJar.path=${felixJar}",
127+
"-Ddatadog.smoketest.osgi.knopflerfishJar.path=${knopflerfishJar}",
128+
"-Ddatadog.smoketest.osgi.bundle.paths=${bundlePaths}"
129+
]
130+
}
131+
})
111132
}

0 commit comments

Comments
 (0)