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
-
How are you specifying this builder?greg-449– greg-4492013年12月13日 10:53:30 +00:00Commented Dec 13, 2013 at 10:53
-
@greg-449 Check out the screenshot I added.hawk– hawk2013年12月16日 01:49:37 +00:00Commented Dec 16, 2013 at 1:49
2 Answers 2
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><project>/.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.
1 Comment
.launch) to .externalToolBuilders is exactly the same as creating a Program Builder with the Builders dialog, isn't it? Why do it this way?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.