Skip to content

Commit

Permalink
change the source set entrypoint to java17
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Zhou committed Aug 30, 2023
1 parent ddbbe1b commit 1b70e14
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions build_script/restModel.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ project.sourceSets.all { SourceSet sourceSet ->
project.tasks[sourceSet.compileJavaTaskName].dependsOn(rootProject.ext.build.restModelGenerateTasks[sourceSet])
}

// 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')]
// Use 'jar' instead a custom task name for Java 17 source set in the multi-release jar
final Task jarTask = project.tasks[sourceSet.getName().endsWith('17') ? 'jar' : sourceSet.getTaskName('', 'jar')]
jarTask.from(inputParentDirPath) {
include "${pegasusDirName}${File.separatorChar}**${File.separatorChar}*.pdsc"
include "${pegasusDirName}${File.separatorChar}**${File.separatorChar}*.pdl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
package com.linkedin.restli.internal.common;

import java.nio.ByteBuffer;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
Expand Down Expand Up @@ -198,7 +199,7 @@ private static ByteBuffer decodeConsecutiveOctets(String s, int start)
byte b = decodeOctet(s, i + 1);
bb.put(b);
}
bb.flip();
((Buffer)bb).flip();
return bb;
}

Expand Down
57 changes: 30 additions & 27 deletions restli-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ plugins {
// 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
// Note that we use java 17 as the source set entry point to minimize the impact on existing Java 8 and Java 11 consumers.
// This is because the JVM of the consumer will pick up the highest bytecode version which is lower than or equal to the JVM version.
// So, for Java 8 and Java 11 consumers, Java 17 does not qualify since it is higher than 8 and 11, which means they will
// fall back to using the default Java 8 level bytecode.
sourceSets {
java11 {
java17 {
java {
srcDirs = ['src/main/java11']
srcDirs = ['src/main/java17']
}
}
}
// 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 {
compileJava17Java {
sourceCompatibility = 11
targetCompatibility = 11
options.compilerArgs.addAll(['--release', '11'])
Expand All @@ -24,8 +28,8 @@ if (JavaVersion.current() >= JavaVersion.VERSION_11) {
// 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
into('META-INF/versions/17') {
from sourceSets.java17.output
}
manifest {
attributes(
Expand Down Expand Up @@ -63,29 +67,28 @@ dependencies {

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
java17Compile project(':data')
java17Compile project(':r2-core')
java17Compile project(':li-jersey-uri')
java17Compile project(':generator')
java17Compile project(':pegasus-common')
java17Compile project(':restli-common')
java17Compile project(':restli-client')
java17Compile project(':restli-server')
java17Compile externalDependency.caffeine
java17Compile externalDependency.commonsIo
java17Compile externalDependency.codemodel
java17Compile externalDependency.commonsCli
java17Compile externalDependency.commonsLang
java17Compile externalDependency.jacksonCore
java17Compile externalDependency.jacksonDataBind
java17Compile externalDependency.velocity

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private static String buildDoc(String docText)
{
if (docText != null && !docText.isEmpty())
{
return DocletHelper.processDocCommentStr(docText);
return docText;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public static MethodIdentity create(ExecutableElement method)
final List<String> parameterTypeNames = new ArrayList<>();
for (VariableElement param : method.getParameters()) {
TypeMirror type = param.asType();
parameterTypeNames.add(DocletHelper.getCanonicalName(type.toString()));
parameterTypeNames.add(type.toString());
}

return new MethodIdentity(method.getEnclosingElement().toString() + "." + method.getSimpleName().toString(),
Expand Down

0 comments on commit 1b70e14

Please sign in to comment.