Vertispan / j2clmavenplugin

Maven plugin to launch new J2CL compilation
https://vertispan.github.io/j2clmavenplugin/
Apache License 2.0
53 stars 26 forks source link

ignore-maven-apt-test-annotations #169

Closed orielmaute closed 2 years ago

orielmaute commented 2 years ago

Fix to ignore maven apt generated files with scope test (directory generated-test-sources/test-annotations)

orielmaute commented 2 years ago

@niloc132: Testcase added plus small changes. Please check out if the changes are as you requested.

One thing: it would be great if the project could use an automatic syntax formatter (e.g. fmt-maven - i had to do my changes twice, because my ide automatically formats with google code style an thus the formatting was broken - complete file shown has been shown as changed.

niloc132 commented 2 years ago

One thing: it would be great if the project could use an automatic syntax formatter (e.g. fmt-maven - i had to do my changes twice, because my ide automatically formats with google code style an thus the formatting was broken - complete file shown has been shown as changed.

If we have a suitably flexible formatter (i'm not too picky, but would rather it not rewrite everything on the way), we'll take it. Formatting the generated code might be weird, I'm not sure. The main thing I dislike about codeformatters is when they decide that my "put each method of a stream chain on a new line" is wasting newlines and makes them less readable by removing some of those lines.

orielmaute commented 2 years ago

@niloc132 the filter now also runs in AbstractBuildMojo#buildProject - but I have doubts if this is what you want..

Yes, a formatter has a lot of pros but also a lot of cons. Long time i was also no friend of code formatters, but in my team there were people using their own formatter, so on each commit it was difficult to see what really changed. Formatting code on each build solved this issue (also the discussions how code should be formatted...). But yes you are right, that the formatted code is sometimes hard to read (specially when using complex dsl). But based on your comment i think its better to leave everything as is.

niloc132 commented 2 years ago

Running in buildProject seems like overkill, but it will have no real effect unless someone deliberately names their source dir to match this pattern. This is hacky anyway, but I'm good with the very very low odds of someone doing that on purpose.

I would mildly prefer a formater that leaves readable code in my IDE than one that makes diffs easier to read (I mean both is good, but I do far more work in the IDE than in diffs). I agree that a formater would be a good idea. If you propose something I will try to overlook anything that won't actively harm comprehension. Want to start an issue on this, maybe propose a quick-and-dirty-and-opinionated PR to try this outside of this PR?

niloc132 commented 2 years ago
[ERROR] Failed to execute goal com.vertispan.j2cl:j2cl-maven-plugin:0.20-SNAPSHOT:test (test-js-with-assertions-true) on project java-assertions: Failed to run tests: /home/runner/work/j2clmavenplugin/j2clmavenplugin/j2cl-maven-plugin/target/it-tests/java-assertions/target/java-assertions-1.0-assertions-true/j2clsample/tests/MyTest.testsuite -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vertispan.j2cl:j2cl-maven-plugin:0.20-SNAPSHOT:test (test-js-with-assertions-true) on project java-assertions: Failed to run tests
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:306)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to run tests
    at com.vertispan.j2cl.mojo.TestMojo.execute (TestMojo.java:495)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.NoSuchFileException: /home/runner/work/j2clmavenplugin/j2clmavenplugin/j2cl-maven-plugin/target/it-tests/java-assertions/target/java-assertions-1.0-assertions-true/j2clsample/tests/MyTest.testsuite
    at sun.nio.fs.UnixException.translateToIOException (UnixException.java:92)
    at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:111)
    at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:116)
    at sun.nio.fs.UnixCopyFile.copy (UnixCopyFile.java:548)
    at sun.nio.fs.UnixFileSystemProvider.copy (UnixFileSystemProvider.java:258)
    at java.nio.file.Files.copy (Files.java:1295)
    at com.vertispan.j2cl.mojo.TestMojo.execute (TestMojo.java:372)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

This error is probably not caused by this, re-running to be sure. Not really seeing how this could happen as a race (..unless we're having gha disk issues? wouldnt be the first time I've seen crazy disk issues), need to keep an eye on this.