diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a391c1c7..2dbde7738b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [29.51.0] - 2024-02-06 +- Minor version bump due to dropping support to Gradle versions below 6.9.4. +- Make rest.li codebase use Gradle 6.9.4 to build itself +- Make PegasusPlugin compatible with all Gradle version from 6.9.4 to 8.5 + ## [29.50.1] - 2024-01-31 - Fix r2-netty illegal state exception due to premature channel recycling. @@ -5627,7 +5632,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.50.1...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.51.0...master +[29.51.0]: https://github.com/linkedin/rest.li/compare/v29.50.1...v29.51.0 [29.50.1]: https://github.com/linkedin/rest.li/compare/v29.50.0...v29.50.1 [29.50.0]: https://github.com/linkedin/rest.li/compare/v29.49.9...v29.50.0 [29.49.9]: https://github.com/linkedin/rest.li/compare/v29.49.8...v29.49.9 diff --git a/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/IntegTestingUtil.groovy b/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/IntegTestingUtil.groovy index bb88184026..e5b33c9011 100644 --- a/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/IntegTestingUtil.groovy +++ b/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/IntegTestingUtil.groovy @@ -1,7 +1,7 @@ package com.linkedin.pegasus.gradle final class IntegTestingUtil { - public static final List ALL_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.5.1'] + public static final List ALL_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.5.1', '8.5'] public static final List OLD_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4'] - public static final List NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.6.3'] + public static final List NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.6.3', '8.5'] } diff --git a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java index 46e0aa1028..4a2453665f 100644 --- a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java +++ b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java @@ -74,7 +74,6 @@ import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.Sync; -import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.bundling.Jar; import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.javadoc.Javadoc; @@ -942,9 +941,6 @@ protected void configureSchemaAnnotationValidation(Project project, project.getTasks().getByName("check").dependsOn(validateSchemaAnnotationTask); } - - - @SuppressWarnings("deprecation") protected void configureGeneratedSourcesAndJavadoc(Project project) { _generateJavadocTask = project.getTasks().create("generateJavadoc", Javadoc.class); @@ -963,8 +959,7 @@ protected void configureGeneratedSourcesAndJavadoc(Project project) _generateSourcesJarTask = project.getTasks().create("generateSourcesJar", Jar.class, jarTask -> { jarTask.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); jarTask.setDescription("Generates a jar file containing the sources for the generated Java classes."); - // FIXME change to #getArchiveClassifier().set("sources"); breaks backwards-compatibility before 5.1 - jarTask.setClassifier("sources"); + jarTask.getArchiveClassifier().set("sources"); }); project.getArtifacts().add("generatedSources", _generateSourcesJarTask); @@ -985,8 +980,7 @@ protected void configureGeneratedSourcesAndJavadoc(Project project) jarTask.dependsOn(_generateJavadocTask); jarTask.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); jarTask.setDescription("Generates a jar file containing the Javadoc for the generated Java classes."); - // FIXME change to #getArchiveClassifier().set("sources"); breaks backwards-compatibility before 5.1 - jarTask.setClassifier("javadoc"); + jarTask.getArchiveClassifier().set("javadoc"); jarTask.from(_generateJavadocTask.getDestinationDir()); }); @@ -1443,8 +1437,8 @@ protected void configureRestModelGeneration(Project project, SourceSet sourceSet // Use the files from apiDir for generating the changed files report as we need to notify user only when // source system files are modified. - changedFileReportTask.setIdlFiles(SharedFileUtils.getSuffixedFiles(project, apiIdlDir, IDL_FILE_SUFFIX)); - changedFileReportTask.setSnapshotFiles(SharedFileUtils.getSuffixedFiles(project, apiSnapshotDir, + changedFileReportTask.getIdlFiles().from(SharedFileUtils.getSuffixedFiles(project, apiIdlDir, IDL_FILE_SUFFIX)); + changedFileReportTask.getSnapshotFiles().from(SharedFileUtils.getSuffixedFiles(project, apiSnapshotDir, SNAPSHOT_FILE_SUFFIX)); changedFileReportTask.mustRunAfter(publishRestliSnapshotTask, publishRestliIdlTask); changedFileReportTask.doLast(new CacheableAction<>(t -> @@ -1516,7 +1510,6 @@ protected void configurePegasusSchemaSnapshotGeneration(Project project, SourceS project.getTasks().getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(publishPegasusSchemaSnapshot); } - @SuppressWarnings("deprecation") protected void configureAvroSchemaGeneration(Project project, SourceSet sourceSet) { File dataSchemaDir = project.file(getDataSchemaPath(project, sourceSet)); @@ -1566,8 +1559,7 @@ protected void configureAvroSchemaGeneration(Project project, SourceSet sourceSe copySpec.eachFile(fileCopyDetails -> fileCopyDetails.setPath("avro" + File.separatorChar + fileCopyDetails.getPath()))); - // FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1 - task.setAppendix(getAppendix(sourceSet, "avro-schema")); + task.getArchiveAppendix().set(getAppendix(sourceSet, "avro-schema")); task.setDescription("Generate an avro schema jar"); }); @@ -1644,7 +1636,6 @@ protected void configureConversionUtilities(Project project, SourceSet sourceSet }); } - @SuppressWarnings("deprecation") protected GenerateDataTemplateTask configureDataTemplateGeneration(Project project, SourceSet sourceSet) { File dataSchemaDir = project.file(getDataSchemaPath(project, sourceSet)); @@ -1835,8 +1826,7 @@ protected GenerateDataTemplateTask configureDataTemplateGeneration(Project proje task.dependsOn(dataTemplateJarDepends); task.from(targetSourceSet.getOutput()); - // FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1 - task.setAppendix(getAppendix(sourceSet, "data-template")); + task.getArchiveAppendix().set(getAppendix(sourceSet, "data-template")); task.setDescription("Generate a data template jar"); }); @@ -1987,7 +1977,6 @@ private String mapSourceSetToFeatureName(SourceSet sourceSet) { // It also compiles the rest client source files into classes, and creates both the // rest model and rest client jar files. // - @SuppressWarnings("deprecation") protected void configureRestClientGeneration(Project project, SourceSet sourceSet) { // idl directory for api project @@ -2108,8 +2097,7 @@ protected void configureRestClientGeneration(Project project, SourceSet sourceSe .info("Add idl file: {}", fileCopyDetails)); copySpec.setIncludes(Collections.singletonList('*' + IDL_FILE_SUFFIX)); }); - // FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1 - task.setAppendix(getAppendix(sourceSet, "rest-model")); + task.getArchiveAppendix().set(getAppendix(sourceSet, "rest-model")); task.setDescription("Generate rest model jar"); }); @@ -2126,8 +2114,7 @@ protected void configureRestClientGeneration(Project project, SourceSet sourceSe copySpec.setIncludes(Collections.singletonList('*' + IDL_FILE_SUFFIX)); }); task.from(targetSourceSet.getOutput()); - // FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1 - task.setAppendix(getAppendix(sourceSet, "rest-client")); + task.getArchiveAppendix().set(getAppendix(sourceSet, "rest-client")); task.setDescription("Generate rest client jar"); }); @@ -2231,7 +2218,7 @@ public static String getNonEmptyProperty(Project project, String propertyName) */ public static boolean isPropertyTrue(Project project, String propertyName) { - return project.hasProperty(propertyName) && Boolean.valueOf(project.property(propertyName).toString()); + return project.hasProperty(propertyName) && Boolean.parseBoolean(project.property(propertyName).toString()); } private static String createModifiedFilesMessage(Collection nonEquivExpectedFiles, diff --git a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/tasks/ChangedFileReportTask.java b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/tasks/ChangedFileReportTask.java index a7dd65f606..5f310a0eb3 100644 --- a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/tasks/ChangedFileReportTask.java +++ b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/tasks/ChangedFileReportTask.java @@ -1,27 +1,28 @@ package com.linkedin.pegasus.gradle.tasks; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; import org.gradle.api.DefaultTask; +import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.file.FileCollection; import org.gradle.api.specs.Specs; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.SkipWhenEmpty; import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.incremental.IncrementalTaskInputs; +import org.gradle.work.ChangeType; +import org.gradle.work.Incremental; +import org.gradle.work.InputChanges; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; -public class ChangedFileReportTask extends DefaultTask + +public abstract class ChangedFileReportTask extends DefaultTask { private final Collection _needCheckinFiles = new ArrayList<>(); - private FileCollection _idlFiles = getProject().files(); - private FileCollection _snapshotFiles = getProject().files(); - public ChangedFileReportTask() { //with Gradle 6.0, Declaring an incremental task without outputs is not allowed. @@ -29,11 +30,11 @@ public ChangedFileReportTask() } @TaskAction - public void checkFilesForChanges(IncrementalTaskInputs inputs) + public void checkFilesForChanges(InputChanges inputs) { getLogger().lifecycle("Checking idl and snapshot files for changes..."); - getLogger().info("idlFiles: " + _idlFiles.getAsPath()); - getLogger().info("snapshotFiles: " + _snapshotFiles.getAsPath()); + getLogger().info("idlFiles: " + getIdlFiles().getAsPath()); + getLogger().info("snapshotFiles: " + getSnapshotFiles().getAsPath()); Set filesRemoved = new HashSet<>(); Set filesAdded = new HashSet<>(); @@ -41,24 +42,24 @@ public void checkFilesForChanges(IncrementalTaskInputs inputs) if (inputs.isIncremental()) { - inputs.outOfDate(inputFileDetails -> { - if (inputFileDetails.isAdded()) - { - filesAdded.add(inputFileDetails.getFile().getAbsolutePath()); - } - - if (inputFileDetails.isRemoved()) - { - filesRemoved.add(inputFileDetails.getFile().getAbsolutePath()); - } - - if (inputFileDetails.isModified()) - { - filesChanged.add(inputFileDetails.getFile().getAbsolutePath()); - } - }); - - inputs.removed(inputFileDetails -> filesRemoved.add(inputFileDetails.getFile().getAbsolutePath())); + for (FileCollection fileCollection : Arrays.asList(getIdlFiles(), getSnapshotFiles())) { + inputs.getFileChanges(fileCollection).forEach(inputFileDetails -> { + if (inputFileDetails.getChangeType().equals(ChangeType.ADDED)) + { + filesAdded.add(inputFileDetails.getFile().getAbsolutePath()); + } + + if (inputFileDetails.getChangeType().equals(ChangeType.REMOVED)) + { + filesRemoved.add(inputFileDetails.getFile().getAbsolutePath()); + } + + if (inputFileDetails.getChangeType().equals(ChangeType.MODIFIED)) + { + filesChanged.add(inputFileDetails.getFile().getAbsolutePath()); + } + }); + } if (!filesRemoved.isEmpty()) { @@ -91,28 +92,12 @@ private String joinByComma(Set files) } @InputFiles - @SkipWhenEmpty - public FileCollection getSnapshotFiles() - { - return _snapshotFiles; - } - - public void setSnapshotFiles(FileCollection snapshotFiles) - { - _snapshotFiles = snapshotFiles; - } + @Incremental + public abstract ConfigurableFileCollection getSnapshotFiles(); @InputFiles - @SkipWhenEmpty - public FileCollection getIdlFiles() - { - return _idlFiles; - } - - public void setIdlFiles(FileCollection idlFiles) - { - _idlFiles = idlFiles; - } + @Incremental + public abstract ConfigurableFileCollection getIdlFiles(); @Internal public Collection getNeedCheckinFiles() diff --git a/gradle.properties b/gradle.properties index 8e5f4a00fc..01eb3552f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.50.1 +version=29.51.0 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true