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

Add the ability to rename annotations added by the Scala compiler. #756

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shawjef3
Copy link

This is for #146. I haven't tested the new functionality, but existing tests pass.

@shawjef3
Copy link
Author

@johnrengelman The build failed due to a temporary godaddy failure. Please retrigger the build.

@johnrengelman
Copy link
Collaborator

Can you merge master to this. There’s a fix there.

@shawjef3
Copy link
Author

@johnrengelman it passed. Thanks!

@shawjef3
Copy link
Author

shawjef3 commented Feb 17, 2022

@johnrengelman I'm wondering if you've run into this. I want to use this patch with a project I have locally. I publish it.

./gradlew :publishPluginPublicationToMavenLocal

In my project I use pluginManagement in settings.gradle to have Gradle use my local published snapshot instead of the official Shadow publication. Then I run :shadowJar on my project. I get,

> Failed to apply plugin [class 'com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin']
   > Could not create plugin of type 'ShadowJavaPlugin'.
      > The constructor for type ShadowJavaPlugin should be annotated with @Inject.

I looked at the class in the jar in my local repo, and it does have the annotation. However, when I debug Gradle's InjectUtil, the annotation is missing from the constructor. It's like Gradle's class loader is stripping it.

@shawjef3
Copy link
Author

I also asked for help in the Gradle Slack.

@shawjef3
Copy link
Author

I was able to use ((GeneratedClassImpl) type).generatedClass.getConstructors()[0].getAnnotations() to find that the actual annotation on the constructor is @shadow.javax.inject.Inject(). So it seems the publication is shadowing annotations.

@shawjef3
Copy link
Author

I figured out what's happening. Something about my patch makes annotation classes be shaded also. This could be desirable but in this case it's not. I'll figure out how to make it only shade that Scala annotations.

@Goooler Goooler deleted the branch GradleUp:main July 28, 2024 13:54
@Goooler Goooler closed this Jul 28, 2024
@Goooler Goooler reopened this Jul 28, 2024
@Goooler Goooler changed the base branch from master to main July 28, 2024 14:09
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

Successfully merging this pull request may close these issues.

3 participants