gradle-git-properties
gradle-git-properties copied to clipboard
generate git properties in android project
I've added the plugin to my android project, and git.properties not being generated automatically,
it only works running manually the task generateGitProperties
.
I saw a comment in other similar closed issue and it says that the git properties generation depends of classes
task,
now I can see that seems android projects have not a classes
task, just because I've tried
.\gradlew.bat classes -debug
Output
---
* What went wrong:
2021-12-16T14:42:20.138-0500 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Task 'classes' not found in root project 'myapp-android'.
is there a workaround to make the git.properties auto generated for android projects? I know that android have assembleDebug
and assembleRelease
default main tasks
Best Regards.
Something like project.tasks. assembleRelease.dependsOn('generateGitProperties')
will make generateGitProperties
to be executed before assembleRelease
Thanks @tha2015 but it doesn't work
I'm not familiar with Android projects. But generally when you makes a task A depends on some task B, that will make executing A implicitly executing B before A. Have you ran gradle command with debug flag to see what happened?
well not sure. I just added
project.tasks.assembleRelease.dependsOn('generateGitProperties')
and I got:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\erik\Github\myapp-android\build.gradle' line: 171
* What went wrong:
A problem occurred evaluating root project 'myapp-android'.
> Could not get unknown property 'assembleRelease' for task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.
How about this one? project.tasks.processResources.dependsOn('generateGitProperties')
same error: > Could not get unknown property 'processResources' for task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.
checking the tasks names from android studio I can see that processResources
does not exist, but there is a:
processDebugResources
task however project.tasks.processDebugResources.dependsOn('generateGitProperties')
throws same error
@tha2015
I've tried:
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebug')
task.dependsOn 'generateGitProperties'
if (task.name == 'assembleRelease')
task.dependsOn 'generateGitProperties'
}
And I can see that it works, but I'm not sure if that is the best way to fix this.