Skip to content

Commit

Permalink
Make restli plugin compatible with Gradle 8 and create a new release (#…
Browse files Browse the repository at this point in the history
…978)

* Make restli plugin compatible with Gradle 8 and create a new release

* Remove unused dependency

* Don't bump major version

* Do a proper changelog update

---------

Co-authored-by: Evgeny Barbashov <[email protected]>
  • Loading branch information
bzzzzzz and Evgeny Barbashov authored Feb 6, 2024
1 parent 0bf8c62 commit e66f2be
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 78 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.linkedin.pegasus.gradle

final class IntegTestingUtil {
public static final List<String> ALL_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.5.1']
public static final List<String> ALL_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.5.1', '8.5']
public static final List<String> OLD_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4']
public static final List<String> NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.6.3']
public static final List<String> NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.6.3', '8.5']
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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());
});

Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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");
});

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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");
});

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
});

Expand All @@ -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");
});

Expand Down Expand Up @@ -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<String> nonEquivExpectedFiles,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
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<String> _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.
getOutputs().upToDateWhen(Specs.satisfyNone());
}

@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<String> filesRemoved = new HashSet<>();
Set<String> filesAdded = new HashSet<>();
Set<String> filesChanged = new HashSet<>();

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())
{
Expand Down Expand Up @@ -91,28 +92,12 @@ private String joinByComma(Set<String> 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<String> getNeedCheckinFiles()
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.50.1
version=29.51.0
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down

0 comments on commit e66f2be

Please sign in to comment.