You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/08/16 15:05:44 UTC
svn commit: r1514690 -
/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
Author: pkluegl
Date: Fri Aug 16 13:05:44 2013
New Revision: 1514690
URL: http://svn.apache.org/r1514690
Log:
UIMA-3136
- some refactoring
Modified:
uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java?rev=1514690&r1=1514689&r2=1514690&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/launching/RutaLaunchConfigurationDelegate.java Fri Aug 16 13:05:44 2013
@@ -84,8 +84,7 @@ public class RutaLaunchConfigurationDele
IPreferenceStore preferenceStore = RutaIdeUIPlugin.getDefault().getPreferenceStore();
boolean addSDI = preferenceStore.getBoolean(RutaCorePreferences.ADD_SDI);
-
-
+
IResource member = proj.getProject().findMember(mainScriptAttribute);
IPath projectPath = proj.getResource().getLocation();
IPath inputDirPath = projectPath.append(RutaProjectUtils.getDefaultInputLocation());
@@ -126,7 +125,7 @@ public class RutaLaunchConfigurationDele
cmdline.append(RutaLaunchConstants.ARG_ADD_SDI + " ");
cmdline.append(addSDI + " ");
-
+
return cmdline.toString();
}
@@ -159,76 +158,43 @@ public class RutaLaunchConfigurationDele
public static List<String> getClassPath(IScriptProject project) throws CoreException {
RutaIdeUIPlugin d = RutaIdeUIPlugin.getDefault();
List<String> extendedClasspath = new ArrayList<String>();
+
// Normal mode, add the launcher plugin and uima runtime jar to the classpath
- if (!Platform.inDevelopmentMode()) {
- try {
+ try {
+ if (!Platform.inDevelopmentMode()) {
// Add this plugin jar to the classpath
extendedClasspath.add(d.pluginIdToJarPath(RutaIdeUIPlugin.PLUGIN_ID));
+ } else {
+ extendedClasspath.add(d.pluginIdToJarPath(RutaIdeUIPlugin.PLUGIN_ID) + "target/classes");
+ }
- // UIMA jar should be added the end of the class path, because user uima jars
- // (maybe a different version) should appear first on the class path
- extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
- extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.ruta.engine"));
-
- // for inlined jars?
- Bundle bundle = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.runtime");
- if (bundle != null) {
- Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
- if (jarEnum == null) {
- extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
- }
- while (jarEnum != null && jarEnum.hasMoreElements()) {
- URL element = (URL) jarEnum.nextElement();
- extendedClasspath.add(FileLocator.toFileURL(element).getFile());
- }
- }
-
- Bundle bundle2 = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.ruta.engine");
- if (bundle2 != null) {
- Enumeration<?> jarEnum = bundle2.findEntries("/", "*.jar", true);
- while (jarEnum != null && jarEnum.hasMoreElements()) {
- URL element = (URL) jarEnum.nextElement();
- extendedClasspath.add(FileLocator.toFileURL(element).getFile());
- }
+ // uima
+ Bundle bundle = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.runtime");
+ if (bundle != null) {
+ Enumeration<?> jarEnum = bundle.findEntries("/", "uimaj-core*.jar",
+ Platform.inDevelopmentMode());
+ while (jarEnum != null && jarEnum.hasMoreElements()) {
+ URL element = (URL) jarEnum.nextElement();
+ extendedClasspath.add(FileLocator.toFileURL(element).getFile());
}
-
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, RutaIdeUIPlugin.PLUGIN_ID, IStatus.OK,
- "Failed to compose classpath!", e));
}
- }
- // When running inside eclipse with PDE in development mode the plugins
- // are not installed inform of jar files and the classes must be loaded
- // from the target/classes folder or target/org.apache.uima.runtime.*.jar file
- else {
- try {
- extendedClasspath.add(d.pluginIdToJarPath(RutaIdeUIPlugin.PLUGIN_ID) + "target/classes");
- Bundle bundle = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.runtime");
- if (bundle != null) {
- Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
- if (jarEnum == null) {
- extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
- }
- while (jarEnum != null && jarEnum.hasMoreElements()) {
- URL element = (URL) jarEnum.nextElement();
- extendedClasspath.add(FileLocator.toFileURL(element).getFile());
- }
- }
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
- Bundle bundle2 = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.ruta.engine");
- if (bundle2 != null) {
- Enumeration<?> jarEnum = bundle2.findEntries("/", "*.jar", true);
- while (jarEnum != null && jarEnum.hasMoreElements()) {
- URL element = (URL) jarEnum.nextElement();
- extendedClasspath.add(FileLocator.toFileURL(element).getFile());
- }
+ // ruta
+ bundle = RutaIdeUIPlugin.getDefault().getBundle("org.apache.uima.ruta.engine");
+ if (bundle != null) {
+ Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", Platform.inDevelopmentMode());
+ while (jarEnum != null && jarEnum.hasMoreElements()) {
+ URL element = (URL) jarEnum.nextElement();
+ extendedClasspath.add(FileLocator.toFileURL(element).getFile());
}
-
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, RutaIdeUIPlugin.PLUGIN_ID, IStatus.OK,
- "Failed to compose classpath!", e));
}
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.ruta.engine"));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, RutaIdeUIPlugin.PLUGIN_ID, IStatus.OK,
+ "Failed to compose classpath!", e));
}
+
Collection<String> dependencies = getDependencies(project.getProject());
extendedClasspath.addAll(dependencies);
@@ -240,8 +206,15 @@ public class RutaLaunchConfigurationDele
private static Collection<String> getExtensions() throws CoreException {
RutaIdeUIPlugin d = RutaIdeUIPlugin.getDefault();
Collection<String> result = new TreeSet<String>();
- IExtension[] extensions = Platform.getExtensionRegistry()
+ IExtension[] extensions = null;
+ extensions = Platform.getExtensionRegistry()
.getExtensionPoint(RutaIdeUIPlugin.PLUGIN_ID, "actionExtension").getExtensions();
+ extensionToClassPath(d, result, extensions);
+ return result;
+ }
+
+ private static void extensionToClassPath(RutaIdeUIPlugin d, Collection<String> result,
+ IExtension[] extensions) throws CoreException {
for (IExtension each : extensions) {
String namespaceIdentifier = each.getNamespaceIdentifier();
try {
@@ -256,18 +229,16 @@ public class RutaLaunchConfigurationDele
"Failed to extend classpath with " + namespaceIdentifier + "!", e));
}
}
- return result;
}
- private static Collection<String> getDependencies(IProject project)
- throws CoreException {
+ private static Collection<String> getDependencies(IProject project) throws CoreException {
Collection<String> result = new TreeSet<String>();
IProject[] referencedProjects = project.getReferencedProjects();
for (IProject eachProject : referencedProjects) {
// for each java project
extendClasspathWithProject(result, eachProject, new HashSet<IProject>());
IProjectNature nature = eachProject.getNature(RutaNature.NATURE_ID);
- if(nature != null) {
+ if (nature != null) {
result.addAll(getDependencies(eachProject));
}
}
@@ -337,7 +308,7 @@ public class RutaLaunchConfigurationDele
}
}
boolean recursive = configuration.getAttribute(RutaLaunchConstants.RECURSIVE, false);
- if(ouputFolder != null) {
+ if (ouputFolder != null) {
clearOutputFolder(new File(ouputFolder.getLocation().toPortableString()), recursive);
}