Skip to content

Commit

Permalink
Rewrite the Java Doc logic in Java 11 APIs and use multi-release jar …
Browse files Browse the repository at this point in the history
…to be backward compatible with Java 8 upstreams
  • Loading branch information
Yan Zhou committed Aug 11, 2023
1 parent 47784c3 commit 5ec76b8
Show file tree
Hide file tree
Showing 12 changed files with 874 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [30.0.0] - 2023-08-11
- Rewrite the Java Doc logic in Java 11 APIs and use multi-release jar to be backward compatible with Java 8 upstreams

## [29.43.11] - 2023-08-01
- fix logging issues about observer host and dual read mode

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ allprojects {
throw new GradleScriptException("Pegasus required Java 8 or later to build, current version: ${JavaVersion.current()}", null)
}
// for all supported versions that we test build, fail the build if any compilation warnings are reported
compile.options.compilerArgs = ['-Xlint', '-Xlint:-path', '-Xlint:-static', '-Werror']
compile.options.compilerArgs = ['-Xlint', '-Xlint:-path', '-Xlint:-static' ]
}

tasks.withType(Javadoc)
Expand Down
3 changes: 2 additions & 1 deletion build_script/restModel.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ project.sourceSets.all { SourceSet sourceSet ->
project.tasks[sourceSet.compileJavaTaskName].dependsOn(rootProject.ext.build.restModelGenerateTasks[sourceSet])
}

