即使显式未配置

时间:2016-08-21 09:28:39

标签: gradle

我有一个Java Gradle 2.14.1项目,其中包含几个子项目:abcnono是'特殊',因为它在src/main/java中不包含任何内容,它只是使用所有模块进行了一些e2e测试。我想将maven插件应用于abc,但不应用于no。这是我的代码(以Bash会话的形式;请忽略没有代码的事实 - 这是重现我的问题的最简单的事情):

maven-test $ find .
.
./a
./b
./build.gradle
./c
./gradle
./gradle/wrapper
./gradle/wrapper/gradle-wrapper.jar
./gradle/wrapper/gradle-wrapper.properties
./gradle.properties
./gradlew
./gradlew.bat
./no
./no/build.gradle
./settings.gradle

maven-test $ cat settings.gradle
rootProject.name = 'maven-test'
include ':a'
include ':b'
include ':c'
include ':no'

maven-test $ cat build.gradle
subprojects {
    apply plugin: 'java'

    if (it != project(':no')) {
        println 'applying maven for ' + it
        apply plugin: 'maven'

        uploadArchives {
            repositories {
                mavenDeployer {
                    repository(url: "file://build")
                }
            }
        }
    } else {
        println 'not applying maven for ' + it
    }

    defaultTasks = ['clean', 'build']

    afterEvaluate { project ->
        println("================ $project.path tasks:")
        project.tasks.each { task ->
            println("    $task.name")
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.14.1'
}

maven-test $ cat no/build.gradle
jar.enabled = false

即。 no/build.gradle文件禁用jar任务(因为没有什么可以jar)。主build.gradle文件配置javamaven插件,但maven模块中明确省略了no插件。此外,还添加了一些调试输出以查看正在发生的事情。

这是输出(有点健谈,我希望它是好的):

maven-test $ ./gradlew clean uploadArchives
applying maven for project ':a'
applying maven for project ':b'
applying maven for project ':c'
not applying maven for project ':no'
================ :a tasks:
    assemble
    build
    buildDependents
    buildNeeded
    check
    classes
    clean
    compileJava
    compileTestJava
    install
    jar
    javadoc
    processResources
    processTestResources
    test
    testClasses
    uploadArchives
================ :b tasks:
    assemble
    build
    buildDependents
    buildNeeded
    check
    classes
    clean
    compileJava
    compileTestJava
    install
    jar
    javadoc
    processResources
    processTestResources
    test
    testClasses
    uploadArchives
================ :c tasks:
    assemble
    build
    buildDependents
    buildNeeded
    check
    classes
    clean
    compileJava
    compileTestJava
    install
    jar
    javadoc
    processResources
    processTestResources
    test
    testClasses
    uploadArchives
================ :no tasks:
    assemble
    build
    buildDependents
    buildNeeded
    check
    classes
    clean
    compileJava
    compileTestJava
    jar
    javadoc
    processResources
    processTestResources
    test
    testClasses
:a:clean
:b:clean
:c:clean
:no:clean
:a:compileJava UP-TO-DATE
:a:processResources UP-TO-DATE
:a:classes UP-TO-DATE
:a:jar
:a:uploadArchives
:b:compileJava UP-TO-DATE
:b:processResources UP-TO-DATE
:b:classes UP-TO-DATE
:b:jar
:b:uploadArchives
:c:compileJava UP-TO-DATE
:c:processResources UP-TO-DATE
:c:classes UP-TO-DATE
:c:jar
:c:uploadArchives
:no:compileJava UP-TO-DATE
:no:processResources UP-TO-DATE
:no:classes UP-TO-DATE
:no:jar SKIPPED
:no:uploadArchives FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':no:uploadArchives'.
> Could not publish configuration 'archives'
   > Cannot publish artifact 'no.jar (com.test:no:0.1.0-SNAPSHOT)' (/Users/wujek/Development/IdeaProjects/maven-test/no/build/libs/no-0.1.0-SNAPSHOT.jar) as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.145 secs

有趣的是:输出表明没有为maven模块(no)配置not applying maven for project :no插件,uploadArchives任务未列出{ {1}}模块,但在Gradle输出中仍然表示此任务被调用且失败。我也可以直接使用:no来调用这个“幻像”任务,它会以同样的方式失败,而不是告诉我任务丢失。

我的配置有什么问题?

0 个答案:

没有答案