-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ProtobufExtract for Gradle Configuration Cache
by using an ArchiveActionFacade in the same vein as CopyActionFacade in order to remove usage of Project at execution time ArchiveActionFacade uses the internal FileOperations type from Gradle. FileOperations is internal but quite stable and this plugin is already making use of other internals. Moreover, a public alternative will be available in Gradle 6.6 Signed-off-by: Paul Merlin <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/groovy/com/google/protobuf/gradle/ArchiveActionFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.google.protobuf.gradle; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.file.FileTree; | ||
import org.gradle.api.internal.file.FileOperations; | ||
|
||
import javax.inject.Inject; | ||
|
||
public interface ArchiveActionFacade { | ||
|
||
FileTree zipTree(Object path); | ||
|
||
FileTree tarTree(Object path); | ||
|
||
class ProjectBased implements ArchiveActionFacade { | ||
|
||
private final Project project; | ||
|
||
ProjectBased(Project project) { | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
public FileTree zipTree(Object path) { | ||
return project.zipTree(path); | ||
} | ||
|
||
@Override | ||
public FileTree tarTree(Object path) { | ||
return project.tarTree(path); | ||
} | ||
} | ||
|
||
abstract class ServiceBased implements ArchiveActionFacade { | ||
|
||
// TODO Use public ArchiveOperations from Gradle 6.6 instead | ||
@Inject | ||
public abstract FileOperations getFileOperations(); | ||
|
||
@Override | ||
public FileTree zipTree(Object path) { | ||
return getFileOperations().zipTree(path); | ||
} | ||
|
||
@Override | ||
public FileTree tarTree(Object path) { | ||
return getFileOperations().tarTree(path); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters