Hi -
I have the following projects
Parent
- Child1
- Child2
…
In each child I have build.gradle with
(1) an abstract base task class
(2) and the actual task implementing the abstract methods.
I want to move the abstract base class to the parent project and share among all children projects, instead of duplicating.
What’s the best way to do it?
Do I write my own plugin as described in (https://guides.gradle.org/designing-gradle-plugins/)?
Are there other alternatives?
Thanks,
Amit.
@CacheableTask
abstract class MyBuild extends DefaultTask {
Boolean forceBuild = null
@InputDirectory
abstract DirectoryProperty getSrcInputDir()
@Option( option = 'force', description = 'Build even if not stale in cache. Will force build only this repo')
void setForceBuild(final Boolean ignoreVal) {
forceBuild = true
}
@Input
Map<String,String> getInputProperties() {
def inputMap = [:]
if(forceBuild==true) {
inputMap['timestamp'] = LocalDateTime.now().toString()
}
return inputMap
}
@TaskAction
void build {
....
}
}
========================
task mybuild(type: MyBuild) {
description 'my description'
srcInputDir = file('pathname to the src dir')
outputDir = file('./output')
}