0

我在使用 Gradle 的 Cargo 插件部署 Java 应用程序时遇到了一些问题。

我尝试将 commons-discovery 和 commons-logging 添加为依赖项,但效果不佳。

:build
:copyWarToTomcat
:removeSymLinks
:removeExplodedWar UP-TO-DATE
:cargoRunLocal FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cargoRunLocal'.
> Could not create type cargo due to java.lang.NoClassDefFoundError: org/apache/commons/discovery/resource/ClassLoaders

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cargoRunLocal'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)

BUILD FAILED

这是我的 build.gradle 中的货物依赖项:

dependencies {
    classpath 'com.bmuschko:gradle-cargo-plugin:2.1.1'
}

这是我添加 Cargo 配置的 localDeploy.gradle:

apply plugin: 'com.bmuschko.cargo'

cargo {
    containerId = 'tomcat7x'

    local {
        installer {
            installUrl = 'https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.67/bin/apache-tomcat-7.0.67.zip'
            downloadDir = file("$buildDir/download")
            extractDir = file("$buildDir/extract")
        }
    }
}
4

2 回答 2

0

似乎常见的发现 jar 文件没有正确加载。

我猜你应该启用org.gradle.debug=truegradle.properties尝试调试它 - 当设置为 true 时,Gradle 将在启用远程调试的情况下运行构建,侦听端口 5005。请注意,这相当于添加 -Xrunjdwp:transport=dt_socket,server=y, suspend=y,address=5005 到 JVM 命令行,并将挂起虚拟机,直到附加调试器。

于 2016-01-28T14:12:02.650 回答
0

如果您有以下内容,请确保依赖项是可传递的,然后使其更具体

configurations.all {
    transitive = false
}

例子

configurations.compile {
    transitive = false
}

这样 gradle 将下载 cargo 的所有依赖项

于 2016-11-01T11:12:12.443 回答