IntelliJ下载库jar文件的源错误

huangapple go评论76阅读模式
英文:

IntelliJ download source of a library jar error

问题

我使用Gradle 6.2.2,JFrog Artifactory OSS,IntelliJ IDEA Ultimate 2020.1。
我将构件发布到Artifactory,一切都正常工作。我还希望开发人员在调试项目时可以下载源代码(而不是反编译),并跟踪代码。

我检查了JFrog Artifactory,一切看起来都没问题。在1.2.3-SNAPSHOT/目录下,我看到了以下内容:

maven-metadata.xml
foobar-1.2.3-SNAPSHOT-src.jar
foobar-1.2.3-SNAPSHOT.jar
foobar-1.2.3-SNAPSHOT.module
foobar-1.2.3-SNAPSHOT.pom

build.gradle代码片段:

task sourceJar(type: Jar) {
  classifier 'src'
  from sourceSets.main.allJava
}

publishing {
  publications {
    mavenJava(MavenPublication) {
        from components.java
        artifact tasks.sourceJar
    }
  }
}

我尝试在IntelliJ中下载foobar.jar中的类的源代码
IntelliJ下载库jar文件的源错误

IntelliJ 报错:

11:46:03 PM: 执行任务 'DownloadSources'...

Task :DownloadSources 失败

1 个可执行任务: 1 已执行

失败: 构建失败。

  • Where:
    Initialization script 'C:\Users\xxxx\AppData\Local\Temp\1\ijmiscinit5.gradle' 行: 20

  • What went wrong:
    Execution failed for task ':DownloadSources'.
    Could not resolve all files for configuration ':downloadSources_4a831a47-2d8a-44e0-b835-8ff80c6fbcc8'.
    Could not find com.example:foobar:1.2.3-SNAPSHOT.
    Required by:
    project :

英文:

I use gradle 6.2.2, JFrog Artifactory OSS, IntelliJ IDEA Ultimate 2020.1
I publish artifact to the Artifactory, everything works alright. I also want when developers debug the project can download the source (not decompiler), and trace into the code.

I checked JFrog Artifactory, things look OK. under 1.2.3-SNAPSHOT/ I see

maven-metadata.xml
foobar-1.2.3-SNAPSHOT-src.jar
foobar-1.2.3-SNAPSHOT.jar
foobar-1.2.3-SNAPSHOT.module
foobar-1.2.3-SNAPSHOT.pom

build.gradle snippet

task sourceJar(type: Jar) {
  classifier 'src'
  from sourceSets.main.allJava
}

publishing {
  publications {
    mavenJava(MavenPublication) {
        from components.java
        artifact tasks.sourceJar
    }
  }
}

I tried to download the source code of a class in foobar.jar in IntelliJ
IntelliJ下载库jar文件的源错误

IntelliJ complains:

11:46:03 PM: Executing task 'DownloadSources'...

Task :DownloadSources FAILED

1 actionable task: 1 executed

FAILURE: Build failed with an exception.

  • Where:
    Initialization script 'C:\Users\xxxx\AppData\Local\Temp\1\ijmiscinit5.gradle' line: 20

  • What went wrong:
    Execution failed for task ':DownloadSources'.
    Could not resolve all files for configuration ':downloadSources_4a831a47-2d8a-44e0-b835-8ff80c6fbcc8'.
    Could not find com.example:foobar:1.2.3-SNAPSHOT.
    Required by:
    project :

答案1

得分: 2

classifier should be sources - but you can below snippet to remove hand writing

see https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example

java {
withJavadocJar()
withSourcesJar()
}

英文:

classifier should be sources - but you can below snippet to remove hand writing

see https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example

java {
    withJavadocJar()
    withSourcesJar()
}

huangapple
  • 本文由 发表于 2020年8月2日 15:38:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/63213551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定