How can I use task rules?

Hello guys,

I see these rules at the end of gradle tasks command:

Rules ----- Pattern: build: Assembles the artifacts of a configuration. Pattern: upload: Assembles and uploads the artifacts belonging to a configuration. Pattern: clean: Cleans the output files of a task.

I have subprojects in my gradle project and I have made tasks like uploadWeb, uploadBackoffice and buildWeb, buildBackoffice, so it looks like I could use it. But I can’t find any instructions how to use it? What is ConfigurationName?

You can find information about task rules in the Gradle documentation.

I saw that, there is just how to create new task rules. But where I can find info about how to use these existing ones(build, upload)?

Check the tasks section of the Java plugin.

Ok, I understand now that I should use something like - gradle buildConfigurationName, but still how can I make this configuration name? Do you have any example?

Btw, thanks for quick response.

Correct me if I’m wrong, but I understand these task rules as a way to run some task on some specified project. Like if I have project(’:modules:web-module’), I have to create somehow ConfigurationName like WebModule for this project and then I will be able to run it using this rule like buildWebModule. Is it correct?

Guys?

The clean task rules apply to tasks.

Pattern: clean<TaskName>: Cleans the output files of a task.

Example: If you want to clean the output of the classes task (class files in build/classes), you’d run cleanClasses.

The task rules for build and upload apply to configurations.

Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

Example: To uploads the artifacts in the archives configuration, including the JAR file, you’d run uploadArchives.

I am not sure what your tasks uploadWeb, uploadBackoffice, buildWeb and buildBackoffice do. As long as web and backoffice are not custom configurations, the tasks won’t apply to this concept. Did that clarify your question?

Thank you for so detailed answer. So basically i need to create a configuration for each project and put all it

dependencies of that project to this configuration?

What exactly do you want to achieve in your project?