jbosstools / m2e-apt

Maven integration with Eclipse JDT Annotation Processor Toolkit
39 stars 19 forks source link

Make WTP editor optional #80

Closed fbricon closed 2 years ago

fbricon commented 2 years ago

Fixes #79

fbricon commented 2 years ago

TL;DR: Current status: (╯°□°)╯︵ ┻━┻

Currently, tests fail running in Eclipse, as the build is locked waiting for AUTO_BUILD to finish:

"main" #1 prio=6 os_prio=31 cpu=10659.92ms elapsed=159.47s tid=0x00007fe8ea00c000 nid=0x103 in Object.wait()  [0x00007ff7b6058000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(java.base@17.0.1/Native Method)
    - waiting on <no object reference available>
    at org.eclipse.core.internal.jobs.JobManager.join(JobManager.java:1032)
    - locked <0x00000006085bf600> (a java.util.Collections$SynchronizedSet)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager.removeFolder(GeneratedSourceFolderManager.java:508)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager.folderNamePreferenceChanged(GeneratedSourceFolderManager.java:321)
    at org.eclipse.jdt.apt.core.internal.AptProject.preferenceChanged(AptProject.java:81)
    at org.eclipse.jdt.apt.core.util.AptConfig.setString(AptConfig.java:969)
    at org.eclipse.jdt.apt.core.util.AptConfig.setGenSrcDir(AptConfig.java:917)
    at org.jboss.tools.maven.apt.internal.AbstractAptConfiguratorDelegate.configureProject(AbstractAptConfiguratorDelegate.java:172)
    at org.jboss.tools.maven.apt.internal.AbstractAptProjectConfigurator.configure(AbstractAptProjectConfigurator.java:99)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:124)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$2(ProjectConfigurationManager.java:515)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$$Lambda$792/0x0000000800afe270.call(Unknown Source)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:509)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProjects(ProjectConfigurationManager.java:298)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$0(ProjectConfigurationManager.java:178)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$$Lambda$766/0x0000000800a1b160.call(Unknown Source)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:103)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1416)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:148)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.lambda$2(AbstractMavenProjectTestCase.java:411)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase$$Lambda$765/0x0000000800a26c48.run(Unknown Source)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2338)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.importProjects(AbstractMavenProjectTestCase.java:409)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.importProject(AbstractMavenProjectTestCase.java:357)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.importProject(AbstractMavenProjectTestCase.java:343)
    at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.importProject(AbstractMavenProjectTestCase.java:331)
    at org.jboss.tools.maven.apt.tests.AbstractM2eAptProjectConfiguratorTestCase.defaultTest(AbstractM2eAptProjectConfiguratorTestCase.java:75)
    at org.jboss.tools.maven.apt.tests.AbstractM2eAptProjectConfiguratorTestCase.defaultTest(AbstractM2eAptProjectConfiguratorTestCase.java:71)
    at org.jboss.tools.maven.apt.tests.M2eAptProjectconfiguratorTest.testMavenPropertySupport1(M2eAptProjectconfiguratorTest.java:290)

This is caused by the latest changes in o.e.j.a.c.i.g.GeneratedSourceFolderManager

Disabling auto-build during tests will likely work, but I'm really concerned about what will happen during an actual autobuild, risking to freeze user's eclipse (although I haven't experienced it so far).

In a CLI build, the tests get stuck immediately at :

"main" #1 prio=5 os_prio=31 cpu=11114.12ms elapsed=74.73s tid=0x00007f89c7009000 nid=0x1b03 in Object.wait()  [0x0000700008869000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(java.base@11.0.11/Native Method)
    - waiting on <no object reference available>
    at java.lang.Object.wait(java.base@11.0.11/Object.java:328)
    at java.lang.ProcessImpl.waitFor(java.base@11.0.11/ProcessImpl.java:495)
    - waiting to re-lock in wait() <0x00000006273c03e0> (a java.lang.ProcessImpl)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.eclipse.sisu.equinox.launching.internal.DefaultEquinoxLauncher.execute(DefaultEquinoxLauncher.java:73)
    at org.eclipse.tycho.surefire.AbstractTestMojo.runTest(AbstractTestMojo.java:1038)
    at org.eclipse.tycho.surefire.AbstractTestMojo.execute(AbstractTestMojo.java:688)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    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:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    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:972)
    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(java.base@11.0.11/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.11/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.11/DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(java.base@11.0.11/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)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.11/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.11/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.11/DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(java.base@11.0.11/Method.java:566)
    at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
    at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
    at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:61)

which is a completely different issue apparently.

@snjeza @rgrunber, any ideas?

snjeza commented 2 years ago

Related issue - https://github.com/redhat-developer/vscode-java/issues/2020#issuecomment-880837330 @fbricon You can try the following patch:

diff --git a/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java b/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java
index 107078a..13a3424 100644
--- a/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java
+++ b/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;

+import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -24,11 +25,17 @@ import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
 import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
 import org.eclipse.jdt.apt.core.util.AptConfig;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.core.project.IProjectCreationListener;
+import org.eclipse.m2e.core.project.ResolverConfiguration;
 import org.eclipse.osgi.util.NLS;
 import org.jboss.tools.maven.apt.MavenJdtAptPlugin;
 import org.jboss.tools.maven.apt.internal.Messages;
@@ -459,4 +466,15 @@ public class M2eAptProjectconfiguratorTest extends AbstractM2eAptProjectConfigur
            }
        }
    }
+
+   @Override
+   protected IProject[] importProjects(String basedir, String[] pomNames, ResolverConfiguration configuration,
+             boolean skipSanityCheck, IProjectCreationListener listener) throws IOException, CoreException {
+       try {
+           Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, monitor);
+       } catch (OperationCanceledException | InterruptedException e) {
+           // ignore
+       }
+       return super.importProjects(basedir, pomNames, configuration, skipSanityCheck, listener);
+   }
 }
fbricon commented 2 years ago

@snjeza thanks, that worked