3

I want to run a Java program as a builder before the Java Builder kicks in. The Java class to be run is part of another project within the workspace.

I can add Program builder but I don't want to point explicitly to a Java VM as my teammates may have their Java installed in different location. Is there a way to achieve this without referring to a particular JVM executable?

EDIT: Added screenshot of Eclipse Builders to show which config I'm talking about. Screenshot of Eclipse Builders configuration

Lii
12.2k9 gold badges69 silver badges93 bronze badges
asked Dec 13, 2013 at 10:01
2
  • How are you specifying this builder? Commented Dec 13, 2013 at 10:53
  • @greg-449 Check out the screenshot I added. Commented Dec 16, 2013 at 1:49

2 Answers 2

1

I can run the java program using a normal launcher (.launch file created using Run/Debug Configuration). I figured out a way to make that work as a Builder step.

Simply move the .launch to .externalToolBuilders and modify the .project file in a text editor to pick up that .launch file.

<buildCommand>
 <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
 <triggers>full,incremental,</triggers>
 <arguments>
 <dictionary>
 <key>LaunchConfigHandle</key>
 <value>&lt;project&gt;/.externalToolBuilders/MyCustomJavaProgram.launch</value>
 </dictionary>
 </arguments>
</buildCommand>

Eclipse being the good boy it is, doesn't complain about the presence of a org.eclipse.jdt.launching.localJavaApplication as a Builder step and everything works smoothly. In fact if you edit this newly added Builder step it even shows the correct Edit launch configuration dialog.

answered Dec 17, 2013 at 1:54
Sign up to request clarification or add additional context in comments.

1 Comment

But manually adding a launch configuration file (.launch) to .externalToolBuilders is exactly the same as creating a Program Builder with the Builders dialog, isn't it? Why do it this way?
0

The best way to create a builder in Java is to create a plugin and use the org.eclipse.core.resources.builders extension point. Your builder class then extends the org.eclipse.core.resources.IncrementalProjectBuilder class and has access to lots of detail about what is being built.

This method does not require a JVM to be specified anywhere as your plugin runs as part of Eclipse.

answered Dec 16, 2013 at 7:45

1 Comment

while that may be useful in general, in my case it's a bit of an overkill. i don't want to force a plugin installation on part of other team members either.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.