Eclipse components

T

Tim Tyler

Are the Eclipse compiler and formatter available as stand-alone
components yet?

If not why not? Is it something to do with being big and blue?
Or do they not want their competitors using these components?
 
C

Chris Smith

Tim Tyler said:
Are the Eclipse compiler and formatter available as stand-alone
components yet?

I'm not aware of the formatter being available this way. The compiler
appears to be used in Jasper as distributed with Tomcat 5.5, so it is at
least possible to use it this way.
If not why not? Is it something to do with being big and blue?
Or do they not want their competitors using these components?

Mainly because you haven't packaged it that way yet. Let's get back to
reality here! There's no point acting like this is some big IBM
conspiracy to keep the functionality under wraps. It's open source.
Understandably, the project developers want to spend their time making
Eclipse better... and I'm quite grateful for that. I think it's a wise
decision on their part.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

Roland

Are the Eclipse compiler and formatter available as stand-alone
components yet?

If not why not? Is it something to do with being big and blue?
Or do they not want their competitors using these components?

In one of our projects I've used the Eclipse compiler to compile a batch
of Java files. This works perfectly. [Never used formatter stand-alone.]

You'll need the 'JDT Core' plugin: I've used org.eclipse.jdt.core_3.0.1,
in particular the class org.eclipse.jdt.internal.compiler.batch.Main in
jdtcore.jar. The following snippet shows how this class can be used


import org.eclipse.jdt.internal.compiler.batch.Main

/**
* Compiles sourceFile and produces .class file in outDir.
* @param sourceFile source file to compile
* @param outDir directory of resulting class file
* @return <code>true</code> if compilation was successful,
* <code>false</code> when compilation failed
*/
private boolean compileJavaSource(File sourceFile, File outDir)
{
StringWriter javacOut = new StringWriter();
PrintWriter pwJavacOut = new PrintWriter(javacOut);
StringWriter javacErr = new StringWriter();
PrintWriter pwJavacErr = new PrintWriter(javacErr);

Main javac = new Main(pwJavacOut, pwJavacErr, false);

String[] args = {"-d", outDir.toString(), sourceFile.toString()};

boolean compiled = javac.compile(args);
pwJavacOut.close();
pwJavacErr.close();

if (compiled)
{
// success
return true;
}
else
{
// failed: log compiler messages
__logger.severe("Java compiler stdout: " + javacOut.toString());
__logger.severe("Java compiler stderr: " + javacErr.toString());
return false;
}
}

--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
T

Tim Tyler

Chris Smith said:
I'm not aware of the formatter being available this way. The compiler
appears to be used in Jasper as distributed with Tomcat 5.5, so it is at
least possible to use it this way.


Mainly because you haven't packaged it that way yet. Let's get back to
reality here! There's no point acting like this is some big IBM
conspiracy to keep the functionality under wraps. It's open source.
Understandably, the project developers want to spend their time making
Eclipse better... and I'm quite grateful for that. I think it's a wise
decision on their part.

If a component is viable as a modular element, then the larger the
audience it has, the more developers it attracts, the faster development
goes, and the better the tool gets.

As far as I can see, an Eclipse-only formatter is a project that doesn't
make much sense.

*Most* formatters can be plugged into any IDE, or used from the command
line.

The Eclipse formatter appears to suffer from not having any command-line
interface.

How do you format all the files in a project?

It's a symptom of the underlying problem.

What's the cause of the problem? As you can see from my speculations, I
don't really know - but I am interested in the cause of it - since it
seems to be repeatedly causing monolith-related problems for Eclipse.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top