简体   繁体   English

Gradle依赖性未列出本地Maven Jar的依赖性

[英]Gradle dependencies not listing dependencies of local maven jar

I'm developing an IntelliJ plugin using the Gradle build system. 我正在使用Gradle构建系统开发IntelliJ插件。 This plugin uses a common model which is a maven project. 该插件使用一个通用模型,这是一个Maven项目。

I've included mavenLocal in my gradle repositories and also added the compile-time dependency in 'dependencies'. 我已经在我的gradle存储库中包含了mavenLocal,并且还在“ dependencies”中添加了编译时依赖。

The code is compiling fine but I'm getting java.lang.NoClassDefFoundError in runtime. 代码可以正常编译,但是在运行时出现java.lang.NoClassDefFoundError。 When I checked the dependencies in gradle it is not listing all dependencies for local maven jar(model library). 当我在gradle中检查依赖项时,它没有列出本地maven jar(模型库)的所有依赖项。

Below is a stripped version of my build.gradle 下面是我的build.gradle的剥离版本

plugins {
    id 'java'
    id 'org.jetbrains.intellij' version '0.4.1'
    id 'maven'
}
group 'oracle.nosql'

repositories {
    //mavenCentral()
    mavenLocal()
}
dependencies {
    compile 'oracle.nosql:oracle.nosql.model.common:1.0.0' //this is maven lib
    compile 'oracle.nosql:oracle.nosql.model.cloud:1.0.0' //this is maven lib
}
apply plugin: 'maven'

Below is the output of gradle dependencies 以下是gradle dependencies的输出

compileClasspath - Compile classpath for source set 'main'.M
+--- oracle.nosql:oracle.nosql.model.common:1.0.0M
+--- oracle.nosql:oracle.nosql.model.cloud:1.0.0M
|    \--- com.fasterxml.jackson.core:jackson-databind:2.9.7M
|         +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0M
|         \--- com.fasterxml.jackson.core:jackson-core:2.9.7M
\--- com.jetbrains:ideaIC:2018.3.2M

But in maven for model dependency is different. 但是在Maven中对模型的依赖是不同的。

    mvn dependency:build-classpath

    oracle.nosql.model.cloud ---
    [INFO] Dependencies classpath:
    ...\.m2\repository\oracle\nosql\oracle.nosql.model.common\1.0.0\oracle.nosql.model.common-1.0.0.jar;
D:\oracle-nosql-cloud-sdk-18.298\java\lib\nosqldriver.jar;
...\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.7\jackson-databind-2.9.7.jar;...\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;...\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.7\jackson-core-2.9.7.jar;...\.m2\repository\junit\junit\4.12\junit-4.12.jar;

In particular D:\\oracle-nosql-cloud-sdk-18.298\\java\\lib\\nosqldriver.jar is missing from gradle dependency. 特别是gradle依赖项缺少D:\\oracle-nosql-cloud-sdk-18.298\\java\\lib\\nosqldriver.jar

I think this is causing java.lang.NoClassDefFoundError. 我认为这是导致java.lang.NoClassDefFoundError的原因。

Given the absolute path of D:\\oracle-nosql-cloud-sdk-18.298\\java\\lib\\nosqldriver.jar , I will assume you have a system dependency declared in your Maven library. 给定D:\\oracle-nosql-cloud-sdk-18.298\\java\\lib\\nosqldriver.jar的绝对路径,我将假定您在Maven库中声明了system依赖项。

These dependencies are not included by Gradle for the compileClasspath or runtimeClasspath resolution. Gradle不为compileClasspathruntimeClasspath解析提供这些依赖项。

You will have to add back this dependency as a file dependency in your Gradle build. 您将不得不在Gradle构建中将此依赖项重新添加为文件依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM