Author: Grid.Qian
Date: 2008-11-14 02:20:12 -0500 (Fri, 14 Nov 2008)
New Revision: 11781
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
Log:
JBIDE-3195:remove the generated output folder from AS/bin folder
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-11-14
06:49:46 UTC (rev 11780)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-11-14
07:20:12 UTC (rev 11781)
@@ -16,6 +16,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.jboss.tools.ws.core.utils.StatusUtils;
@@ -24,92 +26,106 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
-abstract class AbstractGenerateCodeCommand extends AbstractDataModelOperation{
+abstract class AbstractGenerateCodeCommand extends AbstractDataModelOperation {
protected ServiceModel model;
- private String cmdFileName_linux;
- private String cmdFileName_win;
+ private String cmdFileName_linux;
+ private String cmdFileName_win;
-
- public AbstractGenerateCodeCommand(ServiceModel model){
+ public AbstractGenerateCodeCommand(ServiceModel model) {
this.model = model;
cmdFileName_linux = getCommandLineFileName_linux();
cmdFileName_win = getCommandLineFileName_win();
}
-
+
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
IStatus status = Status.OK_STATUS;
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(model
- .getWebProjectName());
-
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ model.getWebProjectName());
+
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(
+ model.getWebProjectName()).toOSString();
+ IJavaProject javaProject = JavaCore.create(project);
try {
- String runtimeLocation = JBossWSCreationUtils.getJBossWSRuntimeLocation(project);
- String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
+ String runtimeLocation = JBossWSCreationUtils
+ .getJBossWSRuntimeLocation(project);
+ String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
IPath path = new Path(commandLocation);
- String command = "sh " + cmdFileName_linux;
- if(System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0){
- command = "cmd.exe /c " + cmdFileName_win;
+ StringBuffer command = new StringBuffer();
+ if (System.getProperty("os.name").toLowerCase().indexOf("win")
>= 0) {
+ command.append("cmd.exe /c ").append(cmdFileName_win);
path = path.append(cmdFileName_win);
- }else{
+ } else {
+ command.append("sh ").append(cmdFileName_linux);
path = path.append(cmdFileName_linux);
}
-
- if(!path.toFile().getAbsoluteFile().exists()){
- return StatusUtils.errorStatus(
- NLS.bind(JBossWSCreationCoreMessages.Error_Message_Command_File_Not_Found,
- new String[] {path.toOSString()}));
+
+ if (!path.toFile().getAbsoluteFile().exists()) {
+ return StatusUtils
+ .errorStatus(NLS
+ .bind(
+ JBossWSCreationCoreMessages.Error_Message_Command_File_Not_Found,
+ new String[] { path.toOSString() }));
}
-
- String args = getCommandlineArgs();
- command += " -k " + args + " " + model.getWsdlURI();
+
+ String args = getCommandlineArgs();
+ command.append(" -k ").append(args).append(" ");
+ if(model.getWsdlURI() != null){
+ command.append(model.getWsdlURI());
+ }
+ command.append(" -o ").append(projectRoot).append(Path.SEPARATOR)
+ .append(
+ javaProject.getOutputLocation()
+ .removeFirstSegments(1).toOSString());
Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(command, null, new File(commandLocation));
- StringBuffer errorResult = new StringBuffer();
- StringBuffer inputResult = new StringBuffer();
-
- convertInputStreamToString(errorResult, proc.getErrorStream());
- convertInputStreamToString(inputResult, proc.getInputStream());
-
- int exitValue = proc.waitFor();
-
- if(exitValue != 0){
- return StatusUtils.errorStatus(errorResult.toString());
- }else{
- String resultInput = inputResult.toString();
- if(resultInput != null &&
resultInput.indexOf("[ERROR]") >= 0){
- JBossWSCreationCore.getDefault().logError(resultInput);
- IStatus errorStatus = StatusUtils.errorStatus(resultInput);
- status = StatusUtils
- .errorStatus(
- JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
- new CoreException(errorStatus));
- }else{
- JBossWSCreationCore.getDefault().logInfo(resultInput);
- }
- }
-
+ Process proc = rt.exec(command.toString(), null, new File(
+ commandLocation));
+ StringBuffer errorResult = new StringBuffer();
+ StringBuffer inputResult = new StringBuffer();
+
+ convertInputStreamToString(errorResult, proc.getErrorStream());
+ convertInputStreamToString(inputResult, proc.getInputStream());
+
+ int exitValue = proc.waitFor();
+
+ if (exitValue != 0) {
+ return StatusUtils.errorStatus(errorResult.toString());
+ } else {
+ String resultInput = inputResult.toString();
+ if (resultInput != null && resultInput.indexOf("[ERROR]") >= 0)
{
+ JBossWSCreationCore.getDefault().logError(resultInput);
+ IStatus errorStatus = StatusUtils.errorStatus(resultInput);
+ status = StatusUtils
+ .errorStatus(
+ JBossWSCreationCoreMessages.Error_Message_Failed_To_Generate_Code,
+ new CoreException(errorStatus));
+ } else {
+ JBossWSCreationCore.getDefault().logInfo(resultInput);
+ }
+ }
+
} catch (IOException e) {
JBossWSCreationCore.getDefault().logError(e);
-
+
} catch (InterruptedException e) {
- // ignore
- } catch (CoreException e) {
+ // ignore
+ } catch (CoreException e) {
JBossWSCreationCore.getDefault().logError(e);
- //unable to get runtime location
+ // unable to get runtime location
return e.getStatus();
}
-
+
refreshProject(model.getWebProjectName(), monitor);
-
-
+
return status;
}
-
- private void convertInputStreamToString(final StringBuffer result, final InputStream
input) {
+ private void convertInputStreamToString(final StringBuffer result,
+ final InputStream input) {
+
Thread thread = new Thread() {
public void run() {
@@ -129,25 +145,25 @@
}
};
-
+
thread.start();
}
-
- private void refreshProject(String project, IProgressMonitor monitor){
+
+ private void refreshProject(String project, IProgressMonitor monitor) {
try {
- JBossWSCreationUtils.getProjectByName(project).refreshLocal(2, monitor);
+ JBossWSCreationUtils.getProjectByName(project).refreshLocal(2,
+ monitor);
} catch (CoreException e) {
e.printStackTrace();
JBossWSCreationCore.getDefault().logError(e);
}
}
-
+
abstract protected String getCommandlineArgs();
-
+
abstract protected String getCommandLineFileName_linux();
+
abstract protected String getCommandLineFileName_win();
-
-
}
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2008-11-14
06:49:46 UTC (rev 11780)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/WSProviderInvokeCommand.java 2008-11-14
07:20:12 UTC (rev 11781)
@@ -62,12 +62,12 @@
seperator = SEPERATOR_LINUX;
}
StringBuffer commandLine = new StringBuffer();
- String project = model.getWebProjectName();
- String projectRoot = JBossWSCreationUtils.getProjectRoot(project)
+ String projectName = model.getWebProjectName();
+ String projectRoot = JBossWSCreationUtils.getProjectRoot(projectName)
.toOSString();
IProject iProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(project);
+ .getProject(projectName);
IJavaProject javaProject = JavaCore.create(iProject);
commandLine.append(" -s ").append(projectRoot).append(Path.SEPARATOR)
@@ -80,10 +80,6 @@
javaProject.getOutputLocation().removeFirstSegments(1)
.toOSString()).append(seperator);
commandLine.append(getClasspathEntries(javaProject)).append("\" ");
- commandLine.append(" -o ").append(projectRoot).append(
- Path.SEPARATOR).append(
- javaProject.getOutputLocation().removeFirstSegments(1)
- .toOSString());
} catch (JavaModelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Show replies by date