Skip to content

Commit

Permalink
[build] Allow selection of relevant netty-native-transport from CLI
Browse files Browse the repository at this point in the history
The `forceTranport` property can be used to choose between `nio` and
`native` when running Gradle tasks like tests. This allows to select
the underlying transport to active, eg. when running a test matrix in
CI.
  • Loading branch information
simonbasle committed Oct 25, 2019
1 parent e03c7c6 commit c36be27
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,32 @@ configure(rootProject) { project ->

compile "io.netty:netty-handler:${nettyVersion}"
compile "io.netty:netty-codec-http:${nettyVersion}"
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
optional "io.netty:netty-transport-native-kqueue:${nettyVersion}"

//transport resolution: typical build forces epoll but not kqueue transitively
//on the other hand, if we want to make transport-specific tests, we'll make all
// native optional at compile time and add correct native/nio to testRuntime
if (project.hasProperty("forceTransport")) {
//so that the main code compiles
optional "io.netty:netty-transport-native-epoll:${nettyVersion}"
optional "io.netty:netty-transport-native-kqueue:${nettyVersion}"
//now we explicitly add correctly qualified native, or do nothing if we want to test NIO
if (forceTransport == "native") {
if (osdetector.os == "osx") {
testRuntime "io.netty:netty-transport-native-kqueue:${nettyVersion}${os_suffix}"
}
else if (osdetector.os == "linux") {
testRuntime "io.netty:netty-transport-native-epoll:${nettyVersion}${os_suffix}"
}
}
else if (forceTransport != "nio") {
throw new InvalidUserDataException("invalid -PforceTranport option " + forceTransport + ", should be native|nio")
}
}
else {
//classic build to be distributed
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
optional "io.netty:netty-transport-native-kqueue:${nettyVersion}"
}

// Testing
testCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion"
Expand Down

0 comments on commit c36be27

Please sign in to comment.