-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issues/159: Support Gradle configuration cache
- Loading branch information
Showing
11 changed files
with
176 additions
and
82 deletions.
There are no files selected for viewing
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
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
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
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
44 changes: 44 additions & 0 deletions
44
skippy-gradle/src/main/java/io/skippy/gradle/CachableProperties.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,44 @@ | ||
package io.skippy.gradle; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.SourceSetContainer; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* A sub-set of relevant {@link Project} properties that are compatible with Gradle's Configuration Cache. | ||
*/ | ||
class CachableProperties { | ||
|
||
final boolean sourceSetContainerAvailable; | ||
final List<File> classesDirs; | ||
final SkippyPluginExtension skippyPluginExtension; | ||
final Path projectDir; | ||
final Path buildDir; | ||
|
||
private CachableProperties(boolean sourceSetContainerAvailable, List<File> classesDirs, SkippyPluginExtension skippyExtension, Path projectDir, Path buildDir) { | ||
this.sourceSetContainerAvailable = sourceSetContainerAvailable; | ||
this.classesDirs = classesDirs; | ||
this.skippyPluginExtension = skippyExtension; | ||
this.projectDir = projectDir; | ||
this.buildDir = buildDir; | ||
} | ||
|
||
static CachableProperties from(Project project) { | ||
var sourceSetContainer = project.getExtensions().findByType(SourceSetContainer.class); | ||
if (sourceSetContainer != null) { | ||
// new ArrayList<>() is a workaround for https://github.com/gradle/gradle/issues/26942 | ||
var classesDirs = new ArrayList<>(sourceSetContainer.stream().flatMap(sourceSet -> sourceSet.getOutput().getClassesDirs().getFiles().stream()).toList()); | ||
var skippyExtension = project.getExtensions().getByType(SkippyPluginExtension.class); | ||
var projectDir = project.getProjectDir().toPath(); | ||
var buildDir = project.getLayout().getBuildDirectory().getAsFile().get().toPath(); | ||
return new CachableProperties(sourceSetContainer != null, classesDirs, skippyExtension, projectDir, buildDir); | ||
} else { | ||
return new CachableProperties(false, null, null, null, null); | ||
} | ||
} | ||
|
||
} |
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
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
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
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
Oops, something went wrong.