This message was deleted.
# community-support
s
This message was deleted.
e
if you create a
dev
source set, it'll default to
src/dev/resources
,
src/dev/java
, etc.
m
The main thing is that we don't want src/dev/resources included in a release.
j
maybe R8?
m
R8?
j
it is which Android uses to remove any unused resource
I think it can be used in java projects too but I am not sure, I haven't used it outside Android
e
it can, but r8 doesn't do anything with resources
do you want full-blown build variants like Android?
m
I was kind of thinking of something more like
if System.getenv("CI")
type of solution.
e
you could conditionally register new srcDirs, but IMO that's a terrible idea. your CI will either verify the prod configuration but not the dev configuration, or vice versa.
m
I might be XY Probleming this big time.
e
https://docs.gradle.org/current/userguide/feature_variants.html shows off gradle-native variants, but they don't have the automatic hierarchy that Android does
m
We have files like "cassandra.properties" and "rabbitmq.properties" in our src/main/resources and the idea one of my developers floated was that when running locally we include src/dev/resources in the classpath to supercede our default settings.
j
why not using local.properties
e
I don't think you can rely on a specific order of resources on conflict
m
He wants to be able to edit those files locally, have them gitignored, but not have it in the resulting JAR file when we build for release.
j
local.properties then
e
rather than
local.properties
it would be better to allow parameterizing how properties get loaded, then you can have a separate run configuration that loads them from a differently-named properties file
j
Copy code
public fun Project.getProperty(name: String): String =
    localProperties?.getProperty(name)?.also {
        logger.debug("Property $name found in the project `local.properties` file")
    }
        ?: localProperties?.getProperty(name.toSnakeCase())
            ?: System.getenv(name)?.also {
            logger.debug("Property $name found in the root `local.properties`file")
        }
            ?: System.getenv(name.toSnakeCase())
            ?: providers.gradleProperty(name).orNull?.also {
            logger.debug("Property $name found in the environment variables")
        }
            ?: providers.gradleProperty(name.toSnakeCase()).orNull.run {
            checkNotNull(this) {
                logger.debug("Property $name found in the `gradle.properties` file")
                val project = this@getProperty
                val userHomePath = System.getProperty("user.home")
                """
                    |The property `$name` is not available in any of the next sources:
                    |  - ${project.projectDir}${File.separator}local.properties
                    |  - ${project.rootDir}${File.separator}local.properties
                    |  - Environment variable
                    |  - ${project.projectDir}${File.separator}gradle.properties
                    |  - ${project.rootDir}${File.separator}gradle.properties
                    |  - $userHomePath${File.separator}.gradle${File.separator}gradle.properties
                    |  
                """.trimMargin()
            }
I use that to get properties from local, env and gradle properties
e
how does that help with the resources that are used in the binary
m
Yeah.
That's my problem. XML, properties, and JKS files.
A lot of the properties could be driven by environment variable, but some cannot.
j
I replied about his properties files which he wants to be ignored
m
Thanks for the feedback everyone
I appreciate it.
🙂 1