Gradle 在编译任务中使用 jar-with-dependencies

Gradle to use a jar-with-dependencies in compile task

我们有一个项目使用 '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:

 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"
    }
}

我建议 并使用 shorthand 声明依赖关系:

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 上录制一个简短的片段,说明我如何为您需要的工件找到合适的存储库: