For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

BinaryTasks

Deprecated

The Gradle software model is deprecated and will be removed in Gradle 10. Use the new component model (e.g. cpp-application, cpp-library, swift-application, swift-library, xctest) instead.

Declares the tasks to build a custom org.gradle.platform.base.BinarySpec binary. The following example demonstrates how to register multiple tasks for custom binary using a plugin with a org.gradle.platform.base.BinaryTasks annotation.

@Managed interface SampleComponent extends ComponentSpec {}
@Managed interface SampleBinary extends BinarySpec {}

apply plugin: MyCustomBinariesPlugin

class MyCustomBinaryCreationTask extends DefaultTask {
     @TaskAction void build() {
         //building the binary
     }
}

class MyCustomBinariesPlugin extends RuleSource {
    @ComponentType
    void register(TypeBuilder<SampleBinary> builder) {}

    @BinaryTasks
    void createBinaryTasks(ModelMap<Task> tasks, SampleBinary binary) {
        tasks.create("${binary.name}Task1", MyCustomBinaryCreationTask)
        tasks.create("${binary.name}Task2") {
            dependsOn "${binary.name}Task1"
        }
    }
}

Since

2.2

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String