Skip to content

Commit

Permalink
Fix the concurrent configuration resolution error in Gradle 8 and abo…
Browse files Browse the repository at this point in the history
…ve (#996)

* Fix the concurrent configuration resolution error in Gradle 8 and above

* Rerun all checks
  • Loading branch information
bzzzzzz authored Apr 8, 2024
1 parent 522bed0 commit e7d0ee8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 5 additions & 1 deletion 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]

## [29.52.1] - 2024-04-03
- fix concurrent configuration resolution issue in the Gradle plugin in Gradle 8 and above

## [29.52.0] - 2024-04-01
- fix applying client side service config override in INDIS flow

Expand Down Expand Up @@ -5677,7 +5680,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.52.0...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.52.1...master
[29.52.1]: https://github.com/linkedin/rest.li/compare/v29.52.0...v29.52.1
[29.52.0]: https://github.com/linkedin/rest.li/compare/v29.51.14...v29.52.0
[29.51.14]: https://github.com/linkedin/rest.li/compare/v29.51.13...v29.51.14
[29.51.13]: https://github.com/linkedin/rest.li/compare/v29.51.12...v29.51.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPlugin;
Expand Down Expand Up @@ -1185,6 +1186,14 @@ private static Configuration getDataModelConfig(Project project, SourceSet sourc
: project.getConfigurations().getByName("dataModel");
}

private static Dependency getDataModelDependency(Project project, String dependencyPath, SourceSet sourceSet)
{
Map<String, String> declaration = new HashMap<>();
declaration.put("path", dependencyPath);
declaration.put("configuration", isTestSourceSet(sourceSet) ? "testDataModel" : "dataModel");
return project.getDependencies().project(declaration);
}

private static boolean isTaskSuccessful(Task task)
{
return task.getState().getExecuted()
Expand Down Expand Up @@ -1264,8 +1273,15 @@ protected void configureRestModelGeneration(Project project, SourceSet sourceSet
.plus(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME))
.plus(sourceSet.getRuntimeClasspath());
String destinationDirPrefix = getGeneratedDirPath(project, sourceSet, REST_GEN_TYPE) + File.separatorChar;
FileCollection restModelResolverPath = apiProject.files(getDataSchemaPath(project, sourceSet))
.plus(getDataModelConfig(apiProject, sourceSet));
Project finalApiProject = apiProject;

Configuration restModelResolverConf = project.getConfigurations().create(sourceSet.getTaskName(null, "restModelResolverPath"), c -> {
c.setVisible(false);
c.setCanBeConsumed(false);
c.setCanBeResolved(true);
c.getDependencies().add(project.getDependencies().create(finalApiProject.files(getDataSchemaPath(project, sourceSet))));
c.getDependencies().add(getDataModelDependency(project, finalApiProject.getPath(), sourceSet));
});
Set<File> watchedRestModelInputDirs = buildWatchedRestModelInputDirs(project, sourceSet);
Set<File> restModelInputDirs = difference(sourceSet.getAllSource().getSrcDirs(),
sourceSet.getResources().getSrcDirs());
Expand All @@ -1289,7 +1305,7 @@ protected void configureRestModelGeneration(Project project, SourceSet sourceSet
.getExtensions().getExtraProperties().get("pegasus");
task.setIdlOptions(pegasusOptions.get(sourceSet.getName()).idlOptions);

task.setResolverPath(restModelResolverPath);
task.setResolverPath(restModelResolverConf);
if (isPropertyTrue(project, ENABLE_ARG_FILE))
{
task.setEnableArgFile(true);
Expand Down Expand Up @@ -1347,7 +1363,7 @@ protected void configureRestModelGeneration(Project project, SourceSet sourceSet
task.dependsOn(generateRestModelTask);
task.setCurrentIdlFiles(SharedFileUtils.getIdlFiles(project, destinationDirPrefix));
task.setPreviousIdlDirectory(apiIdlDir);
task.setResolverPath(restModelResolverPath);
task.setResolverPath(restModelResolverConf);
task.setCodegenClasspath(project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION));
task.setIdlCompatLevel(PropertyUtil.findCompatLevel(project, FileCompatibilityType.IDL));
if (isPropertyTrue(project, ENABLE_ARG_FILE))
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.52.0
version=29.52.1
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down

0 comments on commit e7d0ee8

Please sign in to comment.