Created
April 22, 2016 19:00
-
-
Save martinda/31173a4627c47d38f50b09042cdb4ae0 to your computer and use it in GitHub Desktop.
Building fruits with Gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Managed | |
interface FruitBinarySpec extends BinarySpec { | |
List<String> getFruits() | |
void setFruits(List<String> fruits) | |
} | |
class FruitTask extends SourceTask { | |
@Input | |
List<String> fruits | |
@TaskAction | |
void peform() { | |
println(fruits) | |
} | |
} | |
class FruitRules extends RuleSource { | |
@ComponentType | |
void registerBinary(TypeBuilder<FruitBinarySpec> builder) {} | |
@BinaryTasks | |
void generateTasks(ModelMap<Task> tasks, final FruitBinarySpec binary) { | |
println("CALL ME !!!") | |
binary.tasks.each { task -> | |
def taskName = task.taskName("build",binary.name) | |
tasks.create(taskName, FruitTask) { fruitTask -> | |
fruitTask.fruits = binary.fruits | |
} | |
} | |
} | |
} | |
apply plugin: FruitRules | |
model { | |
components { | |
redFruits(FruitBinarySpec) { | |
fruits = ['apple', 'cherry'] | |
} | |
yellowFruits(FruitBinarySpec) { | |
fruits = ['banana', 'pina'] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment