java - Gradle 在编译任务中使用带有依赖项的 jar

标签 java gradle compiler-errors build.gradle gradlew

我们有一个使用“jrs-rest-java-client”的项目,版本:“6.3.1”

我们用来获取 jar 的网站自 9 月份以来就出现了证书问题。 https://jaspersoft.artifactoryonline.com

然后我们必须从另一个站点获取 jar 。 https://jaspersoft.jfrog.io/

问题是缺少依赖项 require,但如果我们使用具有“-jar-with-dependencies”的 jar,它就可以工作。我尝试在本地下载该 jar 并更改 .gradle 以使用本地版本。

我更喜欢的是让构建直接获取该版本,而无需先下载。

我们如何指定要使用的 jar?

dependencies {
compile fileTree(dir: 'lib',
    includes: [
        'ojdbc8.jar',
     ])
    //compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1'
    compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', USETHISONE: 'jar-with-dependencies'
    //compile files("${buildDir}/jrs-rest-java-client-6.3.1-jar-with-dependencies.jar")
}

我现在已按照建议进行尝试;

repositories {
    mavenCentral()
    // to handle broked jasper reports dependencies
    maven {
        url 'http://jasperreports.sourceforge.net/maven2'
        url 'https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/'
        url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
    }
}

dependencies {
    implementation project(':common:project-common-properties')
    implementation project(':common:project-common-mail')

    implementation fileTree(dir: 'lib', includes: [
        'ojdbc8.jar'
     ])
    implementation group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies'
}

我在构建时仍然遇到错误...

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':services:notificationService:compileClasspath'.
> Could not find com.jaspersoft.jasperserver:jasperserver-dto:6.3.0.
  Required by:
      project :services:notificationService > com.jaspersoft:jrs-rest-java-client:6.3.1

如果使用 jrs-rest-java-client-6.3.1-jar-with-dependency.jar,则不需要该库。

谢谢大家,

解决方案是,如视频所示(谢谢!) 添加新网址:

 url "https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases"

最佳答案

来自jfrog repo ,它向您展示了如何执行此操作:

compile(group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies')

添加 gradle 的存储库:

repositories {
    jcenter {
        name "jaspersoft-releases"
        url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
    }
}

我推荐switching from compile to implementation并使用简写来声明依赖项:

implementation "com.jaspersoft:jrs-rest-java-client:6.3.1:jar-with-dependencies"
<小时/>

Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for his life time.

我决定录制一个简短的剪辑,说明我如何在 jfrog 上找到适合您所需工件的存储库:

enter image description here

关于java - Gradle 在编译任务中使用带有依赖项的 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58938619/

相关文章:

java - 无法在 Firebase 上初始化类 FirebaseThreadManagers 错误

java - 字符串文字未正确用双引号括起来

c++ - 如何使用编译器 g++-8.2 编译 Hazelcast C++ 客户端

node.js - NodeJS CLD包外部依赖项

java - Maven Tycho 找不到我用 maven-bundle-plugin 创建的包

Java:平滑的颜色过渡

java - spring-boot gradle 插件搞乱了 ivy 依赖配置?

android - 测试运行失败 : Unable to find instrumentation info for: ComponentInfo{} -- error trying to test in IntelliJ with Gradle

gradle - 如何使用新的 Gradle SonarQube 插件向 Sonar 报告 Jacoco Groovy 代码覆盖率?

compilation - 安装MPFR(3.1.0)时出错