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

Integration with maven-publish hard to use #611

Open
autonomousapps opened this issue Nov 5, 2020 · 4 comments
Open

Integration with maven-publish hard to use #611

autonomousapps opened this issue Nov 5, 2020 · 4 comments

Comments

@autonomousapps
Copy link

Please check the User Guide before submitting "how do I do 'x'?" questions!

Shadow Version

6.1.0

Gradle Version

6.7

Expected Behavior

This issue is filed per this comment.

Given a multi-module project, where A depends on B, and where B uses this shadow plugin to bundle some external dependencies (in this case, antlr),

  1. A and B can be published to external repos and consumed by other projects in the normal way
  2. This multi-module project can be viewed as normal in the IDE (no "unresolved references").

Actual Behavior

It seems that 1 might already be fine, but I have only published to maven-local as a proof of concept so far. The issue I'm having is with 2. I have several "unresolved references" in IDEA that were previously resolvable. These references are to classes that were relocated in B. In the past, I simply built the B jar and included it directly in A (with implementation(files("libs/antlr-$internalAntlrVersion.jar")) and jar.from(zipTree("libs/antlr-$internalAntlrVersion.jar"))), and my IDE had no trouble with this. Now I'm using implementation(project(path = ":antlr", configuration = "shadow")) and several relocated classes are red in the IDE.

My best guess right now is that IDEA doesn't really understand configuration = "shadow", but without that project A depended on the unrelocated jar and compilation from the command line failed.

Gradle Build Script(s)

You can find the code at https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/tree/pub-antlr. (the pub-antlr branch). The most relevant files are:

  1. ./build.gradle.kts
  2. antlr/build.gradle.kts
  3. buildSrc/src/main/kotlin/plugin-publishing.gradle.kts

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

https://gist.github.com/autonomousapps/fc5aff10403b5a07f34391fcfd88945d

Additional context

Project A is the root project and publishes a gradle plugin. Project B is a normal Java/Kotlin project that uses antlr to create and publish a custom grammar.

@autonomousapps
Copy link
Author

autonomousapps commented Nov 5, 2020

An example of inability to resolve symbols (in com.autonomousapps.tasks.ImportFinderTask):

Screen Shot 2020-11-05 at 11 23 07 AM

I tried the old "invalidate caches & restart" trick, but it still can't find these symbols.

@autonomousapps
Copy link
Author

autonomousapps commented Nov 5, 2020

Possibly relates to https://youtrack.jetbrains.com/issue/IDEA-163411 and also seems like a reprisal of #264

@autonomousapps
Copy link
Author

Was just looking at this again and saw this in changelog.

NEW: Support for Gradle Metadata publication via the shadowRuntimeElements configuration. This is a beta feature the hasn't been tested extensively. Feedback is appreciated.

Could you reply with a quick snippet on how I'd use that configuration?

@autonomousapps
Copy link
Author

Ah, this actually works: from(components["java"])

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

1 participant