Skip to content

Commit 8da9f53

Browse files
ThadHouseJaciBrunning
authored andcommitted
Add way to disable the force no cache deletion behavior (#287)
* Add way to disable the force no cache deletion behavior Fixes #286 The displays a large warning when the property is set, with no way to disable the message. We really do not want teams to have that property enabled. * Remove setting examples
1 parent f315114 commit 8da9f53

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/groovy/edu/wpi/first/gradlerio/GradleRIOPlugin.groovy

+12-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class GradleRIOPlugin implements Plugin<Project> {
6969
}
7070
}
7171

72-
disableCacheCleanup()
72+
disableCacheCleanup(project)
7373

7474
project.gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
7575
try {
@@ -97,16 +97,25 @@ class GradleRIOPlugin implements Plugin<Project> {
9797
_registered_build_finished = true
9898
}
9999

100+
private static final String GRADLERIO_DISABLE_CACHE_CLEANUP_PROPERTY = "gradlerio.disable.cache.cleanup"
100101
private static final String CACHE_CLEANUP_PROPERTY = "org.gradle.cache.cleanup"
101102

102103
// Write to ~/.gradle/gradle.properties, to disable cache cleanup. Cache cleanup
103104
// has the possibility to make dependencies 'go missing' if left unattended for a long time.
104105
// There's a chance this could happen during competition.
105-
void disableCacheCleanup() {
106+
void disableCacheCleanup(Project project) {
106107
def logger = ETLoggerFactory.INSTANCE.create("GR_CACHECLEANUP")
108+
if (project.findProperty(GRADLERIO_DISABLE_CACHE_CLEANUP_PROPERTY) == "false") {
109+
logger.logErrorHead("Warning! You have the property gradlerio.disable.cache.cleanup set to false")
110+
logger.logError("This can cause issues when going to competition, since this means your dependencies can be deleted unwillingly after a month.")
111+
logger.logError("Remove this from your gradle.properties file unless you know what you're doing.")
112+
logger.logError("Note, this may result in you not being able to deploy code at competition")
113+
return
114+
}
115+
107116
try {
108117
// TODO: Issue #6084 on gradle/gradle, this may not work in 5.1 or all use cases
109-
def gradleProperties = new File("${System.getProperty('user.home')}/.gradle/gradle.properties")
118+
def gradleProperties = new File("${project.gradle.gradleUserHomeDir}/gradle.properties")
110119
if (gradleProperties.isFile()) {
111120
Properties props = GUtil.loadProperties(gradleProperties)
112121
String cleanup = props.getProperty(CACHE_CLEANUP_PROPERTY)

0 commit comments

Comments
 (0)