I am new to Gradle, so the answer may be simple, so I apologize if the answer is simple: I have a testing tool that I need to extract from it and compare it with the testing application version. However, the version of my tool is in my build.graddle file as
version '1.0'
I tried another way to access it (for example):
task generateSources {
File outDir
outDir = file("$buildDir/classes/test/tests/Version.java")
doFirst {
outDir.exists() || outDir.mkdirs()
new File(outDir).write("public class Version { public static final String VERSION = \"$project.version\"; }")
}
}
compileJava.dependsOn generateSources
compileJava.source generateSources.outputs.files, sourceSets.main.java
I found this piece of code to output the version to another java file, but I don’t see how I can get this information later (I mean, my tests are defined in src, and I will need to point to a file that does not exist at compilation - correct me if I am wrong here).
Any idea on how I could accomplish this task?