-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace all usages of findProperty (#652)
* Replace all usages of findProperty It is not compatible with project isolation, `providers.gradleProperty` is however. This PR also change all build script related usages, though this isn't needed for consumers of course. * Spotless * Build's working again * Add new API * Make proguard rule validator modern * Support local properties --------- Co-authored-by: Zac Sweers <[email protected]>
- Loading branch information
Showing
7 changed files
with
79 additions
and
25 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
33 changes: 33 additions & 0 deletions
33
...-ir/moshi-gradle-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/gradle/LocalProperties.kt
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,33 @@ | ||
package dev.zacsweers.moshix.ir.gradle | ||
|
||
import java.util.Properties | ||
import org.gradle.api.Project | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.provider.ValueSource | ||
import org.gradle.api.provider.ValueSourceParameters | ||
|
||
internal fun Project.createPropertiesProvider(filePath: String): Provider<Properties> { | ||
return project.providers.of(LocalProperties::class.java) { | ||
it.parameters.propertiesFile.set(project.layout.projectDirectory.file(filePath)) | ||
} | ||
} | ||
|
||
/** Implementation of provider holding a local properties file's parsed [Properties]. */ | ||
internal abstract class LocalProperties : ValueSource<Properties, LocalProperties.Parameters> { | ||
interface Parameters : ValueSourceParameters { | ||
val propertiesFile: RegularFileProperty | ||
} | ||
|
||
override fun obtain(): Properties? { | ||
val provider = parameters.propertiesFile | ||
if (!provider.isPresent) { | ||
return null | ||
} | ||
val propertiesFile = provider.asFile.get() | ||
if (!propertiesFile.exists()) { | ||
return null | ||
} | ||
return Properties().apply { propertiesFile.inputStream().use(::load) } | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.