Skip to content

Commit

Permalink
Building bookkeeper with gradle on java11
Browse files Browse the repository at this point in the history

Descriptions of the changes in this PR:


### Motivation
This change enable gradle to build on java11 

### Changes
- generateJniHeaders for CpuAffinity using native gradle config rather than using javac rather than specifying it via command line in gradle
- Update gradle dependencies that helps build java11
- Update checkstyle to use native configurations from gradle 

Master Issue: apache#2640



Reviewers: Prashant Kumar <None>, Henry Saputra <[email protected]>, Matteo Merli <[email protected]>

This closes apache#2817 from pradeepbn/java11 and squashes the following commits:

95c19de [pradeepbn] Merge pull request #1 from mauricebarnum/pr-2817-jni
049a510 [maurice barnum] use compileJava task to generate jni headers
f690e90 [Pradeep Nagaraju] Replace javac to use gradle native config
9285c10 [Pradeep Nagaraju] Revert the changes to avoid deprecation of finalize()
22c3cfd [Pradeep Nagaraju] remove unwanted changes
b416059 [Pradeep Nagaraju] - Building bookkeeper with gradle on java11 - Use gradle native solution for using javac rather than specifying it via command line in gradle
  • Loading branch information
pradeepbn authored Oct 8, 2021
1 parent 9c6c5d9 commit 883231e
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 23 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ allprojects {
checkstyle {
toolVersion "${checkStyleVersion}"
configFile file("$rootDir/buildtools/src/main/resources/bookkeeper/checkstyle.xml")
configDirectory = file("$rootDir/buildtools/src/main/resources/bookkeeper")
checkstyleMain {
source ='src/main/java'
}
Expand Down
2 changes: 1 addition & 1 deletion buildtools/src/main/resources/bookkeeper/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}" default="./buildtools/src/main/resources/bookkeeper/suppressions.xml" />
<property name="file" value="${config_loc}/suppressions.xml" default="./buildtools/src/main/resources/bookkeeper/suppressions.xml" />
</module>

<!-- Check that every module has a package-info.java -->
Expand Down
10 changes: 2 additions & 8 deletions circe-checksum/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ dependencies {
testImplementation depLibs.mockito
}

task generateJniHeaders(type:Exec) {
ext {
javahOutputDir = "$buildDir/javahGenerated"
}
dependsOn classes
def classpath = sourceSets.main.output.classesDirs.join(":")
commandLine("javah", "-d", javahOutputDir, "-classpath",
classpath, "com.scurrilous.circe.crc.Sse42Crc32C")
compileJava {
options.headerOutputDirectory = file("${buildDir}/javahGenerated")
}

jar {
Expand Down
4 changes: 2 additions & 2 deletions circe-checksum/src/main/circe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ library {

binaries.configureEach { CppBinary binary ->
def compileTask = binary.compileTask.get()
compileTask.dependsOn project(':circe-checksum').generateJniHeaders
compileTask.dependsOn project(':circe-checksum').compileJava
compileTask.includes.from("${Jvm.current().javaHome}/include",
project(':circe-checksum').generateJniHeaders.javahOutputDir)
project(':circe-checksum').compileJava.options.headerOutputDirectory)

def osFamily = binary.targetPlatform.targetMachine.operatingSystemFamily

Expand Down
16 changes: 6 additions & 10 deletions cpu-affinity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/

plugins {
id 'java'
}

dependencies {
compileOnly depLibs.lombok
compileOnly depLibs.spotbugsAnnotations
implementation depLibs.commonsLang3
implementation depLibs.guava
implementation depLibs.slf4j
testImplementation depLibs.junit

compileOnly depLibs.lombok
annotationProcessor depLibs.lombok
testCompileOnly depLibs.lombok
testAnnotationProcessor depLibs.lombok
}

task generateJniHeaders(type:Exec) {
ext {
javahOutputDir = "$buildDir/javahGenerated"
}
dependsOn classes
def classpath = sourceSets.main.output.classesDirs.join(":")
commandLine("javah", "-d", javahOutputDir, "-classpath",
classpath, "org.apache.bookkeeper.common.util.affinity.impl.CpuAffinityJni")
compileJava {
options.headerOutputDirectory = file("${buildDir}/javahGenerated")
}

jar {
Expand Down
4 changes: 2 additions & 2 deletions cpu-affinity/src/main/affinity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ plugins {
library {
binaries.configureEach { CppBinary binary ->
def compileTask = binary.compileTask.get()
compileTask.dependsOn project(':cpu-affinity').generateJniHeaders
compileTask.dependsOn project(':cpu-affinity').compileJava
compileTask.includes.from("${Jvm.current().javaHome}/include",
project(':cpu-affinity').generateJniHeaders.javahOutputDir)
project(':cpu-affinity').compileJava.options.headerOutputDirectory)

def osFamily = binary.targetPlatform.targetMachine.operatingSystemFamily

Expand Down
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ depVersions = [
hdrhistogram: "2.1.4",
httpclient: "4.5.13",
jackson: "2.11.1",
javaAnnotations:"1.3.2",
jcommander: "1.78",
jctools: "2.1.2",
jetty: "9.4.31.v20200723",
Expand Down Expand Up @@ -111,6 +112,7 @@ depLibs = [
hamcrest: "org.hamcrest:hamcrest-all:${depVersions.hamcrest}",
httpclient: "org.apache.httpcomponents:httpclient:${depVersions.httpclient}",
jacksonAnnotations: "com.fasterxml.jackson.core:jackson-annotations:${depVersions.jackson}",
javaAnnotations: "javax.annotation:javax.annotation-api:${depVersions.javaAnnotations}",
jacksonCore: "com.fasterxml.jackson.core:jackson-core:${depVersions.jackson}",
jacksonDatabind: "com.fasterxml.jackson.core:jackson-databind:${depVersions.jackson}",
jcommander: "com.beust:jcommander:${depVersions.jcommander}",
Expand Down
1 change: 1 addition & 0 deletions stream/distributedlog/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
testImplementation project(path: ':stream:distributedlog:common', configuration: 'testArtifacts')
testImplementation depLibs.junit
testImplementation depLibs.mockito
implementation depLibs.javaAnnotations

annotationProcessor depLibs.lombok
testAnnotationProcessor depLibs.lombok
Expand Down
1 change: 1 addition & 0 deletions stream/proto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation depLibs.lombok
implementation depLibs.grpc
implementation depLibs.commonsLang3
implementation depLibs.javaAnnotations

annotationProcessor depLibs.lombok
}
Expand Down
1 change: 1 addition & 0 deletions stream/server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
runtimeOnly depLibs.vertxCore
runtimeOnly depLibs.vertxWeb
testImplementation depLibs.mockito
implementation depLibs.javaAnnotations

annotationProcessor depLibs.lombok
}
Expand Down
1 change: 1 addition & 0 deletions stream/tests-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation depLibs.slf4j

annotationProcessor depLibs.lombok
implementation depLibs.javaAnnotations
}

protobuf {
Expand Down

0 comments on commit 883231e

Please sign in to comment.