Gradle - создайте пользовательскую библиотеку Groovy с зависимостями Java (Apache Commons) - PullRequest
0 голосов
/ 12 февраля 2019

Я пытаюсь создать Groovy библиотеку (JAR), используя Java-зависимости, но безуспешно.Мне удалось использовать простые методы, но когда мой код использует сторонние библиотеки, он не найдет связанный класс.

Версия Gradle: 5.2

Groovy 1.8.9

Структура проекта:

enter image description here

build.gradle

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Groovy project to get you started.
 * For more details take a look at the Groovy Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.2/userguide/tutorial_groovy_projects.html
 */

plugins {
    // Apply the groovy plugin to add support for Groovy
    id 'groovy'
}

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // Use the latest Groovy version for building this library
    implementation 'org.codehaus.groovy:groovy-all:1.8.8'
    compile  group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
    compile  group: 'commons-io', name: 'commons-io', version: '2.6'

   // https://mvnrepository.com/artifact/org.spockframework/spock-core
    testCompile group: 'org.spockframework', name: 'spock-core', version: '1.1-groovy-2.4'

}

settings.gradle

/*
 * This file was generated by the Gradle 'init' task.
 *
 * The settings file is used to specify which projects to include in your build.
 *
 * Detailed information about configuring a multi-project build in Gradle can be found
 * in the user manual at https://docs.gradle.org/5.2/userguide/multi_project_builds.html
 */

rootProject.name = 'com.itau.plugins'

MyClassWithDependencies:

package com.itau.plugins

import org.apache.commons.io.FileUtils


class MyClassWithDependencies {

    def copy(source, destination) {
        FileUtils.copyFile(new File(source), new File(destination))
    }

    def copyDir(source, destination) {
        FileUtils.copyDirectory(new File(source), new File(destination))
    }

}

Ошибка довольно очевидна:

Когда я пытаюсь импортировать, выдает Groovy:unable to resolve class org.apache.commons.io.FileUtils

И, когда я запускаю gradlew build --no-build-cache вывод

BUILD SUCCESSFUL in 1s                                                                                                                                                                                  
2 actionable tasks: 2 up-to-date   

и мои зависимости gradle (я думаю, что изображение здесь - лучший вариант):

enter image description here

Любая помощь могла бы быть полезна.Заранее спасибо.

PS Мне удалось создать Fat Jar, но это не то, что мне нужно.

...