Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Ant Runner - Console Log
Ant Runner - Console Log [message #37159] Sun, 18 May 2003 21:26 Go to next message
Eclipse UserFriend
Originally posted by: ghodsian.collaxa.com

Hi,

I am developing a builder extension which needs to run an ant build file.
I have found the documentation on how to configure and run AntRunner.

try
{
// build logic
AntRunner runner = new AntRunner();
runner.setBuildFileLocation( buildFile );

// Assign logger so that output is redirected to the console.
runner.addBuildLogger( ANT_LOGGER_CLASS );

runner.setArguments( " -verbose");
runner.run( monitor );
}
catch( Throwable t )
{
t.printStackTrace();
}

But I am not able to determine how to redirect the output the build into
the console.

Has anyone already solved that problem? Any pointer would be much
apreciated.
Re: Ant Runner - Console Log [message #37910 is a reply to message #37159] Mon, 19 May 2003 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jared-eclipse.mn.rr.com

Eclipse launches and using AntLaunchDelegate and AntLaunchShortcut.

- Jared

Mark Ghodsian wrote:

> Hi,
>
> I am developing a builder extension which needs to run an ant build file.
> I have found the documentation on how to configure and run AntRunner.
>
> try
> {
> // build logic
> AntRunner runner = new AntRunner();
> runner.setBuildFileLocation( buildFile );
>
> // Assign logger so that output is redirected to the console.
> runner.addBuildLogger( ANT_LOGGER_CLASS );
>
> runner.setArguments( " -verbose");
> runner.run( monitor );
> }
> catch( Throwable t )
> {
> t.printStackTrace();
> }
>
> But I am not able to determine how to redirect the output the build into
> the console.
>
> Has anyone already solved that problem? Any pointer would be much
> apreciated.
Re: Ant Runner - Console Log [message #38763 is a reply to message #37910] Mon, 19 May 2003 19:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ghodsian.collaxa.com

Thank you for the insight. Would you happen to know if there are examples
out there on how to leverage the AntLaunchDelegate or the
AntLaunchShortcut from within a builder?
Thanks!!!
Mark

Jared Burns wrote:

> Eclipse launches and using AntLaunchDelegate and AntLaunchShortcut.

> - Jared

> Mark Ghodsian wrote:

> > Hi,
> >
> > I am developing a builder extension which needs to run an ant build file.
> > I have found the documentation on how to configure and run AntRunner.
> >
> > try
> > {
> > // build logic
> > AntRunner runner = new AntRunner();
> > runner.setBuildFileLocation( buildFile );
> >
> > // Assign logger so that output is redirected to the console.
> > runner.addBuildLogger( ANT_LOGGER_CLASS );
> >
> > runner.setArguments( " -verbose");
> > runner.run( monitor );
> > }
> > catch( Throwable t )
> > {
> > t.printStackTrace();
> > }
> >
> > But I am not able to determine how to redirect the output the build into
> > the console.
> >
> > Has anyone already solved that problem? Any pointer would be much
> > apreciated.
Re: Ant Runner - Console Log [message #38860 is a reply to message #38763] Mon, 19 May 2003 21:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jared-eclipse.mn.rr.com

ExternalToolBuilder is a builder that runs launch configs, including Ant
configs. As you'll see in the build(...) method, it's passed the location
of a launch config as an argument and just executes that config.

- Jared

Mark Ghodsian wrote:

> Thank you for the insight. Would you happen to know if there are examples
> out there on how to leverage the AntLaunchDelegate or the
> AntLaunchShortcut from within a builder?
Re: Ant Runner - Console Log [message #39088 is a reply to message #38860] Tue, 20 May 2003 02:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ghodsian.collaxa.com

Jared. Thank you so much! It worked like a charm. Here is the source code
in case anyone else needs to accomplish the same time:

/*
* Created on May 14, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package bpelz.builders;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.StringTokenizer;

import bpelz.bpelzPlugin;

import org.eclipse.ant.core.AntRunner;
import org.eclipse.ant.internal.core.IAntCoreConstants;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.resources.IFile;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.DebugUITools;
import
org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchConfigurationMessages;
import
org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchShortcut;
import org.eclipse.ui.externaltools.internal.model.IExternalToolCon stants;
import org.eclipse.ui.externaltools.internal.model.ToolUtil;
import org.eclipse.ui.externaltools.internal.model.VariableContextM anager;


/**
* @author Edwin Khodabakchian
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class BPELBuilder extends IncrementalProjectBuilder
{
private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
private static final int[] DEFAULT_BUILD_TYPES= new int[] {

IncrementalProjectBuilder.INCREMENTAL_BUILD,
IncrementalProjectBuilder.FULL_BUILD};

public IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException
{
try
{
System.out.println( ">>>>>>>>>>BUILDING>>>>>>>>>>>>");

// find build find within this project
IFile selectedFile = findBuildFile();

// Create a temporary launch configuration.
ILaunchConfiguration config = createDefaultConfig(
selectedFile );

boolean runTool = false;
int[] buildKinds =
buildTypesToArray( (String)config.getAttribute(

IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")
); //$NON-NLS-1$

for (int i = 0; i < buildKinds.length; i++) {
if (kind == buildKinds[i]) {
runTool = true;
break;
}
}
if (!runTool)
return null;

// Mark the build as started
VariableContextManager.getDefault().buildStarted(getProject( ),
kind);

// Launch the external ant tool
config.launch(ILaunchManager.RUN_MODE, null);

// Mark the build as completed
VariableContextManager.getDefault().buildEnded();
forgetLastBuiltState();

System.out.println( "<<<<<<<<<<BUILDING<<<<<<<<<<<<<");
}
catch( Throwable t )
{
t.printStackTrace( );
}
return null;
}

/**
* Creates and returns a default launch configuration for the given
file.
*
* @param file
* @return default launch configuration
*/
public static ILaunchConfiguration createDefaultConfig( IFile file )
{

ILaunchManager manager =
DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type =
manager.getLaunchConfigurationType(

IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);

StringBuffer buffer = new
StringBuffer(file.getProject().getName());
buffer.append(" "); //$NON-NLS-1$
buffer.append( file.getName() );
String name = buffer.toString().trim();
name= manager.generateUniqueLaunchConfigurationNameFrom( name );
try
{
ILaunchConfigurationWorkingCopy workingCopy
= type.newInstance(null, name);
StringBuffer buf = new StringBuffer();
ToolUtil.buildVariableTag(
IExternalToolConstants.VAR_WORKSPACE_LOC,
file.getFullPath().toString(),
buf
);

workingCopy.setAttribute(
IExternalToolConstants.ATTR_LOCATION,
buf.toString()
);

// set default for common settings
CommonTab tab = new CommonTab();
tab.setDefaults( workingCopy );
tab.dispose();

return workingCopy;
}
catch (Throwable t)
{
System.out.println( "Error while creating the default
configuration" );
t.printStackTrace();
}
return null;
}

/***
* Find the ant build file associated with this project.
*/
protected IFile findBuildFile()
{
IProject p = getProject();
return (IFile) p.findMember(
IAntCoreConstants.DEFAULT_BUILD_FILENAME );
}

protected void startupOnInitialize()
{
System.out.println( ">>>>>>>>>>BUILD ON INITIALIZE>>>>>>>>>>>>");
// builder init logic
}

/**
* Converts the build types string into an array of
* build kinds.
*
* @param buildTypes the string of built types to convert
* @return the array of build kinds.
*/
public static int[] buildTypesToArray(String buildTypes) {
int count = 0;
boolean incremental = false;
boolean full = false;
boolean auto = false;

if (buildTypes == null || buildTypes.length() == 0) {
return DEFAULT_BUILD_TYPES;
}

StringTokenizer tokenizer = new StringTokenizer(buildTypes,
BUILD_TYPE_SEPARATOR);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if
(IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token) ) {
if (!incremental) {
incremental = true;
count++;
}
}
else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token))
{
if (!full) {
full = true;
count++;
}
}
else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token))
{
if (!auto) {
auto = true;
count++;
}
}
}

int[] results = new int[count];
count = 0;
if (incremental) {
results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
count++;
}
if (full) {
results[count] = IncrementalProjectBuilder.FULL_BUILD;
count++;
}
if (auto) {
results[count] = IncrementalProjectBuilder.AUTO_BUILD;
count++;
}

return results;
}


}






Jared Burns wrote:

> ExternalToolBuilder is a builder that runs launch configs, including Ant
> configs. As you'll see in the build(...) method, it's passed the location
> of a launch config as an argument and just executes that config.

> - Jared

> Mark Ghodsian wrote:

> > Thank you for the insight. Would you happen to know if there are examples
> > out there on how to leverage the AntLaunchDelegate or the
> > AntLaunchShortcut from within a builder?
Re: Ant Runner - Console Log [message #286058 is a reply to message #39088] Wed, 01 June 2005 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mazloumi.uni-mannheim.de

Sorry, but I didn't understand how I can redirect the ant log to
a console view.

Has someone experience with that?

This is what id do at the moment:

final AntRunner runner = new AntRunner();
....
runner.setBuildFileLocation(buildFile.toString());
....
runner.setMessageOutputLevel(verboseLevel);
....
runner.setArguments(args);
....
runner.run();

I know I can add my own logger with:
runner.addBuildLogger("foo.FooLogger");

But how do I write out what ant logs into a console window?

Thanks,
nima

Mark Ghodsian wrote:
> Jared. Thank you so much! It worked like a charm. Here is the source code
> in case anyone else needs to accomplish the same time:
>
> /*
> * Created on May 14, 2003
> *
> * To change the template for this generated file go to
> * Window>Preferences>Java>Code Generation>Code and Comments
> */
> package bpelz.builders;
>
> import java.io.File;
> import java.io.IOException;
> import java.util.Map;
> import java.util.StringTokenizer;
>
> import bpelz.bpelzPlugin;
>
> import org.eclipse.ant.core.AntRunner;
> import org.eclipse.ant.internal.core.IAntCoreConstants;
> import org.eclipse.core.resources.IFile;
> import org.eclipse.core.resources.IProject;
> import org.eclipse.core.resources.IncrementalProjectBuilder;
> import org.eclipse.core.runtime.CoreException;
> import org.eclipse.core.runtime.IProgressMonitor;
> import org.eclipse.core.runtime.IStatus;
> import org.eclipse.core.runtime.Status;
> import org.eclipse.core.resources.IFile;
> import org.eclipse.debug.core.DebugPlugin;
> import org.eclipse.debug.core.ILaunchConfiguration;
> import org.eclipse.debug.core.ILaunchConfigurationType;
> import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
> import org.eclipse.debug.core.ILaunchManager;
> import org.eclipse.debug.ui.CommonTab;
> import org.eclipse.debug.ui.DebugUITools;
> import
> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchConfigurationMessages;
> import
> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchShortcut;
> import org.eclipse.ui.externaltools.internal.model.IExternalToolCon stants;
> import org.eclipse.ui.externaltools.internal.model.ToolUtil;
> import org.eclipse.ui.externaltools.internal.model.VariableContextM anager;
>
>
> /**
> * @author Edwin Khodabakchian
> *
> * To change the template for this generated type comment go to
> * Window>Preferences>Java>Code Generation>Code and Comments
> */
> public class BPELBuilder extends IncrementalProjectBuilder
> {
> private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
> private static final int[] DEFAULT_BUILD_TYPES= new int[] {
>
> IncrementalProjectBuilder.INCREMENTAL_BUILD,
> IncrementalProjectBuilder.FULL_BUILD};
>
> public IProject[] build(int kind, Map args, IProgressMonitor monitor)
> throws CoreException
> {
> try
> {
> System.out.println( ">>>>>>>>>>BUILDING>>>>>>>>>>>>");
>
> // find build find within this project
> IFile selectedFile = findBuildFile();
>
> // Create a temporary launch configuration.
> ILaunchConfiguration config = createDefaultConfig(
> selectedFile );
>
> boolean runTool = false;
> int[] buildKinds =
> buildTypesToArray( (String)config.getAttribute(
>
> IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")
> ); //$NON-NLS-1$
>
> for (int i = 0; i < buildKinds.length; i++) {
> if (kind == buildKinds[i]) {
> runTool = true;
> break;
> }
> }
> if (!runTool)
> return null;
>
> // Mark the build as started
> VariableContextManager.getDefault().buildStarted(getProject( ),
> kind);
>
> // Launch the external ant tool
> config.launch(ILaunchManager.RUN_MODE, null);
>
> // Mark the build as completed
> VariableContextManager.getDefault().buildEnded();
> forgetLastBuiltState();
>
> System.out.println( "<<<<<<<<<<BUILDING<<<<<<<<<<<<<");
> }
> catch( Throwable t )
> {
> t.printStackTrace( );
> }
> return null;
> }
>
> /**
> * Creates and returns a default launch configuration for the given
> file.
> *
> * @param file
> * @return default launch configuration
> */
> public static ILaunchConfiguration createDefaultConfig( IFile file )
> {
>
> ILaunchManager manager =
> DebugPlugin.getDefault().getLaunchManager();
> ILaunchConfigurationType type =
> manager.getLaunchConfigurationType(
>
> IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
>
> StringBuffer buffer = new
> StringBuffer(file.getProject().getName());
> buffer.append(" "); //$NON-NLS-1$
> buffer.append( file.getName() );
> String name = buffer.toString().trim();
> name= manager.generateUniqueLaunchConfigurationNameFrom( name );
> try
> {
> ILaunchConfigurationWorkingCopy workingCopy
> = type.newInstance(null, name);
> StringBuffer buf = new StringBuffer();
> ToolUtil.buildVariableTag(
> IExternalToolConstants.VAR_WORKSPACE_LOC,
> file.getFullPath().toString(),
> buf
> );
>
> workingCopy.setAttribute(
> IExternalToolConstants.ATTR_LOCATION,
> buf.toString()
> );
>
> // set default for common settings
> CommonTab tab = new CommonTab();
> tab.setDefaults( workingCopy );
> tab.dispose();
>
> return workingCopy;
> }
> catch (Throwable t)
> {
> System.out.println( "Error while creating the default
> configuration" );
> t.printStackTrace();
> }
> return null;
> }
>
> /***
> * Find the ant build file associated with this project.
> */
> protected IFile findBuildFile()
> {
> IProject p = getProject();
> return (IFile) p.findMember(
> IAntCoreConstants.DEFAULT_BUILD_FILENAME );
> }
>
> protected void startupOnInitialize()
> {
> System.out.println( ">>>>>>>>>>BUILD ON INITIALIZE>>>>>>>>>>>>");
> // builder init logic
> }
>
> /**
> * Converts the build types string into an array of
> * build kinds.
> *
> * @param buildTypes the string of built types to convert
> * @return the array of build kinds.
> */
> public static int[] buildTypesToArray(String buildTypes) {
> int count = 0;
> boolean incremental = false;
> boolean full = false;
> boolean auto = false;
>
> if (buildTypes == null || buildTypes.length() == 0) {
> return DEFAULT_BUILD_TYPES;
> }
>
> StringTokenizer tokenizer = new StringTokenizer(buildTypes,
> BUILD_TYPE_SEPARATOR);
> while (tokenizer.hasMoreTokens()) {
> String token = tokenizer.nextToken();
> if
> (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token) ) {
> if (!incremental) {
> incremental = true;
> count++;
> }
> }
> else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token))
> {
> if (!full) {
> full = true;
> count++;
> }
> }
> else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token))
> {
> if (!auto) {
> auto = true;
> count++;
> }
> }
> }
>
> int[] results = new int[count];
> count = 0;
> if (incremental) {
> results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
> count++;
> }
> if (full) {
> results[count] = IncrementalProjectBuilder.FULL_BUILD;
> count++;
> }
> if (auto) {
> results[count] = IncrementalProjectBuilder.AUTO_BUILD;
> count++;
> }
>
> return results;
> }
>
>
> }
>
>
>
>
>
>
> Jared Burns wrote:
>
>
>>ExternalToolBuilder is a builder that runs launch configs, including Ant
>>configs. As you'll see in the build(...) method, it's passed the location
>>of a launch config as an argument and just executes that config.
>
>
>>- Jared
>
>
>>Mark Ghodsian wrote:
>
>
>>>Thank you for the insight. Would you happen to know if there are examples
>>>out there on how to leverage the AntLaunchDelegate or the
>>>AntLaunchShortcut from within a builder?
>
>
>
>
Re: Ant Runner - Console Log [message #286071 is a reply to message #286058] Wed, 01 June 2005 16:02 Go to previous messageGo to next message
Eclipse UserFriend
I have pasted below a logger class that works for me (would be your
foo.FooLogger):

public class AntConsoleLogger extends DefaultLogger {

// the message console stream used to output to the console view
private MessageConsoleStream mConsoleStream = null;

public AntConsoleLogger() {
super();
MessageConsole myConsole = findConsole("Some console name");
mConsoleStream = myConsole.newMessageStream();
}

protected void log(String message) {
mConsoleStream.println(message);
}
}

Also in case u need it, have added method to findConsole:

public static MessageConsole findConsole(String name) {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName()))
return (MessageConsole) existing[i];
//no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[]{myConsole});
return myConsole;
}

