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

Micronaut 4 Groovy projects fail Intellij compilation #9925

Draft
wants to merge 1 commit into
base: 4.1.x
Choose a base branch
from

Conversation

timyates
Copy link
Member

Something in this PR has broken compilation with Groovyc and inject-groovy.

#9232

when d273fda is reverted then this test passes.

I am not sure why

@timyates
Copy link
Member Author

From @paulk-asert

It probably isn't the usual case of two places using ClassHelper.make when a cached version is needed but rather one being a primary classnode (since we are compiling it)

@dstepanov
Copy link
Contributor

Your test is failing becase the class is not found.
Please try your use case with resolveName changed to findClassNode. Otherwise this needs to be addressed with the Groovy team. All this is added so we can properly get the default annotation values (GroovyMappedStereotypesSpec).

@dstepanov
Copy link
Contributor

So I looked a bit more, and I see a few issues:

  • @timyates The test should have FileSystemCompiler.commandLineCompile(testDirectory.resolve("src/main/java/Usage.groovy").toString(), testDirectory.resolve("src/main/java/Annotation.groovy").toString())
  • It looks like our code have added that resolution, because it's not possible to retrive the annotation default values from the ordinary ClassNode but it works with DecompiledClassNode
  • The problem is in ClassNodeResolver#tryAsScript which calls CompilationUnit#addSource:
public SourceUnit addSource(final SourceUnit source) {
        String name = source.getName();
        source.setClassLoader(getClassLoader());
        for (SourceUnit su : queuedSources) {
            if (name.equals(su.getName())) return su;
        }
        queuedSources.add(source);
        return source;
    }

That one is not checking if the source is already in sources field.

@sdelamo sdelamo modified the milestones: 4.2.0, 4.3.0 Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Micronaut 4 Groovy projects fail Intellij compilation
3 participants