Slackbot
01/10/2023, 12:25 PMVampire
01/10/2023, 12:27 PM.env or DotEnv and how is it related to Gradle?Jiří Grygerek
01/10/2023, 12:30 PMVampire
01/10/2023, 12:31 PMprocessResources task using expand to replace the placeholder.Jiří Grygerek
01/10/2023, 12:32 PMVampire
01/10/2023, 12:33 PMJiří Grygerek
01/10/2023, 12:34 PMVampire
01/10/2023, 12:34 PMJiří Grygerek
01/10/2023, 12:35 PMJiří Grygerek
01/10/2023, 12:35 PMJiří Grygerek
01/10/2023, 12:36 PMprocessResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
task api() {
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())
}
ext.apiToken = properties.getProperty('api.token');
}Vampire
01/10/2023, 12:37 PMJiří Grygerek
01/10/2023, 12:40 PM.jar file I don't know if something like that is even possible in java/gradle.Jiří Grygerek
01/10/2023, 12:49 PMprocessResources {
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
properties.load(propertiesFile.newDataInputStream());
def props = [version: version, api_key: properties.get("api.token")]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}Vampire
01/10/2023, 1:53 PMplugin.yml and that file will be present in the jar, so it will be discoverable from the jar.
That's why I then said if you don't want it discoverable from the jar, you need to read it for example from an environment variable or system property or file and configure that accordingly in the runtime environment.Jiří Grygerek
01/10/2023, 1:54 PM