Andre Couture
Andre Couture

Reputation: 107

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"

Upvotes: 0

Views: 649

Answers (1)

smac89
smac89

Reputation: 43068

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:

enter image description here

Upvotes: 3

Related Questions