worldsayshi
worldsayshi

Reputation: 1991

Avoid error exit status when running eclipse in headless build mode

Edit: This issue was due to me misinterpreting the error output. There was indeed a build failure of a build configuration that I wasn't interested in. So I excluded the configuration from the build command (see answer).

I'm running a build script that at one instance runs a headless build with eclipse like so:

set -e

# ...

eclipse -nosplash \
 -application org.eclipse.cdt.managedbuilder.core.headlessbuild \
 -import ./ \
 -I /usr/lib/jvm/java-7-openjdk-i386/include/ \
 -I /usr/lib/jvm/java-7-openjdk-i386/include/linux \
 -cleanBuild all

The build is successful in that it outputs the built libraries. However, it seems that after the build is complete eclipse try to start the gui. And since I'm running the script in an environment that lacks a window manager it fails and eclipse return an error code and thus cause my script to fail. I would very much like it to actually fail if there was an actual problem. So I wouldn't like to remove the set -e command. How can I make eclipse not try to start its gui? Or is there some reasonable workaround for this?

Here is the eclipse output after the point of completing building the libs:

Invoking scanner config builder on project 
Eclipse: Cannot open display: 
Eclipse:
Java was started but returned exit code=1
-Dosgi.requiredJavaVersion=1.7
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
-Djava.class.path=/vagrant/exec/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
-os linux
-ws gtk
-arch x86
-launcher /vagrant/exec/eclipse/eclipse
-name Eclipse
--launcher.library /vagrant/exec/eclipse//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.200.v20140603-1326/eclipse_1605.so
-startup /vagrant/exec/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.appendVmargs
-product org.eclipse.epp.package.cpp.product
-application org.eclipse.cdt.managedbuilder.core.headlessbuild
-import ./
-I /usr/lib/jvm/java-7-openjdk-i386/include/
-I /usr/lib/jvm/java-7-openjdk-i386/include/linux
-cleanBuild all
-vm /usr/lib/jvm/java-7-openjdk-i386/jre/bin/../lib/i386/client/libjvm.so
-vmargs
-Dosgi.requiredJavaVersion=1.7
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m

Upvotes: 4

Views: 2453

Answers (1)

worldsayshi
worldsayshi

Reputation: 1991

This was a case of me not reading the output properly. My problem was that I used the -cleanBuild all option while there was only one configuration that was buildable on the system, possibly causing it to try to open an error dialogue. The name of the configurations was Release (mingw) and Release (posix). -cleanBuild accepts regex input so I ended up running the build like so:

eclipse -nosplash \
    --launcher.suppressErrors \
    -application org.eclipse.cdt.managedbuilder.core.headlessbuild \
    -import ./ \
    -I /usr/lib/jvm/java-7-openjdk-i386/include/ \
    -I /usr/lib/jvm/java-7-openjdk-i386/include/linux \
    -cleanBuild .*/.*posix.*

Upvotes: 3

Related Questions