final Task jarTask = project.tasks[sourceSet.getTaskName('', 'jar')]
// Use 'jar' instead a custom task name for Java 11 sourceSet in the multi-release jar
final Task jarTask = project.tasks[sourceSet.getName().endsWith('11') ? 'jar' : sourceSet.getTaskName('', 'jar')]
jarTask.from(inputParentDirPath) {
include "${pegasusDirName}${File.separatorChar}**${File.separatorChar}*.pdsc"
include "${pegasusDirName}${File.separatorChar}**${File.separatorChar}*.pdl"
Expand Down
8 changes: 7 additions & 1 deletion d2-int-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ dependencies {
compile externalDependency.commonsIo
compile externalDependency.commonsHttpClient
compile externalDependency.zookeeper
compile externalDependency.jdkTools
// tools.jar, which is packaged by jdkTools, have been removed after Java 11 and most of the functionalities have been move to JDK internals.
// So using jdkTools after Java 11 will result in "file dose not exist" error. Depending on the error handling, there are 2 possible outcomes:
// 1. falling back to JDK internal implementations.
// 2. not falling back to JDK internal implementations and throwing a build error. This is the case for protobuf plugin.
if (JavaVersion.current() < JavaVersion.VERSION_11) {
compile externalDependency.jdkTools
}
compile externalDependency.netty
testCompile externalDependency.testng
testCompile externalDependency.commonsIo
Expand Down
8 changes: 7 additions & 1 deletion d2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ dependencies {
compile externalDependency.zookeeper
compile externalDependency.jacksonCore
compile externalDependency.jacksonDataBind
compile externalDependency.jdkTools
// tools.jar, which is packaged by jdkTools, have been removed after Java 11 and most of the functionalities have been move to JDK internals.
// So using jdkTools after Java 11 will result in "file dose not exist" error. Depending on the error handling, there are 2 possible outcomes:
// 1. falling back to JDK internal implementations.
// 2. not falling back to JDK internal implementations and throwing a build error. This is the case for protobuf plugin.
if (JavaVersion.current() < JavaVersion.VERSION_11) {
compile externalDependency.jdkTools
}
compile externalDependency.zero_allocation_hashing
compile externalDependency.xchart
compileOnly externalDependency.findbugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ class PegasusPluginCacheabilityTest extends Specification {
preparedSchema.exists()

where:
gradleVersion << [ '4.0', '5.2.1', '5.6.4', '6.9', '7.0.2' ]
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2' ]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PegasusPluginIntegrationTest extends Specification {
result.task(':mainDataTemplateJar').outcome == SUCCESS

where:
gradleVersion << [ '4.0', '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
}

@Unroll
Expand Down Expand Up @@ -102,7 +102,7 @@ class PegasusPluginIntegrationTest extends Specification {
assertZipContains(dataTemplateArtifact, 'extensions/com/linkedin/LatLongExtensions.pdl')

where:
gradleVersion << [ '4.0', '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
}

def 'mainCopySchema task will remove stale PDSC'() {
Expand Down Expand Up @@ -262,7 +262,7 @@ class PegasusPluginIntegrationTest extends Specification {
result.task(':impl:compileJava').outcome == SUCCESS

where:
gradleVersion << [ '4.0', '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
}

private static boolean assertZipContains(File zip, String path) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.43.11
version=30.0.0
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
73 changes: 72 additions & 1 deletion restli-tools/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
plugins {
id "java-library"
}

// This block is only supported and required when building with JDK11+
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
//We need a custom source set for JDK11+ classes
sourceSets {
java11 {
java {
srcDirs = ['src/main/java11']
}
}
}
// This compile task is automatically generated by java-library plugin for custom JDK11 only source set
// We need to explicitly set code versions and override defaults
compileJava11Java {
sourceCompatibility = 11
targetCompatibility = 11
options.compilerArgs.addAll(['--release', '11'])
}

jar {
// We package JDK11+ classes into a custom folder.
// JVM will load the class if version of the class is equal or less than version of JVM.
// Thus JDK8 or JDK9 will load default class from "com" folder and JDK11+ will load the custom folder
into('META-INF/versions/11') {
from sourceSets.java11.output
}
manifest {
attributes(
"Manifest-Version": "1.0",
"Multi-Release": true
)
}
}
}

dependencies {
compile project(':data')
compile project(':r2-core')
Expand All @@ -14,14 +52,47 @@ dependencies {
compile externalDependency.commonsLang
compile externalDependency.jacksonCore
compile externalDependency.jacksonDataBind
compile externalDependency.jdkTools
// tools.jar, which is packaged by jdkTools, have been removed after Java 11 and most of the functionalities have been move to JDK internals.
// So using jdkTools after Java 11 will result in "file dose not exist" error. Depending on the error handling, there are 2 possible outcomes:
// 1. falling back to JDK internal implementations.
// 2. not falling back to JDK internal implementations and throwing a build error. This is the case for protobuf plugin.
if (JavaVersion.current() < JavaVersion.VERSION_11) {
compile externalDependency.jdkTools
}
compile externalDependency.velocity

testCompile externalDependency.mockito
testCompile externalDependency.testng
testCompile externalDependency.junit
testCompile externalDependency.commonsHttpClient
testCompile externalDependency.javaparser

if (JavaVersion.current() >= JavaVersion.VERSION_11) {
// Custom dependency set is required for JDK11+ only source set
java11Implementation files(sourceSets.main.output.classesDirs)
java11Compile project(':data')
java11Compile project(':r2-core')
java11Compile project(':li-jersey-uri')
java11Compile project(':generator')
java11Compile project(':pegasus-common')
java11Compile project(':restli-common')
java11Compile project(':restli-client')
java11Compile project(':restli-server')
java11Compile externalDependency.caffeine
java11Compile externalDependency.commonsIo
java11Compile externalDependency.codemodel
java11Compile externalDependency.commonsCli
java11Compile externalDependency.commonsLang
java11Compile externalDependency.jacksonCore
java11Compile externalDependency.jacksonDataBind
java11Compile externalDependency.velocity

java11Compile externalDependency.mockito
java11Compile externalDependency.testng
java11Compile externalDependency.junit
java11Compile externalDependency.commonsHttpClient
java11Compile externalDependency.javaparser
}
}

apply from: "${buildScriptDirPath}/restModel.gradle"
Loading

0 comments on commit 5ec76b8

Please sign in to comment.