Bug 519237 - [Cocoa] mvn -Pbuild-individual-bundles fails on OSX due to missing -XstartOnFirstThread vm arg
Summary: [Cocoa] mvn -Pbuild-individual-bundles fails on OSX due to missing -XstartOn...
Status: CLOSED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Leo Ufimtsev CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2017-07-05 10:00 EDT by Leo Ufimtsev CLA
Modified: 2017-07-18 13:53 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2017-07-05 10:00:26 EDT
I'm in the process of setting up Linux/OSX/Windows automated maven test servers, to test SWT gerrit submissions.

I ran into a problem on OSX when running jUnits via maven:

Steps to reproduce:
	cd ~/git/ecligse.platform.swt
	mvn clean verify -Pbuild-individual-bundles

Expected:
- SWT is compiled and AllTests jUnits are executed.
- This works on Linux/gtk

Actual:
- On OSX, SWT compiles, but all tests fail with:
  ***WARNING: Display must be created on main thread due to Cocoa restrictions...

Investigation:
- I found that the -XstartOnFirstThread jvm argument is missing in scenario above.
- I found other plugins add this argument conditionally via activation/os/family. E.g:
  <profile><id>macosx</id>
	<activation><os><family>mac</family></os></activation>
	<properties><ui.test.vmargs>${uitest.vmparams} -XstartOnFirstThread</ui.test.vmargs></properties>
  </profile>
  http://git.eclipse.org/c/swtbot/org.eclipse.swtbot.git/tree/org.eclipse.swtbot.eclipse.ui.test/pom.xml#n44

Proposed solution:
- Following conventions found in Tycho/FAQ:
  https://wiki.eclipse.org/Tycho/FAQ#How_do_I_add_OS-specific_flags.3F
  I've modified swt's parent pom.xml & swt's test pom.xml, to conditionally add vmarg -XstartOnFirstThread on OSX
- I tested this modification. On Linux and OSX, mvn build/tests succeed. (Not tested on Windows, but change shouldn't affect windows).
- As a note, I found that our OSX build server specifies -XstartOnFirstThread via frameworkvmargs (see Bug 502410). 
  It might lead to a situation where -XstartOnFirstThread is specified multiple times. I've tested a scenario where -XstartOnFirstThread is specified multiple times on OSX, mvn build/tests succeed. So it shouldn't be an issue.

I'll be submitting a patch shortly.
(Note, I've never really worked with maven much before, so feedback on upcoming patch is much appreciated).
Comment 1 Leo Ufimtsev CLA 2017-07-05 10:03:29 EDT
Patch:
https://git.eclipse.org/r/#/c/100667/

@Cocoa/Maven reviewers, please kindly review