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

Change how the default class translation files path is constructed #106

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

Conversation

marko-bekhta
Copy link
Contributor

Hey @jamezp

with the most recent release of [plexus-compiler](https://github.com/codehaus-plexus/plexus-compiler) and in particular after this fix: codehaus-plexus/plexus-compiler#350 we've started to see build failures with:

[ERROR] Unknown source: Cannot read org.hibernate.search.util.impl.test.logging package files, cause : java.io.FileNotFoundException: Resource does not exist : CLASS_OUTPUT/org.hibernate.search.util.impl.test.logging/Log
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.BatchFilerImpl.getResource(BatchFilerImpl.java:173)
[ERROR] 	at org.jboss.logging.processor.apt.TranslationClassGenerator.findTranslationFiles(TranslationClassGenerator.java:152)
[ERROR] 	at org.jboss.logging.processor.apt.TranslationClassGenerator.processTypeElement(TranslationClassGenerator.java:115)
[ERROR] 	at org.jboss.logging.processor.apt.LoggingToolsProcessor.doProcess(LoggingToolsProcessor.java:213)
[ERROR] 	at org.jboss.logging.processor.apt.LoggingToolsProcessor.process(LoggingToolsProcessor.java:167)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:141)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:123)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:172)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:952)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:449)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:425)
[ERROR] 	at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:4753)
[ERROR] 	at org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl.call(EclipseCompilerImpl.java:101)
[ERROR] 	at org.eclipse.jdt.internal.compiler.tool.EclipseCompiler$1.call(EclipseCompiler.java:196)
[ERROR] 	at org.codehaus.plexus.compiler.eclipse.EclipseJavaCompiler.performCompile(EclipseJavaCompiler.java:309)
[ERROR] 	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1188)
[ERROR] 	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:212)
[ERROR] 	at com.gradle.maven.cache.extension.d.c.a(SourceFile:27)
[ERROR] 	at com.gradle.maven.cache.extension.d.n.a(SourceFile:23)
[ERROR] 	at com.gradle.maven.cache.extension.d.h.a(SourceFile:28)
[ERROR] 	at com.gradle.maven.cache.extension.d.m.a(SourceFile:27)
[ERROR] 	at com.gradle.maven.cache.extension.d.a.c(SourceFile:115)
[ERROR] 	at com.gradle.maven.cache.extension.d.a.a(SourceFile:61)
[ERROR] 	at com.gradle.maven.cache.extension.d.e.a(SourceFile:27)
[ERROR] 	at com.gradle.maven.cache.extension.d.l.a(SourceFile:17)
[ERROR] 	at com.gradle.maven.cache.extension.d.d.a(SourceFile:42)
[ERROR] 	at com.gradle.maven.cache.extension.d.b.a(SourceFile:26)
[ERROR] 	at com.gradle.maven.cache.extension.d.f$1.run(SourceFile:35)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(SourceFile:29)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(SourceFile:26)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(SourceFile:66)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(SourceFile:59)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(SourceFile:157)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(SourceFile:59)
[ERROR] 	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(SourceFile:47)
[ERROR] 	at com.gradle.maven.cache.extension.d.f.a(SourceFile:31)
[ERROR] 	at com.gradle.maven.cache.extension.d.k.a(SourceFile:76)
[ERROR] 	at com.gradle.maven.cache.extension.h.b.lambda$createProxy$0(SourceFile:79)
[ERROR] 	at jdk.proxy10/jdk.proxy10.$Proxy78.execute(Unknown Source)
[ERROR] 	at com.gradle.maven.scan.extension.internal.d.a.executeMojo(SourceFile:114)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
[ERROR] 	at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
[ERROR] 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
[ERROR] 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
[ERROR] 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:906)
[ERROR] 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:283)
[ERROR] 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:283)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:226)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:407)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR] 	at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:52)
[ERROR] 	at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:161)
[ERROR] 	at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:73)
[ERROR] 

e.g. https://ci.hibernate.org/blue/organizations/jenkins/hibernate-search/detail/main/1041/pipeline/121
Let me know if the change makes sense to you. Thanks!

@marko-bekhta marko-bekhta force-pushed the fix/change-translation-path-construction branch from 042cb46 to 753db13 Compare March 13, 2024 07:25
@marko-bekhta
Copy link
Contributor Author

Hi James, just a reminder about this one in case it got lost 🙈

@jamezp
Copy link
Member

jamezp commented Apr 2, 2024

