diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/CloudToolsEclipseProjectUpdater.java b/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/CloudToolsEclipseProjectUpdater.java index 134e2934ae..3d84dbbbc1 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/CloudToolsEclipseProjectUpdater.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/CloudToolsEclipseProjectUpdater.java @@ -106,8 +106,6 @@ public static IStatus updateProject(IProject project, SubMonitor progress) { } progress.worked(5); - // remove "appengine-api" as appengine-api-1.0-sdk now included in the servlet container - libraryIds.remove("appengine-api"); //$NON-NLS-1$ // remove "googlecloudcore" and "googleapiclient" as they were utility definitions, now // pulled from library dependencies libraryIds.remove("googlecloudcore"); //$NON-NLS-1$ diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/UpdateCloudToolsEclipseProjectHandler.java b/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/UpdateCloudToolsEclipseProjectHandler.java index 8a51ef6030..986d319455 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/UpdateCloudToolsEclipseProjectHandler.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.compat/src/com/google/cloud/tools/eclipse/appengine/compat/cte13/UpdateCloudToolsEclipseProjectHandler.java @@ -18,7 +18,6 @@ import com.google.cloud.tools.eclipse.appengine.compat.Messages; import com.google.cloud.tools.eclipse.ui.util.ProjectFromSelectionHelper; -import java.text.MessageFormat; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -34,11 +33,12 @@ public class UpdateCloudToolsEclipseProjectHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - final IProject project = ProjectFromSelectionHelper.getFirstProject(event); + IProject project = ProjectFromSelectionHelper.getFirstProject(event); if (!CloudToolsEclipseProjectUpdater.hasOldContainers(project)) { throw new ExecutionException(Messages.getString("project.appears.up.to.date")); //$NON-NLS-1$ } - Job updateJob = new WorkspaceJob(MessageFormat.format(Messages.getString("updating.project"), project.getName())) { //$NON-NLS-1$ + String jobName = Messages.getString("updating.project", project.getName()); //$NON-NLS-1$ + Job updateJob = new WorkspaceJob(jobName) { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { return CloudToolsEclipseProjectUpdater.updateProject(project, SubMonitor.convert(monitor)); diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/launching/LaunchHelper.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/launching/LaunchHelper.java index 84dad4c0db..929393901c 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/launching/LaunchHelper.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/launching/LaunchHelper.java @@ -25,7 +25,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.collect.Sets.SetView; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -65,9 +64,10 @@ public void launch(IModule[] modules, String launchMode) throws CoreException { if (isRunning(existing)) { ILaunch launch = existing.getLaunch(); Preconditions.checkNotNull(launch, "A running server should have a launch"); //$NON-NLS-1$ - String detail = launchMode.equals(launch.getLaunchMode()) ? Messages.getString("SERVER_ALREADY_RUNNING") //$NON-NLS-1$ - : MessageFormat.format(Messages.getString("SERVER_ALREADY_RUNNING_IN_MODE"), //$NON-NLS-1$ - launch.getLaunchMode()); + String detail = launchMode.equals(launch.getLaunchMode()) + ? Messages.getString("SERVER_ALREADY_RUNNING") //$NON-NLS-1$ + : Messages.getString( + "SERVER_ALREADY_RUNNING_IN_MODE", launch.getLaunchMode()); //$NON-NLS-1$ throw new CoreException(StatusUtil.info(this, detail)); } server = existing; diff --git a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/ImportNativeAppEngineStandardProjectTest.java b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/ImportNativeAppEngineStandardProjectTest.java index 5c2d2f8764..5fc90e841a 100644 --- a/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/ImportNativeAppEngineStandardProjectTest.java +++ b/plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/ImportNativeAppEngineStandardProjectTest.java @@ -34,10 +34,12 @@ import java.io.IOException; import java.net.URL; import java.util.concurrent.TimeUnit; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jdt.core.IClasspathContainer; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; @@ -63,7 +65,7 @@ public class ImportNativeAppEngineStandardProjectTest extends BaseProjectTest { public TemporaryFolder tempFolder = new TemporaryFolder(); @Test - public void importAppEngineStandardJava7_from1_3_1() throws IOException, CoreException { + public void testImportAppEngineStandardJava7_from1_3_1() throws IOException, CoreException { assertFalse(projectExists("AESv7")); ZipUtil.extractZip(new URL( "platform:/plugin/com.google.cloud.tools.eclipse.integration.appengine/test-projects/cte-1_3_1-appengine-standard-java7.zip"), @@ -71,10 +73,7 @@ public void importAppEngineStandardJava7_from1_3_1() throws IOException, CoreExc project = SwtBotAppEngineActions.importNativeProject(bot, "AESv7", tempFolder.getRoot()); assertTrue(project.exists()); - updateOldContainers(); - - ProjectUtils.waitForProjects(project); - ProjectUtils.waitUntilNoBuildErrors(project); + updateOldContainers(project); IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("should be a faceted project", facetedProject); @@ -90,7 +89,7 @@ public void importAppEngineStandardJava7_from1_3_1() throws IOException, CoreExc } @Test - public void importAppEngineStandardJava8_from1_3_1() throws IOException, CoreException { + public void testImportAppEngineStandardJava8_from1_3_1() throws IOException, CoreException { Assume.assumeTrue(JavaRuntimeUtils.hasJavaSE8()); assertFalse(projectExists("AESv8")); ZipUtil.extractZip(new URL( @@ -99,10 +98,7 @@ public void importAppEngineStandardJava8_from1_3_1() throws IOException, CoreExc project = SwtBotAppEngineActions.importNativeProject(bot, "AESv8", tempFolder.getRoot()); assertTrue(project.exists()); - updateOldContainers(); - - ProjectUtils.waitForProjects(project); - ProjectUtils.waitUntilNoBuildErrors(project); + updateOldContainers(project); IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("should be a faceted project", facetedProject); @@ -117,10 +113,44 @@ public void importAppEngineStandardJava8_from1_3_1() throws IOException, CoreExc facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET)); } - private void updateOldContainers() throws JavaModelException { + // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/3202 + @Test + public void testImportProjectFrom131_oldStyleContainerWithAppEngineApi() + throws IOException, CoreException { + assertFalse(projectExists("old-library-container-with-appengine-api")); + ZipUtil.extractZip(new URL( + "platform:/plugin/com.google.cloud.tools.eclipse.integration.appengine/test-projects/old-library-container-with-appengine-api.zip"), + tempFolder.getRoot()); + project = SwtBotAppEngineActions.importNativeProject( + bot, "old-library-container-with-appengine-api", tempFolder.getRoot()); + assertTrue(project.exists()); + + updateOldContainers(project); + + assertTrue(hasAppEngineApi(project)); + } + + private static boolean hasAppEngineApi(IProject project) throws JavaModelException { + IJavaProject javaProject = JavaCore.create(project); + IClasspathContainer masterContainer = + JavaCore.getClasspathContainer(BuildPath.MASTER_CONTAINER_PATH, javaProject); + + for (IClasspathEntry entry : masterContainer.getClasspathEntries()) { + if (entry.getPath().lastSegment().startsWith("appengine-api-1.0-sdk")) { + return true; + } + } + return false; + } + + private static void updateOldContainers(IProject project) throws CoreException { assertTrue(CloudToolsEclipseProjectUpdater.hasOldContainers(project)); IStatus updateStatus = CloudToolsEclipseProjectUpdater.updateProject(project, SubMonitor.convert(null)); + + ProjectUtils.waitForProjects(project); + ProjectUtils.waitUntilNoBuildErrors(project); + assertTrue("Update failed: " + updateStatus.getMessage(), updateStatus.isOK()); assertFalse(CloudToolsEclipseProjectUpdater.hasOldContainers(project)); diff --git a/plugins/com.google.cloud.tools.eclipse.integration.appengine/test-projects/old-library-container-with-appengine-api.zip b/plugins/com.google.cloud.tools.eclipse.integration.appengine/test-projects/old-library-container-with-appengine-api.zip new file mode 100644 index 0000000000..447c7203fa Binary files /dev/null and b/plugins/com.google.cloud.tools.eclipse.integration.appengine/test-projects/old-library-container-with-appengine-api.zip differ