【问题标题】:Gradle to use a jar-with-dependencies in compile taskGradle 在编译任务中使用 jar-with-dependencies
【发布时间】:2019-11-19 16:22:21
【问题描述】:

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

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

然后我们不得不从不同的站点获取罐子。 https://jaspersoft.jfrog.io/

问题是缺少依赖项,但如果我们使用具有“-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-dependencies.jar,则不需要该库。

谢谢大家,

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

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

【问题讨论】:

  • 如果我理解正确,您无法使用 gradle 下载 jrs-rest-java-client。我说的对吗?
  • @Sambit 你的 Maven 块是错误的。它应该只包含一个url。如果你想要多个声明多个,maven repos 每个都有自己的 url。
  • 我试过了,结果一样..
  • 为了清楚起见,当我使用 jrs-rest-java-client-6.3.1-jar-with-dependencies.jar 时,我没有收到您遇到的错误。必须有其他东西在请求该依赖项。
  • 可能是...其他子项目可能是...但现在可以了,因为我使用标准 jar 但包含正确的存储库并且它可以工作。谢谢

标签: java gradle compiler-errors build.gradle gradlew


【解决方案1】:

来自jfrog repo,它向您展示了如何做到这一点:

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

为 gradle 添加 repo:

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"

给一个人一条鱼,你可以喂他一天。教他钓鱼,你养他一辈子。

我决定在 jfrog 上录制一段关于我如何为您需要的工件找到合适存储库的短片:

【讨论】:

  • 仍然存在“找不到 com.jaspersoft.jasperserver:jasperserver-dto:6.3.0”的问题
  • @AndreCouture 查看我的编辑,了解如何为您想要的 jfrog 工件找到合适的存储库
猜你喜欢
  • 1970-01-01
  • 2012-01-31
  • 1970-01-01
  • 1970-01-01
  • 2020-08-02
  • 2011-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多