Hi, I am using init-script to get the source code...
# plugin-development
h
Hi, I am using init-script to get the source code path details of a Java project. Basically I made three calls to get the Java project details 1. Project project = task.getProject(); 2. FileCollection classpath = task.getClasspath(); 3. Iterable<File> srcFiles = task.getSource().getFiles(); But when I use them, I get the build failure problem with a message. “Invocation of 'Task.project' by task ':compileJava' at execution time is unsupported.” One way to avoid this is by using “*-Dorg.gradle.configuration-cache*=false” What is the best way to resolve the issue? -Hari
m
What are you using
project
for? You should use input properties instead
Copy code
For example, if you reference a Project in order to get the project.version at execution time, you should instead directly declare the project version as an input to your task using a Property<String>. Another example would be to reference a SourceSet to later get the source files, the compilation classpath or the outputs of the source set. You should instead declare these as a FileCollection input and reference just that.
h
Thank you, I will try and share my findings.
When we access properties, Gradle is fetching secrets. It seems an unsafe way.