summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-04 13:31:07 (EDT)
committerpelder2007-05-04 13:31:07 (EDT)
commitc8c4bdf05b783a3421b5fd778c237c0df606db68 (patch)
treef39d6818c7c06b2b94312a6deb4ab3570c1087d0
parenta107a714410cf34e31a1b78732bfc804f4802605 (diff)
downloadorg.eclipse.jet-c8c4bdf05b783a3421b5fd778c237c0df606db68.zip
org.eclipse.jet-c8c4bdf05b783a3421b5fd778c237c0df606db68.tar.gz
org.eclipse.jet-c8c4bdf05b783a3421b5fd778c237c0df606db68.tar.bz2
[183457] Avoid IJob.join, and use IWorkspace.build() or IProject.build() to ensure JET projects are properly built before launch.
-rw-r--r--plugins/org.eclipse.jet/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java44
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java21
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java33
4 files changed, 46 insertions, 54 deletions
diff --git a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
index 7806675..90857d4 100644
--- a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet;singleton:=true
-Bundle-Version: 0.7.2.qualifier
+Bundle-Version: 0.7.3.qualifier
Bundle-Activator: org.eclipse.jet.internal.InternalJET2Platform
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ant.core;bundle-version="[3.1.100,4.0.0)",
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
index a06f78c..7d43d85 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,18 +33,16 @@ import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.internal.InternalJET2Platform;
import org.eclipse.jet.internal.extensionpoints.TransformData;
import org.eclipse.jet.internal.extensionpoints.TransformDataFactory;
-import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.transform.IJETBundleDescriptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -279,7 +277,7 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
ProjectJETBundleDescriptor descriptor = (ProjectJETBundleDescriptor)getDescriptor(id);
if (descriptor != null)
{
- if (ensureProjectIsBuilt(monitor))
+ if (ensureProjectIsBuilt(descriptor.getProjectName(), monitor))
{
bundle = InternalJET2Platform.getDefault().getJETBundleInstaller().installBundle(descriptor.getBaseURL());
}
@@ -297,34 +295,20 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
}
}
- /**
- * @param monitor
- */
- private boolean ensureProjectIsBuilt(IProgressMonitor monitor)
- {
- boolean built = true;
- // wait for in-progress auto-build to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] build = jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD);
- if (build.length == 1)
+ private boolean ensureProjectIsBuilt(String name, IProgressMonitor monitor) {
+ try
{
- monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
- try
- {
- build[0].join();
- }
- catch (InterruptedException e)
- {
- built = false;
- }
- finally
- {
- monitor.done();
- }
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ return true;
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ return false;
}
- return built;
}
-
+
public void unload(Bundle bundle) throws BundleException
{
if(bundle != null)
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
index 86bb471..7e9e7b8 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,9 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.codegen.util.ImportManager;
@@ -96,7 +98,8 @@ public class JavaActionsUtil
if (jElementForFolder == null)
{
// checkpoint the workspace (inform the builders) of our changes to date...
- ActionsUtil.checkpointWorkspace(true, new NullProgressMonitor());
+ ActionsUtil.checkpointWorkspace(false, new NullProgressMonitor());
+ buildProject(sourceFolder.segment(0));
// and try again...
jElementForFolder = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(sourceFolder));
}
@@ -134,6 +137,20 @@ public class JavaActionsUtil
}
return result;
}
+
+ private static void buildProject(String projectName)
+ {
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ try
+ {
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
+ }
+ catch (CoreException e)
+ {
+ //e.printStackTrace();
+ }
+ }
+
/**
* Find the a container corresponding the the given package in the specified project.
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
index 55f4e1d..3cf02e6 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,16 +34,14 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.taglib.JET2TagException;
@@ -570,24 +568,17 @@ public final class ActionsUtil
private static void waitForBuildToComplete(IProgressMonitor monitor)
{
- // wait for in-progress auto-build to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] build = jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD);
- if (build.length == 1)
+ monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
+ try
{
- monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
- try
- {
- build[0].join();
- }
- catch (InterruptedException e)
- {
- // nothing to do, continue...
- }
- finally
- {
- monitor.done();
- }
+ ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ }
+ finally {
+ monitor.done();
}
}