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

Not compatible with Gradle 7.0 #493

Closed
pan3793 opened this issue May 5, 2021 · 7 comments
Closed

Not compatible with Gradle 7.0 #493

pan3793 opened this issue May 5, 2021 · 7 comments

Comments

@pan3793
Copy link

pan3793 commented May 5, 2021

protobuf_plugin_version=0.8.16

Build passed with gradle 6.8.3 but failed with gradle 7.0

Run ./gradlew clean build --warning-mode all with gradle 6.8.3.

> Task :xenon-third-party:spark-clickhouse-connector:jar
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "com/zy/dp/xenon/protocol/grpc/ExternalTable$SettingsDefaultEntryHolder.class". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths. Consult the upgrading guide for further information: https://docs.gradle.org/6.8.3/userguide/upgrading_version_5.html#implicit_duplicate_strategy_for_copy_or_archive_tasks_has_been_deprecated
@voidzcy
Copy link
Collaborator

voidzcy commented May 5, 2021

> Task :xenon-third-party:spark-clickhouse-connector:jar

It happens in the jar task, doesn't seem to be caused by this plugin. #487 should have added the needed DuplicatesStrategy for the usage by this plugin.

@pan3793
Copy link
Author

pan3793 commented May 5, 2021

Thanks for reply, let me add more contexts.

I add the generated dirs to sourceSets because they didn't recognized by IDEA if don't do it. Even I saw #477 declared it solved the problem but seems not works for me.

sourceSets.main.scala {
    srcDirs += file("${project.buildDir}/generated/source/proto/main/grpc")
    srcDirs += file("${project.buildDir}/generated/source/proto/main/java")
}

If I remove this workaround, it works happy with both gradle 6.8 and 7.0 (but IDEA can't see the generated codes)
With this workaround, IDEA works fun, but only compile passed with gradle 6.8 not 7.0.

Any suggestions?

@voidzcy
Copy link
Collaborator

voidzcy commented May 5, 2021

I might get some sense for what's happening there, after seeing you are actually compiling Scala with the generated code.

As far as I know the scala plugin is based on the java plugin and compileScala task calls compileJava. The protobuf plugin adds the generated Java code to the input of compileJava while on the other hand you added them explicitly to the scala SourceDirectorySet in order to refresh the IDE being able to pick them up. So the jar task sees more than one copy of the generated code. Before Gradle 7.0, duplicates are handled silently well by Gradle. But Gradle 7.0 has a stricter requirement for explicitly configuring how duplicates should be handled. That's why you get the warning above.

Explicitly adding generated code to the source sets is really unnecessary, IDE should be able to pick up generated code. But that may not always work perfectly well, and possibly there are many other things come to play (e.g., IDEA cache, interacting with other plugins, etc). I've seen a couple of cases that sometimes the IDE works well while sometimes not. I am suspecting it has something to do with working with the antlr plugin, the two together can confuse the IDE.

@pan3793
Copy link
Author

pan3793 commented May 6, 2021

Explicitly adding generated code to the source sets is really unnecessary, IDE should be able to pick up generated code.

That's what I expected behaviors, but unfortunately, I'm struggling a few days but there are zero times IDE works as expected.

I am suspecting it has something to do with working with the antlr plugin, the two together can confuse the IDE.

I afraid I can't agree with that. I added the antlr plugin in to project just at yesterday, and suffered the issue already a few days before doing that. And antlr plugin always works well with IDEA, maybe there are somethings we can learn from antlr?

@voidzcy
Copy link
Collaborator

voidzcy commented May 6, 2021

I tried with gRPC-Java examples by adding some random Scala and antlr code. But it turns out everything just works fine.

Screen Shot 2021-05-06 at 1 34 04 AM

You can find my patch at https://github.com/voidzcy/grpc-java/pull/3/files.

This works for me.
https://github.com/yidongnan/grpc-spring-boot-starter/blob/f0302bd92e7950ce2995af03c1ec555ee1c1dc15/examples/grpc-lib/build.gradle#L49-L56

The same thing should have been done by the plugin and I've verified they are called on the IdealModule correctly. It might be possible that the IdealModule gets overwritten by some other plugins and configurations. I've seen people manually add configurations to explicitly set IdeaModule before, and it seems to work pretty well.

@pan3793
Copy link
Author

pan3793 commented May 6, 2021

I think I find what I am lost. The point is enable idea plugin as README said

This plugin integrates with the idea plugin and automatically registers the proto files and generated Java code as sources.

It's my mistake, because even without idea plugin, IDEA can auto pickup antlr generated code. So I didn't realize that idea plugin is necessary.

Really thanks for your time to help me dig it.

@pan3793 pan3793 closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants