Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for excluding "dependsOn" #433

Open
TWiStErRob opened this issue Mar 21, 2023 · 0 comments
Open

API for excluding "dependsOn" #433

TWiStErRob opened this issue Mar 21, 2023 · 0 comments
Labels
a:feature new feature, improvement or request on:gradle issue related to Gradle

Comments

@TWiStErRob
Copy link
Owner

import org.gradle.api.Named
import org.gradle.api.Task
import org.gradle.api.tasks.TaskProvider

fun Task.notDependsOn(predicate: (String) -> Boolean) {
	this.setDependsOn(
		this.dependsOn
			.filterNot { it is TaskProvider<*> && predicate(it.name) }
			// Since Gradle 7.3 NamedDomainObjectCreatingProvider<TestSuite> contains "test", not a TaskProvider.
			.filterNot { it is Named && predicate(it.name) }
	)
}

was used in https://github.com/TWiStErRob/net.twisterrob.cinema/blob/e6473c1577707734b71580dda33e7dd3f30e65a1/Heroku/gradle/plugins/src/main/kotlin/net/twisterrob/cinema/build/testing.gradle.kts#L76-L82

probably better to prevent adding tasks in the first place, or disabling specific task conditionally with Task.enable.

@TWiStErRob TWiStErRob added a:feature new feature, improvement or request on:gradle issue related to Gradle labels Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature new feature, improvement or request on:gradle issue related to Gradle
Projects
None yet
Development

No branches or pull requests

1 participant