My apologies @marko-bekhta. I'll try to look at it this week :)

@jamezp
Copy link
Member

jamezp commented Apr 25, 2024

I've filed https://issues.redhat.com/browse/LOGTOOL-158 for this. I will have a look at it tomorrow. I want to think about this. I need to refresh my memory a bit too :)

FileObject fObj = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, packageName, interfaceName);
classTranslationFilesPath = fObj.toUri().getPath().replace(interfaceName, "");
// Create some random name:
String relativeName = interfaceName + UUID.randomUUID();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's weird to me is the exception is java.io.FileNotFoundException, yet using a random file name makes it work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in the original approach, it was trying to get a resource (and eclipse compiler wants resources to actually exist) while this patch is just creating a new resource (so a potential problem could be that a file with that "random" name actually exists 🙈)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry getResource() vs createResource(). I should have noticed that.

@marko-bekhta
Copy link
Contributor Author

Hey James 😃
I've pushed one more commit that adds an eclipse compiler profile so it is easier to debug the problem. I've been using:

mvnDebug clean install -Pcompiler-eclipse

and attaching a remote debugger in an IDE.
I had to move out the exception classes out of the interfaces as otherwise using an eclipse compiler leads to:

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-testCompile) on project jboss-logging-processor: Compilation failure
[ERROR] Unknown source: java.lang.UnsupportedOperationException: Instantiating a Nested type CustomException of Reference of type ValidMessages as a class
[ERROR] 	at org.jboss.jdeparser.AbstractJType._new(AbstractJType.java:79)
[ERROR] 	at org.jboss.logging.processor.generator.model.ImplementationClassModel.constructReturnType(ImplementationClassModel.java:516)
[ERROR] 	at org.jboss.logging.processor.generator.model.ImplementationClassModel.createReturnType(ImplementationClassModel.java:409)
[ERROR] 	at org.jboss.logging.processor.generator.model.ImplementationClassModel.createBundleMethod(ImplementationClassModel.java:264)
[ERROR] 	at org.jboss.logging.processor.generator.model.MessageBundleImplementor.generateModel(MessageBundleImplementor.java:74)
[ERROR] 	at org.jboss.logging.processor.generator.model.ClassModel.generateAndWrite(ClassModel.java:126)
[ERROR] 	at org.jboss.logging.processor.apt.ImplementationClassGenerator.processTypeElement(ImplementationClassGenerator.java:58)
[ERROR] 	at org.jboss.logging.processor.apt.LoggingToolsProcessor.doProcess(LoggingToolsProcessor.java:213)
[ERROR] 	at org.jboss.logging.processor.apt.LoggingToolsProcessor.process(LoggingToolsProcessor.java:165)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:141)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:123)
[ERROR] 	at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:172)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:952)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:449)
[ERROR] 	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:425)
[ERROR] 	at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:4753)
[ERROR] 	at org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl.call(EclipseCompilerImpl.java:101)
[ERROR] 	at org.eclipse.jdt.internal.compiler.tool.EclipseCompiler$1.call(EclipseCompiler.java:196)
[ERROR] 	at org.codehaus.plexus.compiler.eclipse.EclipseJavaCompiler.performCompile(EclipseJavaCompiler.java:309)
[ERROR] 	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1140)
[ERROR] 	at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:199)
[ERROR] 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
[ERROR] 	at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
[ERROR] 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
[ERROR] 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
[ERROR] 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:906)
[ERROR] 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:283)
[ERROR] 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:283)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:226)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:407)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)

And I didn't want to dig into org.jboss.jdeparser and make it like eclipse compiler as well 😃.

We can drop this change once we are happy with the fix or however you'd like to proceed.

@jamezp
Copy link
Member

jamezp commented Jun 18, 2024

I've gotta be honest here, this seems like an awfully big change for a bug in a different project. I'm not sure I'd really want to put this fix in here when the fix should really be elsehwere.

@marko-bekhta
Copy link
Contributor Author

Just to be clear 🙈 only the first commit may be of use here (this part https://github.com/jboss-logging/jboss-logging-tools/pull/106/files#diff-aac55a253f897279072fe694e8d4b12f4444838b5d8c121257facd3382320fa1R154-R161). The second one is here temporarily, just in case you want to debug the behaviour of the Eclipse compiler. I agree that the error I've mentioned in the comment above (#106 (comment)) should be addressed either in org.jboss.jdeparser or in the Eclipse compiler itself.

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.

2 participants