Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.2.26引入的变更导致下游项目编译失败 #490

Open
wsy opened this issue Aug 21, 2020 · 11 comments
Open

7.2.26引入的变更导致下游项目编译失败 #490

wsy opened this issue Aug 21, 2020 · 11 comments
Labels
to-be-confirmed Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@wsy
Copy link

wsy commented Aug 21, 2020

gradle implementation [ci skip]
这个commit把相关依赖由compile改为implementation。下游项目在构建的时候会有Maven编译错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project projectName: Compilation failure
[ERROR] /somepath/SomeClass.java:[49,43] 无法访问com.google.gson.JsonElement
[ERROR] 找不到com.google.gson.JsonElement的类文件

我们的项目仅仅用了你们的com.qiniu.util.Json,并没有直接依赖Gson库,所以我们不该添加Gson的依赖项。
Gson的依赖是你们引入的,所以是否你们该把implementation改为api?

@peteryuanpan
Copy link
Contributor

您好,这边已经收到您的问题,工作日会核实确认一下,给您个答复

@wsy
Copy link
Author

wsy commented Aug 25, 2020

有进展么?

@forrest-mao forrest-mao added the to-be-confirmed Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 25, 2020
@peteryuanpan
Copy link
Contributor

peteryuanpan commented Aug 25, 2020

您好,我们这边尝试复现了下
环境:macos,InteillJIDEA
build.gradle

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.qiniu:qiniu-java-sdk:7.2.26'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

test.TEST1.java

package test;

import com.qiniu.util.Json;

public class TEST1 {

    public static void main(String[] args) {
        System.out.println(Json.encode("just test"));
    }

}

运行结果是ok的,且IDEA会自动依赖com.google.code.gson:gson:2.8.5
image

【我们的项目仅仅用了你们的com.qiniu.util.Json,并没有直接依赖Gson库,所以我们不该添加Gson的依赖项。】
我这边清楚gradle3.0.0之后,关于implementation与api的区别
这边改为api后可能产生的风险我们要评估一下,以及其他用户的使用习惯等
你们是否方便先也依赖一下gson库来解决之?

@wsy
Copy link
Author

wsy commented Aug 25, 2020

我们这边用的是Maven。
你们的SDK,Gradle的dependency,“implementation”的依赖,在生成的pom里,dependency是"runtime"
比如Maven上你们jar包附带的pom里是这样的

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.5</version>
      <scope>runtime</scope>
    </dependency>

我的基于Maven的项目,无论在Idea里还是命令行,“maven compile”命令都是失败的。
image

所有这个有没有可能是Gradle的implementation跟Maven有兼容问题?

@peteryuanpan
Copy link
Contributor

您好,您项目中External Libraries能否给个截图,我看下是长什么样子的

我这边是如下
image

@wsy
Copy link
Author

wsy commented Aug 26, 2020

我创建了一个DemoProject
DemoProject.zip

MavenView

ProjectView

IdeaMavenCompile

image

@wsy
Copy link
Author

wsy commented Aug 26, 2020

Demo项目从Java14改了Java1.8也一样。

@peteryuanpan
Copy link
Contributor

您好,这边为您核实下,有结果后给您答复

@wsy
Copy link
Author

wsy commented Aug 27, 2020

@peteryuanpan
Copy link
Contributor

您好,请问问题解决了吗?您试一下7.3.0版本是否有此问题

@wsy
Copy link
Author

wsy commented Nov 26, 2020

试了一下,Maven项目无论是7.3.0还是7.4.0都编译不过。提示找不到 com.google.gson.JsonElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-be-confirmed Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants