You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by jr...@apache.org on 2003/04/23 12:01:28 UTC
cvs commit: jakarta-cactus/integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant AntContainerProvider.java AntContainerManager.java
jruaux 2003/04/23 03:01:28
Modified: integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant
AntContainerProvider.java AntContainerManager.java
Log:
Modified the Ant build launch mechanism, now logs to the console
Revision Changes Path
1.2 +31 -15 jakarta-cactus/integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant/AntContainerProvider.java
Index: AntContainerProvider.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant/AntContainerProvider.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AntContainerProvider.java 21 Mar 2003 16:38:11 -0000 1.1
+++ AntContainerProvider.java 23 Apr 2003 10:01:27 -0000 1.2
@@ -63,10 +63,13 @@
import org.apache.cactus.eclipse.runner.containers.Credential;
import org.apache.cactus.eclipse.runner.containers.IContainerProvider;
import org.apache.cactus.eclipse.runner.ui.CactusMessages;
-import org.eclipse.ant.core.AntRunner;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
/**
* Implementation of IContainerProvider that uses ant scripts to set up
@@ -102,6 +105,10 @@
* The Ant target mask for this provider, for example "tomcat4x".
*/
private String targetMask;
+ /**
+ * Reference to the launch created to start the container.
+ */
+ private ILaunch startLaunch;
/**
* @param theManager the manager of this provider
@@ -140,15 +147,21 @@
public void start(ContainerInfo theContainerInfo, IProgressMonitor thePM)
throws CoreException
{
+ ILaunchManager launchManager =
+ DebugPlugin.getDefault().getLaunchManager();
+
thePM.subTask(CactusMessages.getString("CactusLaunch.message.start"));
String target = getTarget("cactus.run.");
+ antArguments.add(
+ "-Dcactus.test.task=" + EclipseRunTests.class.getName());
antArguments.add("-Dcactus.home." + this.targetMask + "=" + home);
String[] arguments =
(String[]) antArguments.toArray(new String[antArguments.size()]);
- AntRunner runner = this.manager.createAntRunner(arguments, target);
- serverStopped = false;
- runner.run(new SubProgressMonitor(thePM, 8));
- serverStopped = true;
+ ILaunchConfigurationWorkingCopy antCopy =
+ this.manager.createAntLaunchConfiguration(arguments, target);
+ this.startLaunch = antCopy.launch(
+ ILaunchManager.RUN_MODE,
+ new SubProgressMonitor(thePM, 8));
}
/**
@@ -161,18 +174,19 @@
if (eclipseRunner != null)
{
eclipseRunner.finish();
- thePM.worked(30);
- while (!serverStopped)
+ try
{
- try
+ thePM.worked(30);
+ while (!this.startLaunch.isTerminated())
{
+
Thread.sleep(300);
thePM.worked(7);
}
- catch (InterruptedException e)
- {
- // Do nothing
- }
+ }
+ catch (InterruptedException e)
+ {
+ // Do nothing
}
}
}
@@ -191,8 +205,10 @@
String antTarget = getTarget("cactus.clean.");
String[] arguments =
(String[]) antArguments.toArray(new String[antArguments.size()]);
- AntRunner runner = this.manager.createAntRunner(arguments, antTarget);
- runner.run(
+ ILaunchConfigurationWorkingCopy antCopy =
+ this.manager.createAntLaunchConfiguration(arguments, antTarget);
+ antCopy.launch(
+ ILaunchManager.RUN_MODE,
new SubProgressMonitor(thePM, 50));
}
1.9 +56 -13 jakarta-cactus/integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant/AntContainerManager.java
Index: AntContainerManager.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/integration/eclipse/org.apache.cactus.eclipse.runner/src/java/org/apache/cactus/eclipse/runner/containers/ant/AntContainerManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AntContainerManager.java 16 Apr 2003 10:48:43 -0000 1.8
+++ AntContainerManager.java 23 Apr 2003 10:01:27 -0000 1.9
@@ -68,17 +68,21 @@
import org.apache.cactus.eclipse.runner.ui.CactusMessages;
import org.apache.cactus.eclipse.runner.ui.CactusPlugin;
import org.apache.cactus.eclipse.webapp.WarBuilder;
-import org.eclipse.ant.core.AntRunner;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
/**
* Implementation of IContainerManager based on Ant.
@@ -90,6 +94,11 @@
public class AntContainerManager implements IContainerManager
{
/**
+ * The progress monitor associated with the current action.
+ */
+ private IProgressMonitor currentPM;
+
+ /**
* True if the provider has successfully been deployed.
*/
private boolean stateProviderDeployed = false;
@@ -201,7 +210,6 @@
this.containerHomes = theHomes;
antArguments.add("-Dcactus.port=" + thePort);
antArguments.add("-Dcactus.target.dir=" + theTargetDir);
- antArguments.add("-Dcactus.test.runeclipse=" + "true");
// Avoid Ant console popups on win32 platforms
if (BootLoader.getOS().equals(BootLoader.OS_WIN32))
{
@@ -231,19 +239,17 @@
}
/**
- * returns an AntRunner for a container provider.
- * @param theTarget the ant target to be called (in that order)
+ * @param theTarget the Ant target to be called
* @param theProviderArguments the Ant arguments specific for
* the container provider
- * @return the AntRunner for the script
- * @throws CoreException if an AntRunner cannot be created
+ * @return a launch configuration copy for Ant build
+ * @throws CoreException if the launch configuration cannot be created
*/
- public AntRunner createAntRunner(
+ public ILaunchConfigurationWorkingCopy createAntLaunchConfiguration(
String[] theProviderArguments,
String theTarget)
throws CoreException
{
- AntRunner runner = new AntRunner();
CactusPlugin thePlugin = CactusPlugin.getDefault();
URL buildFileURL = thePlugin.find(new Path(buildFilePath));
if (buildFileURL == null)
@@ -254,10 +260,46 @@
null);
}
File buildFileLocation = new File(buildFileURL.getPath());
- runner.setBuildFileLocation(buildFileLocation.getAbsolutePath());
- runner.setArguments(getAllAntArguments(theProviderArguments));
- runner.setExecutionTargets(new String[] {theTarget});
- return runner;
+
+ ILaunchManager launchManager =
+ DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType antType =
+ launchManager.getLaunchConfigurationType(
+ IExternalToolConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
+
+ String name = "Cactus container start-up";
+ String uniqueName =
+ launchManager.generateUniqueLaunchConfigurationNameFrom(name);
+ ILaunchConfigurationWorkingCopy antConfig =
+ antType.newInstance(null, uniqueName);
+
+ antConfig.setAttribute(
+ IExternalToolConstants.ATTR_LOCATION,
+ buildFileLocation.getAbsolutePath());
+ antConfig.setAttribute(
+ IExternalToolConstants.ATTR_TOOL_ARGUMENTS,
+ getString(getAllAntArguments(theProviderArguments)));
+ antConfig.setAttribute(
+ IExternalToolConstants.ATTR_ANT_TARGETS,
+ theTarget);
+ antConfig.setAttribute(
+ IExternalToolConstants.ATTR_RUN_IN_BACKGROUND,
+ false);
+ return antConfig;
+ }
+
+ /**
+ * @param theStringArray an array of String
+ * @return the concatenation of the String elements
+ */
+ private String getString(String[] theStringArray)
+ {
+ String result = "";
+ for (int i = 0; i < theStringArray.length; i++)
+ {
+ result += theStringArray[i] + " ";
+ }
+ return result;
}
/**
@@ -364,6 +406,7 @@
IContainerProvider theProvider)
throws CoreException
{
+ this.currentPM = thePM;
thePM.beginTask(
CactusMessages.getString("CactusLaunch.message.prepare"),
10);
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org