Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building Bookkeeper with gradle on Java11 #2814

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/compatibility-check-java11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Build with Maven
run: mvn clean package -B -nsu -DskipBookKeeperServerTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
- name: Build with gradle
run: ./gradlew test -x bookkeeper-server:test -x tests:integration:cluster:test -x tests:integration:smoke:test -x tests:integration:standalone:test -Dtestlogger.theme=plain
4 changes: 2 additions & 2 deletions .github/workflows/compatibility-check-java8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean package -B -nsu spotbugs:check -DskipBookKeeperServerTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
- name: Build with gradle
run: ./gradlew test -x tests:integration:cluster:test -x tests:integration:smoke:test -x tests:integration:standalone:test -Dtestlogger.theme=plain
13 changes: 6 additions & 7 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B -nsu clean install -Pdocker -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

- name: Run metadata driver tests
run: mvn -B -nsu -f metadata-drivers/pom.xml test -DintegrationTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

- name: Run all integration tests
run: mvn -B -nsu -f tests/pom.xml test -DintegrationTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
- name: run cluster integration test
run: ./gradlew :tests:integration:cluster:test -Dtestlogger.theme=plain
- name: run smoke test
run: ./gradlew tests:integration:smoke -Dtestlogger.theme=plain
- name: run standalone test
run: ./gradlew tests:integration:standalone -Dtestlogger.theme=plain
8 changes: 6 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Validate pull request style
run: mvn clean -B -nsu apache-rat:check checkstyle:check package -Ddistributedlog -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
- name: Validate pull request style validate license headers
run: ./gradlew rat
- name: Validate pull request style validate style
run: ./gradlew checkstyleMain -x microbenchmarks:checkstyleMain
- name: Validate pull request style validate style
run: ./gradlew spotbugsMain
- name: Check license files
run: dev/check-all-licenses
5 changes: 1 addition & 4 deletions .github/workflows/remaining-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ on:
- 'site/**'
workflow_dispatch:

env:
MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3

jobs:
test:

Expand All @@ -49,4 +46,4 @@ jobs:
with:
java-version: 1.8
- name: Run remaining tests
run: mvn -B -nsu -am -pl bookkeeper-server clean install test -Dtest="!org.apache.bookkeeper.client.**,!org.apache.bookkeeper.bookie.**,!org.apache.bookkeeper.replication.**,!org.apache.bookkeeper.tls.**" -DfailIfNoTests=false -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
run: ./gradlew bookkeeper-server:test -PexcludeTests="**org.apache.bookkeeper.bookie.*, **org.apache.bookkeeper.client.*, **org.apache.bookkeeper.replication.*, **org.apache.bookkeeper.tls.*" -Dtestlogger.theme=plain
2 changes: 1 addition & 1 deletion .github/workflows/replication-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
with:
java-version: 1.8
- name: Run replication tests
run: mvn -B -nsu -am -pl bookkeeper-server clean install test -Dtest="org.apache.bookkeeper.replication.**" -DfailIfNoTests=false -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
run: ./gradlew bookkeeper-server:test --tests="org.apache.bookkeeper.replication.*" -Dtestlogger.theme=plain
2 changes: 1 addition & 1 deletion .github/workflows/stream-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
- name: Build with Maven
run: mvn -B -nsu clean install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
- name: Run StreamStorage tests
run: mvn -B -nsu -f stream/pom.xml verify -DstreamTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
run: ./gradlew build -x bookkeeper-server:test -x checkstyleMain -x checkstyleTest -x spotbugsTest -x spotbugsMain -x rat -x signDistTar -Dtestlogger.theme=plain
5 changes: 1 addition & 4 deletions .github/workflows/tls-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ on:
- 'site/**'
workflow_dispatch:

env:
MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3

jobs:
test:

Expand All @@ -49,4 +46,4 @@ jobs:
with:
java-version: 1.8
- name: Run tls tests
run: mvn -B -am -nsu -pl bookkeeper-server clean install test -Dtest="org.apache.bookkeeper.tls.**" -DfailIfNoTests=false -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
run: ./gradlew bookkeeper-server:test --tests="org.apache.bookkeeper.tls.*" -Dtestlogger.theme=plain
2 changes: 2 additions & 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 Expand Up @@ -101,6 +102,7 @@ allprojects {
'**/out/**',
'**/generated/**',
'**/build/**',
'**/target/**',
'**/.idea/**',
'.git/**/*',
'.github/**/*',
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
4 changes: 2 additions & 2 deletions circe-checksum/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ task generateJniHeaders(type:Exec) {
}
dependsOn classes
def classpath = sourceSets.main.output.classesDirs.join(":")
commandLine("javah", "-d", javahOutputDir, "-classpath",
classpath, "com.scurrilous.circe.crc.Sse42Crc32C")
commandLine("javac", "-h", javahOutputDir, "-classpath",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, gradle has first class support for JNI headers now. i didn't check the version, and i don't know gradle well enough yet to update the dependencies for the shared objects.

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.CompileOptions.html#org.gradle.api.tasks.compile.CompileOptions:headerOutputDirectory

Copy link
Contributor Author

@pradeepbn pradeepbn Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, totally agree @mauricebarnum and made relevant changes in another PR #2817. I will close this PR since this is based on @pkumar-singh PR #2812 and want to keep it independent of #2812 changes.

classpath, "./src/main/java/com/scurrilous/circe/crc/Sse42Crc32C.java")
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.scurrilous.circe.utils.NativeUtils.loadLibraryFromJar;
import static com.scurrilous.circe.utils.NativeUtils.libType;

import java.lang.ref.Cleaner;
import java.nio.ByteBuffer;
import com.scurrilous.circe.IncrementalIntHash;
import com.scurrilous.circe.impl.AbstractIncrementalIntHash;
Expand Down Expand Up @@ -54,6 +55,23 @@ public static boolean isSupported() {
config = 0;
}

// A cleaner similar to a finalizer(deprecated in java11)
private static final Cleaner cleaner = Cleaner.create();

static class State implements Runnable {
private final long config;
State(long config) {
// initialize State needed for cleaning action
this.config = config;
}

public void run() {
// cleanup action accessing State, executed at most once
if (this.config != 0)
freeConfig(this.config);
}
}

public Sse42Crc32C(int[] chunkWords) {
if (chunkWords.length == 0) {
config = 0;
Expand All @@ -62,12 +80,7 @@ public Sse42Crc32C(int[] chunkWords) {
if (config == 0)
throw new RuntimeException("CRC32C configuration allocation failed");
}
}

@Override
protected void finalize() {
if (config != 0)
freeConfig(config);
cleaner.register(config, new State(config));
}

@Override
Expand Down
10 changes: 6 additions & 4 deletions cpu-affinity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
* 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) {
Expand All @@ -37,8 +39,8 @@ task generateJniHeaders(type:Exec) {
}
dependsOn classes
def classpath = sourceSets.main.output.classesDirs.join(":")
commandLine("javah", "-d", javahOutputDir, "-classpath",
classpath, "org.apache.bookkeeper.common.util.affinity.impl.CpuAffinityJni")
commandLine("javac", "-h", javahOutputDir, "-classpath",
classpath, "./src/main/java/org/apache/bookkeeper/common/util/affinity/impl/CpuAffinityJni.java")
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@

import java.io.IOException;

import lombok.experimental.UtilityClass;

/**
* JNI wrapper of native functions for CPU affinity.
*/
@UtilityClass
public class CpuAffinityJni {
static native boolean isRoot();

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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* A test base for testing cookie commands.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MetadataDrivers.class })
public class CookieCommandTestBase extends CommandTestBase {

Expand Down