How can I use third-party dependencies in a custom task in buildSrc in Gradle

I followed this guide to create custom tasks with Gradle. http://www.ysofters.com/2015/02/26/how-to-create-gradle-project-with-custom-task-classes-in-groovy/ I also looked at the Gradle document. https://docs.gradle.org/current/userguide/custom_tasks.html

This is very clear, and I can get examples for compiling and using tasks, so that so far so good.

However, the examples only show the import of the Gradle API files, i.e.

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

I want to add some more dependencies, i.e.

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean
import org.springframework.core.io.FileSystemResource

but I can do it - Gradle will complain and say that "the class cannot solve .."

apache-commons buildscript-> build.gradle, , ..

buildscript {
 dependencies {

        classpath group: 'org.springframework', name: 'spring-core', version: springVersion
        classpath group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
      .....

, - ?

+5
1

build.gradle buildSrc. buildSrc/build.gradle buildSrc/build.gradle gradle : https://github.com/gradle/gradle/blob/v4.1.0/buildSrc/build.gradle

+7

Source: https://habr.com/ru/post/1622025/


All Articles