简体   繁体   中英

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

We have a project that make use of 'jrs-rest-java-client', version: '6.3.1'

The site we used to get the jar from has a certificate issue since September. https://jaspersoft.artifactoryonline.com

We then had to get the jar from a different site. https://jaspersoft.jfrog.io/

The problem is that a dependency require is missing, but if we use the jar that has "-jar-with-dependencies" it is working. I tried by downloading that jar locally and changing the.gradle to use the local version.

What I would prefer is to have the build to fetch that version directly without having to download first.

How do we specify what jar to use?

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

I have now tried as suggested;

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

I'm still getting errors at build time...

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

That library is not required if the jrs-rest-java-client-6.3.1-jar-with-dependencies.jar is used.

Thanks all,

The solution was, as seen if the video (Thanks:) adding a new url:

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

From the jfrog repo , it shows you how to do this:

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

Add the repo for gradle:

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

I'd recommend switching from compile to implementation and using a shorthand to declare the dependency:

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.

I decided to record a short clip of how I found the appropriate repositories for the artifacts you needed, on jfrog:

在此处输入图像描述

First of all you need to add the repository in build.gradle file. Add the following repository.

repositories {
        mavenCentral()
        maven {
            url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
        }
    }

For more details, go to the following link and click on the link "jaspersoft-clients-releases". Scroll down little bit, you will be able to see the repository to add. By default it provides for Maven, you need to copy only the url and paste in the repositories section of build.gradle.

https://jaspersoft.jfrog.io/jaspersoft/webapp/#/home

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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