简体   繁体   English

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

[英]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'我们有一个使用“jrs-rest-java-client”的项目,版本:“6.3.1”

The site we used to get the jar from has a certificate issue since September.我们用来获取 jar 的站点自 9 月以来就出现了证书问题。 https://jaspersoft.artifactoryonline.com https://jaspersoft.artifactoryonline.com

We then had to get the jar from a different site.然后我们不得不从另一个站点获取 jar。 https://jaspersoft.jfrog.io/ 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.问题是缺少依赖要求,但如果我们使用具有“-jar-with-dependencies”的 jar,它就可以工作。 I tried by downloading that jar locally and changing the.gradle to use the local version.我尝试在本地下载 jar 并将.gradle 更改为使用本地版本。

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?我们如何指定使用什么 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")
}

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.如果使用 jrs-rest-java-client-6.3.1-jar-with-dependencies.jar,则不需要该库。

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:jfrog repo中,它向您展示了如何执行此操作:

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

Add the repo for gradle:添加 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:我建议compile切换到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.教他如何钓鱼,你养他一辈子。

I decided to record a short clip of how I found the appropriate repositories for the artifacts you needed, on jfrog:我决定在 jfrog 上记录我如何为您需要的工件找到合适的存储库的短片:

在此处输入图像描述

First of all you need to add the repository in build.gradle file.首先,您需要在 build.gradle 文件中添加存储库。 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".有关更多详细信息,请参阅 go 到以下链接并单击链接“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.默认情况下,它提供 Maven,您只需复制 url 并粘贴到 build.gradle 的存储库部分。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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