Slackbot
02/05/2024, 9:04 PMVampire
02/05/2024, 9:33 PMprocessResources
task without creating a new task and then read from that resource file using a Java file.Rachel Garcia
02/05/2024, 10:08 PMRachel Garcia
02/05/2024, 10:08 PMRachel Garcia
02/05/2024, 10:09 PMpublic static final String VERSION_INFO = "@VERSION@";
public static final String BUILD_INFO = "@BUILD@";
These are the variables but I cant understand how to implement or call the java file in the gradle to set the variablesRachel Garcia
02/05/2024, 10:12 PMtask processAppJava(type: Copy) {
from 'src/main/java/memoranda/ui'
include 'App.java'
into 'build/modified-java'
// define the variables
def VERSION_INFO = '@VERSION@'
def NEW_VERSION = '4.5.1'
def BUILD_INFO = '@BUILD@'
def NEW_BUILD = '8.1'
filter { line ->
line.replace(VERSION_INFO, NEW_VERSION)
.replace(BUILD_INFO, NEW_BUILD)
}
doLast {
println version
}
}
Vampire
02/05/2024, 10:15 PMbuild/modified-java
, yes.
But from there it will not end up in any compilation or result.Vampire
02/05/2024, 10:16 PMAdam
02/05/2024, 10:19 PMbuild/modified-java
, but have you set up that directory as a source dir?Vampire
02/05/2024, 10:20 PMVampire
02/05/2024, 10:20 PMVampire
02/05/2024, 10:21 PMVampire
02/05/2024, 10:21 PMAdam
02/05/2024, 10:22 PMbuild.gradle
file) that will generate a Java file with build constants https://github.com/gmazzo/gradle-buildconfig-pluginRachel Garcia
02/05/2024, 10:24 PMRachel Garcia
02/05/2024, 10:25 PMAdam
02/05/2024, 10:26 PMVampire
02/05/2024, 10:29 PM...properties
file in src/main/resources
, in it have your placeholders, then configure the processResources
task with your filter / replace / expand configuration, and at runtime read the values from this resource file.Rachel Garcia
02/05/2024, 10:34 PMRachel Garcia
02/05/2024, 10:35 PMVampire
02/05/2024, 10:36 PMAdam
02/05/2024, 10:37 PMRachel Garcia
02/05/2024, 10:38 PMVampire
02/05/2024, 10:38 PMVampire
02/05/2024, 10:39 PMRachel Garcia
02/05/2024, 10:39 PMVampire
02/05/2024, 10:40 PMRachel Garcia
02/05/2024, 10:40 PMRachel Garcia
02/05/2024, 10:41 PMVampire
02/05/2024, 10:41 PMVampire
02/05/2024, 10:41 PMVampire
02/05/2024, 10:41 PMRachel Garcia
02/05/2024, 10:42 PMRachel Garcia
02/05/2024, 10:42 PMVampire
02/05/2024, 10:42 PMRachel Garcia
02/05/2024, 10:43 PMCompilation failed; see the compiler error output for details.
Vampire
02/05/2024, 10:43 PMVampire
02/05/2024, 10:43 PMVampire
02/05/2024, 10:43 PMRachel Garcia
02/05/2024, 10:43 PMVampire
02/05/2024, 10:44 PMRachel Garcia
02/05/2024, 10:45 PMRachel Garcia
02/05/2024, 10:45 PMRachel Garcia
02/05/2024, 10:46 PMVampire
02/05/2024, 10:47 PMRachel Garcia
02/05/2024, 10:47 PMVampire
02/05/2024, 10:47 PMRachel Garcia
02/05/2024, 10:48 PM