Hope this is what u need.

-matt




Nima Mazloumi wrote:

> Sorry, but I didn't understand how I can redirect the ant log to
> a console view.

> Has someone experience with that?

> This is what id do at the moment:

> final AntRunner runner = new AntRunner();
> ....
> runner.setBuildFileLocation(buildFile.toString());
> ....
> runner.setMessageOutputLevel(verboseLevel);
> ....
> runner.setArguments(args);
> ....
> runner.run();

> I know I can add my own logger with:
> runner.addBuildLogger("foo.FooLogger");

> But how do I write out what ant logs into a console window?

> Thanks,
> nima

> Mark Ghodsian wrote:
>> Jared. Thank you so much! It worked like a charm. Here is the source code
>> in case anyone else needs to accomplish the same time:
>>
>> /*
>> * Created on May 14, 2003
>> *
>> * To change the template for this generated file go to
>> * Window>Preferences>Java>Code Generation>Code and Comments
>> */
>> package bpelz.builders;
>>
>> import java.io.File;
>> import java.io.IOException;
>> import java.util.Map;
>> import java.util.StringTokenizer;
>>
>> import bpelz.bpelzPlugin;
>>
>> import org.eclipse.ant.core.AntRunner;
>> import org.eclipse.ant.internal.core.IAntCoreConstants;
>> import org.eclipse.core.resources.IFile;
>> import org.eclipse.core.resources.IProject;
>> import org.eclipse.core.resources.IncrementalProjectBuilder;
>> import org.eclipse.core.runtime.CoreException;
>> import org.eclipse.core.runtime.IProgressMonitor;
>> import org.eclipse.core.runtime.IStatus;
>> import org.eclipse.core.runtime.Status;
>> import org.eclipse.core.resources.IFile;
>> import org.eclipse.debug.core.DebugPlugin;
>> import org.eclipse.debug.core.ILaunchConfiguration;
>> import org.eclipse.debug.core.ILaunchConfigurationType;
>> import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
>> import org.eclipse.debug.core.ILaunchManager;
>> import org.eclipse.debug.ui.CommonTab;
>> import org.eclipse.debug.ui.DebugUITools;
>> import
>>
org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchConfigurationMessages;
>> import
>>
org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchShortcut;
>> import org.eclipse.ui.externaltools.internal.model.IExternalToolCon stants;
>> import org.eclipse.ui.externaltools.internal.model.ToolUtil;
>> import org.eclipse.ui.externaltools.internal.model.VariableContextM anager;
>>
>>
>> /**
>> * @author Edwin Khodabakchian
>> *
>> * To change the template for this generated type comment go to
>> * Window>Preferences>Java>Code Generation>Code and Comments
>> */
>> public class BPELBuilder extends IncrementalProjectBuilder
>> {
>> private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
>> private static final int[] DEFAULT_BUILD_TYPES= new int[] {
>>
>> IncrementalProjectBuilder.INCREMENTAL_BUILD,
>> IncrementalProjectBuilder.FULL_BUILD};
>>
>> public IProject[] build(int kind, Map args, IProgressMonitor monitor)
>> throws CoreException
>> {
>> try
>> {
>> System.out.println( ">>>>>>>>>>BUILDING>>>>>>>>>>>>");
>>
>> // find build find within this project
>> IFile selectedFile = findBuildFile();
>>
>> // Create a temporary launch configuration.
>> ILaunchConfiguration config = createDefaultConfig(
>> selectedFile );
>>
>> boolean runTool = false;
>> int[] buildKinds =
>> buildTypesToArray( (String)config.getAttribute(
>>
>> IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")
>> ); //$NON-NLS-1$
>>
>> for (int i = 0; i < buildKinds.length; i++) {
>> if (kind == buildKinds[i]) {
>> runTool = true;
>> break;
>> }
>> }
>> if (!runTool)
>> return null;
>>
>> // Mark the build as started
>> VariableContextManager.getDefault().buildStarted(getProject( ),
>> kind);
>>
>> // Launch the external ant tool
>> config.launch(ILaunchManager.RUN_MODE, null);
>>
>> // Mark the build as completed
>> VariableContextManager.getDefault().buildEnded();
>> forgetLastBuiltState();
>>
>> System.out.println( "<<<<<<<<<<BUILDING<<<<<<<<<<<<<");
>> }
>> catch( Throwable t )
>> {
>> t.printStackTrace( );
>> }
>> return null;
>> }
>>
>> /**
>> * Creates and returns a default launch configuration for the given
>> file.
>> *
>> * @param file
>> * @return default launch configuration
>> */
>> public static ILaunchConfiguration createDefaultConfig( IFile file )
>> {
>>
>> ILaunchManager manager =
>> DebugPlugin.getDefault().getLaunchManager();
>> ILaunchConfigurationType type =
>> manager.getLaunchConfigurationType(
>>
>> IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
>>
>> StringBuffer buffer = new
>> StringBuffer(file.getProject().getName());
>> buffer.append(" "); //$NON-NLS-1$
>> buffer.append( file.getName() );
>> String name = buffer.toString().trim();
>> name= manager.generateUniqueLaunchConfigurationNameFrom( name );
>> try
>> {
>> ILaunchConfigurationWorkingCopy workingCopy
>> = type.newInstance(null, name);
>> StringBuffer buf = new StringBuffer();
>> ToolUtil.buildVariableTag(
>> IExternalToolConstants.VAR_WORKSPACE_LOC,
>> file.getFullPath().toString(),
>> buf
>> );
>>
>> workingCopy.setAttribute(
>> IExternalToolConstants.ATTR_LOCATION,
>> buf.toString()
>> );
>>
>> // set default for common settings
>> CommonTab tab = new CommonTab();
>> tab.setDefaults( workingCopy );
>> tab.dispose();
>>
>> return workingCopy;
>> }
>> catch (Throwable t)
>> {
>> System.out.println( "Error while creating the default
>> configuration" );
>> t.printStackTrace();
>> }
>> return null;
>> }
>>
>> /***
>> * Find the ant build file associated with this project.
>> */
>> protected IFile findBuildFile()
>> {
>> IProject p = getProject();
>> return (IFile) p.findMember(
>> IAntCoreConstants.DEFAULT_BUILD_FILENAME );
>> }
>>
>> protected void startupOnInitialize()
>> {
>> System.out.println( ">>>>>>>>>>BUILD ON INITIALIZE>>>>>>>>>>>>");
>> // builder init logic
>> }
>>
>> /**
>> * Converts the build types string into an array of
>> * build kinds.
>> *
>> * @param buildTypes the string of built types to convert
>> * @return the array of build kinds.
>> */
>> public static int[] buildTypesToArray(String buildTypes) {
>> int count = 0;
>> boolean incremental = false;
>> boolean full = false;
>> boolean auto = false;
>>
>> if (buildTypes == null || buildTypes.length() == 0) {
>> return DEFAULT_BUILD_TYPES;
>> }
>>
>> StringTokenizer tokenizer = new StringTokenizer(buildTypes,
>> BUILD_TYPE_SEPARATOR);
>> while (tokenizer.hasMoreTokens()) {
>> String token = tokenizer.nextToken();
>> if
>> (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token) ) {
>> if (!incremental) {
>> incremental = true;
>> count++;
>> }
>> }
>> else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token))
>> {
>> if (!full) {
>> full = true;
>> count++;
>> }
>> }
>> else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token))
>> {
>> if (!auto) {
>> auto = true;
>> count++;
>> }
>> }
>> }
>>
>> int[] results = new int[count];
>> count = 0;
>> if (incremental) {
>> results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
>> count++;
>> }
>> if (full) {
>> results[count] = IncrementalProjectBuilder.FULL_BUILD;
>> count++;
>> }
>> if (auto) {
>> results[count] = IncrementalProjectBuilder.AUTO_BUILD;
>> count++;
>> }
>>
>> return results;
>> }
>>
>>
>> }
>>
>>
>>
>>
>>
>>
>> Jared Burns wrote:
>>
>>
>>>ExternalToolBuilder is a builder that runs launch configs, including Ant
>>>configs. As you'll see in the build(...) method, it's passed the location
>>>of a launch config as an argument and just executes that config.
>>
>>
>>>- Jared
>>
>>
>>>Mark Ghodsian wrote:
>>
>>
>>>>Thank you for the insight. Would you happen to know if there are examples
>>>>out there on how to leverage the AntLaunchDelegate or the
>>>>AntLaunchShortcut from within a builder?
>>
>>
>>
>>
Re: Ant Runner - Console Log [message #286092 is a reply to message #286071] Thu, 02 June 2005 06:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mazloumi.uni-mannheim.de

Hi Matt,

thank you very much. I works now.

Greetings,
Nima

Matt OBrien wrote:
>
> I have pasted below a logger class that works for me (would be your
> foo.FooLogger):
>
> public class AntConsoleLogger extends DefaultLogger {
> // the message console stream used to output to the console view
> private MessageConsoleStream mConsoleStream = null;
>
> public AntConsoleLogger() {
> super(); MessageConsole myConsole =
> findConsole("Some console name");
> mConsoleStream = myConsole.newMessageStream(); }
> protected void log(String message) {
> mConsoleStream.println(message);
> }
> }
>
> Also in case u need it, have added method to findConsole:
>
> public static MessageConsole findConsole(String name) {
> ConsolePlugin plugin = ConsolePlugin.getDefault();
> IConsoleManager conMan = plugin.getConsoleManager();
> IConsole[] existing = conMan.getConsoles();
> for (int i = 0; i < existing.length; i++)
> if (name.equals(existing[i].getName()))
> return (MessageConsole) existing[i];
> //no console found, so create a new one
> MessageConsole myConsole = new MessageConsole(name, null);
> conMan.addConsoles(new IConsole[]{myConsole});
> return myConsole;
> }
>
> Hope this is what u need.
>
> -matt
>
>
>
>
> Nima Mazloumi wrote:
>
>> Sorry, but I didn't understand how I can redirect the ant log to
>> a console view.
>
>
>> Has someone experience with that?
>
>
>> This is what id do at the moment:
>
>
>> final AntRunner runner = new AntRunner();
>> ....
>> runner.setBuildFileLocation(buildFile.toString());
>> ....
>> runner.setMessageOutputLevel(verboseLevel);
>> ....
>> runner.setArguments(args);
>> ....
>> runner.run();
>
>
>> I know I can add my own logger with:
>> runner.addBuildLogger("foo.FooLogger");
>
>
>> But how do I write out what ant logs into a console window?
>
>
>> Thanks,
>> nima
>
>
>> Mark Ghodsian wrote:
>>
>>> Jared. Thank you so much! It worked like a charm. Here is the source
>>> code
>>> in case anyone else needs to accomplish the same time:
>>>
>>> /*
>>> * Created on May 14, 2003
>>> *
>>> * To change the template for this generated file go to
>>> * Window>Preferences>Java>Code Generation>Code and Comments
>>> */
>>> package bpelz.builders;
>>>
>>> import java.io.File;
>>> import java.io.IOException;
>>> import java.util.Map;
>>> import java.util.StringTokenizer;
>>>
>>> import bpelz.bpelzPlugin;
>>>
>>> import org.eclipse.ant.core.AntRunner;
>>> import org.eclipse.ant.internal.core.IAntCoreConstants;
>>> import org.eclipse.core.resources.IFile;
>>> import org.eclipse.core.resources.IProject;
>>> import org.eclipse.core.resources.IncrementalProjectBuilder;
>>> import org.eclipse.core.runtime.CoreException;
>>> import org.eclipse.core.runtime.IProgressMonitor;
>>> import org.eclipse.core.runtime.IStatus;
>>> import org.eclipse.core.runtime.Status;
>>> import org.eclipse.core.resources.IFile;
>>> import org.eclipse.debug.core.DebugPlugin;
>>> import org.eclipse.debug.core.ILaunchConfiguration;
>>> import org.eclipse.debug.core.ILaunchConfigurationType;
>>> import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
>>> import org.eclipse.debug.core.ILaunchManager;
>>> import org.eclipse.debug.ui.CommonTab;
>>> import org.eclipse.debug.ui.DebugUITools;
>>> import
>>>
> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchConfigurationMessages;
>
>
>>> import
>>>
> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchShortcut;
>
>
>>> import
>>> org.eclipse.ui.externaltools.internal.model.IExternalToolCon stants;
>>> import org.eclipse.ui.externaltools.internal.model.ToolUtil;
>>> import
>>> org.eclipse.ui.externaltools.internal.model.VariableContextM anager;
>>>
>>>
>>> /**
>>> * @author Edwin Khodabakchian
>>> *
>>> * To change the template for this generated type comment go to
>>> * Window>Preferences>Java>Code Generation>Code and Comments
>>> */
>>> public class BPELBuilder extends IncrementalProjectBuilder {
>>> private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
>>> private static final int[] DEFAULT_BUILD_TYPES= new int[] {
>>>
>>> IncrementalProjectBuilder.INCREMENTAL_BUILD,
>>>
>>> IncrementalProjectBuilder.FULL_BUILD};
>>>
>>> public IProject[] build(int kind, Map args, IProgressMonitor
>>> monitor)
>>> throws CoreException {
>>> try
>>> {
>>> System.out.println( ">>>>>>>>>>BUILDING>>>>>>>>>>>>");
>>> // find build find within this project
>>> IFile selectedFile = findBuildFile();
>>> // Create a temporary launch configuration.
>>> ILaunchConfiguration config = createDefaultConfig(
>>> selectedFile );
>>> boolean runTool = false;
>>> int[] buildKinds = buildTypesToArray(
>>> (String)config.getAttribute(
>>>
>>> IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")
>>> ); //$NON-NLS-1$
>>>
>>> for (int i = 0; i < buildKinds.length; i++) {
>>> if (kind == buildKinds[i]) {
>>> runTool = true;
>>> break;
>>> }
>>> }
>>> if (!runTool)
>>> return null;
>>> // Mark the build as started
>>>
>>> VariableContextManager.getDefault().buildStarted(getProject( ),
>>> kind);
>>> // Launch the external ant tool
>>> config.launch(ILaunchManager.RUN_MODE, null);
>>> // Mark the build as completed
>>> VariableContextManager.getDefault().buildEnded();
>>> forgetLastBuiltState();
>>>
>>> System.out.println( "<<<<<<<<<<BUILDING<<<<<<<<<<<<<");
>>> }
>>> catch( Throwable t )
>>> {
>>> t.printStackTrace( );
>>> }
>>> return null;
>>> }
>>>
>>> /**
>>> * Creates and returns a default launch configuration for the given
>>> file.
>>> * * @param file
>>> * @return default launch configuration
>>> */
>>> public static ILaunchConfiguration createDefaultConfig( IFile
>>> file ) {
>>>
>>> ILaunchManager manager =
>>> DebugPlugin.getDefault().getLaunchManager();
>>> ILaunchConfigurationType type =
>>> manager.getLaunchConfigurationType(
>>>
>>> IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
>>> StringBuffer buffer = new
>>> StringBuffer(file.getProject().getName());
>>> buffer.append(" "); //$NON-NLS-1$
>>> buffer.append( file.getName() );
>>> String name = buffer.toString().trim();
>>> name= manager.generateUniqueLaunchConfigurationNameFrom( name );
>>> try {
>>> ILaunchConfigurationWorkingCopy workingCopy
>>> = type.newInstance(null,
>>> name);
>>> StringBuffer buf = new StringBuffer();
>>> ToolUtil.buildVariableTag(
>>> IExternalToolConstants.VAR_WORKSPACE_LOC,
>>>
>>> file.getFullPath().toString(),
>>> buf
>>> );
>>>
>>> workingCopy.setAttribute( IExternalToolConstants.ATTR_LOCATION,
>>> buf.toString()
>>> );
>>> // set default for common settings
>>> CommonTab tab = new CommonTab();
>>> tab.setDefaults( workingCopy );
>>> tab.dispose();
>>> return workingCopy;
>>> } catch (Throwable t) {
>>> System.out.println( "Error while creating the default
>>> configuration" );
>>> t.printStackTrace();
>>> }
>>> return null;
>>> } /***
>>> * Find the ant build file associated with this project. */
>>> protected IFile findBuildFile()
>>> {
>>> IProject p = getProject();
>>> return (IFile) p.findMember(
>>> IAntCoreConstants.DEFAULT_BUILD_FILENAME );
>>> }
>>> protected void startupOnInitialize() {
>>> System.out.println( ">>>>>>>>>>BUILD ON
>>> INITIALIZE>>>>>>>>>>>>");
>>> // builder init logic
>>> }
>>> /**
>>> * Converts the build types string into an array of
>>> * build kinds.
>>> *
>>> * @param buildTypes the string of built types to convert
>>> * @return the array of build kinds.
>>> */
>>> public static int[] buildTypesToArray(String buildTypes) {
>>> int count = 0;
>>> boolean incremental = false;
>>> boolean full = false;
>>> boolean auto = false;
>>> if (buildTypes == null || buildTypes.length() == 0) {
>>> return DEFAULT_BUILD_TYPES;
>>> }
>>>
>>> StringTokenizer tokenizer = new StringTokenizer(buildTypes,
>>> BUILD_TYPE_SEPARATOR);
>>> while (tokenizer.hasMoreTokens()) {
>>> String token = tokenizer.nextToken();
>>> if
>>> (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token) ) {
>>> if (!incremental) {
>>> incremental = true;
>>> count++;
>>> }
>>> }
>>> else if
>>> (IExternalToolConstants.BUILD_TYPE_FULL.equals(token))
>>> {
>>> if (!full) {
>>> full = true;
>>> count++;
>>> }
>>> }
>>> else if
>>> (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token))
>>> {
>>> if (!auto) {
>>> auto = true;
>>> count++;
>>> }
>>> }
>>> }
>>>
>>> int[] results = new int[count];
>>> count = 0;
>>> if (incremental) {
>>> results[count] =
>>> IncrementalProjectBuilder.INCREMENTAL_BUILD;
>>> count++;
>>> }
>>> if (full) {
>>> results[count] = IncrementalProjectBuilder.FULL_BUILD;
>>> count++;
>>> }
>>> if (auto) {
>>> results[count] = IncrementalProjectBuilder.AUTO_BUILD;
>>> count++;
>>> }
>>>
>>> return results;
>>> }
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>> Jared Burns wrote:
>>>
>>>
>>>> ExternalToolBuilder is a builder that runs launch configs, including
>>>> Ant configs. As you'll see in the build(...) method, it's passed the
>>>> location of a launch config as an argument and just executes that
>>>> config.
>>>
>>>
>>>
>>>> - Jared
>>>
>>>
>>>
>>>> Mark Ghodsian wrote:
>>>
>>>
>>>
>>>>> Thank you for the insight. Would you happen to know if there are
>>>>> examples
>>>>> out there on how to leverage the AntLaunchDelegate or the
>>>>> AntLaunchShortcut from within a builder?
>>>
>>>
>>>
>>>
>>>
>
Re: Ant Runner - Console Log [message #286093 is a reply to message #286092] Thu, 02 June 2005 06:33 Go to previous message
Eclipse UserFriend
Originally posted by: mazloumi.uni-mannheim.de

Matt,

have you experience with setting ant home programmatically
instead of manually using the preferences?

Thanks,
Nima


Nima Mazloumi wrote:
> Hi Matt,
>
> thank you very much. I works now.
>
> Greetings,
> Nima
>
> Matt OBrien wrote:
>
>>
>> I have pasted below a logger class that works for me (would be your
>> foo.FooLogger):
>>
>> public class AntConsoleLogger extends DefaultLogger {
>> // the message console stream used to output to the console view
>> private MessageConsoleStream mConsoleStream = null;
>>
>> public AntConsoleLogger() {
>> super(); MessageConsole myConsole =
>> findConsole("Some console name");
>> mConsoleStream = myConsole.newMessageStream(); }
>> protected void log(String message) {
>> mConsoleStream.println(message);
>> }
>> }
>>
>> Also in case u need it, have added method to findConsole:
>>
>> public static MessageConsole findConsole(String name) {
>> ConsolePlugin plugin = ConsolePlugin.getDefault();
>> IConsoleManager conMan = plugin.getConsoleManager();
>> IConsole[] existing = conMan.getConsoles();
>> for (int i = 0; i < existing.length; i++)
>> if (name.equals(existing[i].getName()))
>> return (MessageConsole) existing[i];
>> //no console found, so create a new one
>> MessageConsole myConsole = new MessageConsole(name, null);
>> conMan.addConsoles(new IConsole[]{myConsole});
>> return myConsole;
>> }
>>
>> Hope this is what u need.
>>
>> -matt
>>
>>
>>
>>
>> Nima Mazloumi wrote:
>>
>>> Sorry, but I didn't understand how I can redirect the ant log to
>>> a console view.
>>
>>
>>
>>> Has someone experience with that?
>>
>>
>>
>>> This is what id do at the moment:
>>
>>
>>
>>> final AntRunner runner = new AntRunner();
>>> ....
>>> runner.setBuildFileLocation(buildFile.toString());
>>> ....
>>> runner.setMessageOutputLevel(verboseLevel);
>>> ....
>>> runner.setArguments(args);
>>> ....
>>> runner.run();
>>
>>
>>
>>> I know I can add my own logger with:
>>> runner.addBuildLogger("foo.FooLogger");
>>
>>
>>
>>> But how do I write out what ant logs into a console window?
>>
>>
>>
>>> Thanks,
>>> nima
>>
>>
>>
>>> Mark Ghodsian wrote:
>>>
>>>> Jared. Thank you so much! It worked like a charm. Here is the source
>>>> code
>>>> in case anyone else needs to accomplish the same time:
>>>>
>>>> /*
>>>> * Created on May 14, 2003
>>>> *
>>>> * To change the template for this generated file go to
>>>> * Window>Preferences>Java>Code Generation>Code and Comments
>>>> */
>>>> package bpelz.builders;
>>>>
>>>> import java.io.File;
>>>> import java.io.IOException;
>>>> import java.util.Map;
>>>> import java.util.StringTokenizer;
>>>>
>>>> import bpelz.bpelzPlugin;
>>>>
>>>> import org.eclipse.ant.core.AntRunner;
>>>> import org.eclipse.ant.internal.core.IAntCoreConstants;
>>>> import org.eclipse.core.resources.IFile;
>>>> import org.eclipse.core.resources.IProject;
>>>> import org.eclipse.core.resources.IncrementalProjectBuilder;
>>>> import org.eclipse.core.runtime.CoreException;
>>>> import org.eclipse.core.runtime.IProgressMonitor;
>>>> import org.eclipse.core.runtime.IStatus;
>>>> import org.eclipse.core.runtime.Status;
>>>> import org.eclipse.core.resources.IFile;
>>>> import org.eclipse.debug.core.DebugPlugin;
>>>> import org.eclipse.debug.core.ILaunchConfiguration;
>>>> import org.eclipse.debug.core.ILaunchConfigurationType;
>>>> import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
>>>> import org.eclipse.debug.core.ILaunchManager;
>>>> import org.eclipse.debug.ui.CommonTab;
>>>> import org.eclipse.debug.ui.DebugUITools;
>>>> import
>>>>
>> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchConfigurationMessages;
>>
>>
>>>> import
>>>>
>> org.eclipse.ui.externaltools.internal.ant.launchConfiguratio ns.AntLaunchShortcut;
>>
>>
>>>> import
>>>> org.eclipse.ui.externaltools.internal.model.IExternalToolCon stants;
>>>> import org.eclipse.ui.externaltools.internal.model.ToolUtil;
>>>> import
>>>> org.eclipse.ui.externaltools.internal.model.VariableContextM anager;
>>>>
>>>>
>>>> /**
>>>> * @author Edwin Khodabakchian
>>>> *
>>>> * To change the template for this generated type comment go to
>>>> * Window>Preferences>Java>Code Generation>Code and Comments
>>>> */
>>>> public class BPELBuilder extends IncrementalProjectBuilder {
>>>> private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
>>>> private static final int[] DEFAULT_BUILD_TYPES= new int[] {
>>>>
>>>> IncrementalProjectBuilder.INCREMENTAL_BUILD,
>>>>
>>>> IncrementalProjectBuilder.FULL_BUILD};
>>>>
>>>> public IProject[] build(int kind, Map args, IProgressMonitor
>>>> monitor)
>>>> throws CoreException {
>>>> try
>>>> {
>>>> System.out.println( ">>>>>>>>>>BUILDING>>>>>>>>>>>>");
>>>> // find build find within this project
>>>> IFile selectedFile = findBuildFile();
>>>> // Create a temporary launch configuration.
>>>> ILaunchConfiguration config = createDefaultConfig(
>>>> selectedFile );
>>>> boolean runTool = false;
>>>> int[] buildKinds =
>>>> buildTypesToArray( (String)config.getAttribute(
>>>>
>>>> IExternalToolConstants.ATTR_RUN_BUILD_KINDS, "")
>>>> ); //$NON-NLS-1$
>>>>
>>>> for (int i = 0; i < buildKinds.length; i++) {
>>>> if (kind == buildKinds[i]) {
>>>> runTool = true;
>>>> break;
>>>> }
>>>> }
>>>> if (!runTool)
>>>> return null;
>>>> // Mark the build as started
>>>>
>>>> VariableContextManager.getDefault().buildStarted(getProject( ),
>>>> kind);
>>>> // Launch the external ant tool
>>>> config.launch(ILaunchManager.RUN_MODE, null);
>>>> // Mark the build as completed
>>>> VariableContextManager.getDefault().buildEnded();
>>>> forgetLastBuiltState();
>>>>
>>>> System.out.println( "<<<<<<<<<<BUILDING<<<<<<<<<<<<<");
>>>> }
>>>> catch( Throwable t )
>>>> {
>>>> t.printStackTrace( );
>>>> }
>>>> return null;
>>>> }
>>>>
>>>> /**
>>>> * Creates and returns a default launch configuration for the given
>>>> file.
>>>> * * @param file
>>>> * @return default launch configuration
>>>> */
>>>> public static ILaunchConfiguration createDefaultConfig( IFile
>>>> file ) {
>>>>
>>>> ILaunchManager manager =
>>>> DebugPlugin.getDefault().getLaunchManager();
>>>> ILaunchConfigurationType type =
>>>> manager.getLaunchConfigurationType(
>>>>
>>>> IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
>>>> StringBuffer buffer = new
>>>> StringBuffer(file.getProject().getName());
>>>> buffer.append(" "); //$NON-NLS-1$
>>>> buffer.append( file.getName() );
>>>> String name = buffer.toString().trim();
>>>> name= manager.generateUniqueLaunchConfigurationNameFrom(
>>>> name );
>>>> try {
>>>> ILaunchConfigurationWorkingCopy workingCopy
>>>> = type.newInstance(null,
>>>> name);
>>>> StringBuffer buf = new StringBuffer();
>>>> ToolUtil.buildVariableTag(
>>>> IExternalToolConstants.VAR_WORKSPACE_LOC,
>>>>
>>>> file.getFullPath().toString(),
>>>> buf
>>>> );
>>>>
>>>> workingCopy.setAttribute( IExternalToolConstants.ATTR_LOCATION,
>>>> buf.toString()
>>>> );
>>>> // set default for common settings
>>>> CommonTab tab = new CommonTab();
>>>> tab.setDefaults( workingCopy );
>>>> tab.dispose();
>>>> return workingCopy;
>>>> } catch (Throwable t) {
>>>> System.out.println( "Error while creating the default
>>>> configuration" );
>>>> t.printStackTrace();
>>>> }
>>>> return null;
>>>> } /***
>>>> * Find the ant build file associated with this project. */
>>>> protected IFile findBuildFile()
>>>> {
>>>> IProject p = getProject();
>>>> return (IFile) p.findMember(
>>>> IAntCoreConstants.DEFAULT_BUILD_FILENAME );
>>>> }
>>>> protected void startupOnInitialize() {
>>>> System.out.println( ">>>>>>>>>>BUILD ON
>>>> INITIALIZE>>>>>>>>>>>>");
>>>> // builder init logic
>>>> }
>>>> /**
>>>> * Converts the build types string into an array of
>>>> * build kinds.
>>>> *
>>>> * @param buildTypes the string of built types to convert
>>>> * @return the array of build kinds.
>>>> */
>>>> public static int[] buildTypesToArray(String buildTypes) {
>>>> int count = 0;
>>>> boolean incremental = false;
>>>> boolean full = false;
>>>> boolean auto = false;
>>>> if (buildTypes == null || buildTypes.length() == 0) {
>>>> return DEFAULT_BUILD_TYPES;
>>>> }
>>>>
>>>> StringTokenizer tokenizer = new StringTokenizer(buildTypes,
>>>> BUILD_TYPE_SEPARATOR);
>>>> while (tokenizer.hasMoreTokens()) {
>>>> String token = tokenizer.nextToken();
>>>> if
>>>> (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token) ) {
>>>> if (!incremental) {
>>>> incremental = true;
>>>> count++;
>>>> }
>>>> }
>>>> else if
>>>> (IExternalToolConstants.BUILD_TYPE_FULL.equals(token))
>>>> {
>>>> if (!full) {
>>>> full = true;
>>>> count++;
>>>> }
>>>> }
>>>> else if
>>>> (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token))
>>>> {
>>>> if (!auto) {
>>>> auto = true;
>>>> count++;
>>>> }
>>>> }
>>>> }
>>>>
>>>> int[] results = new int[count];
>>>> count = 0;
>>>> if (incremental) {
>>>> results[count] =
>>>> IncrementalProjectBuilder.INCREMENTAL_BUILD;
>>>> count++;
>>>> }
>>>> if (full) {
>>>> results[count] = IncrementalProjectBuilder.FULL_BUILD;
>>>> count++;
>>>> }
>>>> if (auto) {
>>>> results[count] = IncrementalProjectBuilder.AUTO_BUILD;
>>>> count++;
>>>> }
>>>>
>>>> return results;
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Jared Burns wrote:
>>>>
>>>>
>>>>> ExternalToolBuilder is a builder that runs launch configs,
>>>>> including Ant configs. As you'll see in the build(...) method, it's
>>>>> passed the location of a launch config as an argument and just
>>>>> executes that config.
>>>>
>>>>
>>>>
>>>>
>>>>> - Jared
>>>>
>>>>
>>>>
>>>>
>>>>> Mark Ghodsian wrote:
>>>>
>>>>
>>>>
>>>>
>>>>>> Thank you for the insight. Would you happen to know if there are
>>>>>> examples
>>>>>> out there on how to leverage the AntLaunchDelegate or the
>>>>>> AntLaunchShortcut from within a builder?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
Previous Topic:[RCP] Reuse running instance of eclipse
Next Topic:Startup issue occurred from M6 to RC1
Goto Forum:
  


Current Time: Wed May 14 05:03:59 EDT 2025

Powered by FUDForum. Page generated in 0.09440 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top