diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.facets/src/com/google/cloud/tools/eclipse/appengine/facets/AppEngineSdkClasspathContainer.java b/plugins/com.google.cloud.tools.eclipse.appengine.facets/src/com/google/cloud/tools/eclipse/appengine/facets/AppEngineSdkClasspathContainer.java index 92cd881540..068237a3d6 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.facets/src/com/google/cloud/tools/eclipse/appengine/facets/AppEngineSdkClasspathContainer.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.facets/src/com/google/cloud/tools/eclipse/appengine/facets/AppEngineSdkClasspathContainer.java @@ -1,6 +1,6 @@ package com.google.cloud.tools.eclipse.appengine.facets; -import java.io.File; +import java.nio.file.Files; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -13,7 +13,6 @@ public final class AppEngineSdkClasspathContainer implements IClasspathContainer { - private static final CloudSdk CLOUD_SDK = new CloudSdkProvider().getCloudSdk(); public static final String CONTAINER_ID = "AppEngineSDK"; @Override @@ -33,12 +32,12 @@ public String getDescription() { @Override public IClasspathEntry[] getClasspathEntries() { - if (CLOUD_SDK.getJavaAppEngineSdkPath() != null) { - File jarFile = CLOUD_SDK.getJavaToolsJar().toFile(); - if (jarFile.exists()) { - String appEngineToolsApiJar = jarFile.getPath(); + CloudSdk cloudSdk = new CloudSdkProvider().getCloudSdk(); + if (cloudSdk.getJavaAppEngineSdkPath() != null) { + java.nio.file.Path jarFile = cloudSdk.getJavaToolsJar(); + if (Files.exists(jarFile)) { IClasspathEntry appEngineToolsEntry = - JavaCore.newLibraryEntry(new Path(appEngineToolsApiJar), + JavaCore.newLibraryEntry(new Path(jarFile.toString()), null /* sourceAttachmentPath */, null /* sourceAttachmentRootPath */, true /* isExported */); diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ServletClasspathProvider.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ServletClasspathProvider.java index a732eae0e4..60299a4c15 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ServletClasspathProvider.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ServletClasspathProvider.java @@ -25,17 +25,18 @@ public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime ru return new IClasspathEntry[0]; } else { return resolveClasspathContainer(runtime); - } + } } @Override public IClasspathEntry[] resolveClasspathContainer(IRuntime runtime) { - java.nio.file.Path cloudSdkPath = new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath(); + java.nio.file.Path cloudSdkPath = + new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath(); if (cloudSdkPath == null) { return new IClasspathEntry[0]; }; - String servletJar = cloudSdkPath + "/platform/google_appengine/google/appengine/tools/java/lib/shared/servlet-api.jar"; - String jspJar = cloudSdkPath + "/platform/google_appengine/google/appengine/tools/java/lib/shared/jsp-api.jar"; + String servletJar = cloudSdkPath + "/shared/servlet-api.jar"; + String jspJar = cloudSdkPath + "/shared/jsp-api.jar"; IClasspathEntry servletEntry = JavaCore.newLibraryEntry(new Path(servletJar), null, null); IClasspathEntry jspEntry = JavaCore.newLibraryEntry(new Path(jspJar), null, null); diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/CloudSdkRuntimeWizardFragment.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/CloudSdkRuntimeWizardFragment.java index 502d347aba..14885f5491 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/CloudSdkRuntimeWizardFragment.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/CloudSdkRuntimeWizardFragment.java @@ -44,8 +44,6 @@ import org.eclipse.wst.server.ui.wizard.IWizardHandle; import org.eclipse.wst.server.ui.wizard.WizardFragment; -import java.io.File; - /** * {@link WizardFragment} for configuring Google Cloud SDK Runtime. */ @@ -146,7 +144,7 @@ public void widgetSelected(SelectionEvent event) { } }); - File location = new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath().toFile(); + java.nio.file.Path location = new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath(); if (location != null) { dirTextBox.setText(location.toString()); } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java index 37544ad2a5..54f1760f58 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java @@ -25,7 +25,6 @@ import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineFacet.java b/plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineFacet.java index 071f434497..0aadfec1b8 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineFacet.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineFacet.java @@ -1,6 +1,5 @@ package com.google.cloud.tools.eclipse.appengine.newproject; -import java.io.File; import java.util.HashSet; import java.util.Set; @@ -49,9 +48,10 @@ public static void installAppEngineRuntime(IFacetedProject project, IProgressMon IRuntimeWorkingCopy appEngineRuntimeWorkingCopy = appEngineRuntimeType.createRuntime(null, monitor); - File sdkLocation = new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath().toFile(); + java.nio.file.Path sdkLocation = + new CloudSdkProvider().getCloudSdk().getJavaAppEngineSdkPath(); if (sdkLocation != null) { - IPath sdkPath = Path.fromOSString(sdkLocation.getAbsolutePath()); + IPath sdkPath = Path.fromOSString(sdkLocation.toString()); appEngineRuntimeWorkingCopy.setLocation(sdkPath); } org.eclipse.wst.server.core.IRuntime appEngineServerRuntime @@ -70,7 +70,8 @@ public static void installAppEngineFacet(IFacetedProject facetedProject, IProgre throws CoreException { IFacetedProjectWorkingCopy workingCopy = facetedProject.createWorkingCopy(); IProjectFacet appEngineFacet = ProjectFacetsManager.getProjectFacet(APP_ENGINE_FACET_ID); - IProjectFacetVersion appEngineFacetVersion = appEngineFacet.getVersion(APP_ENGINE_FACET_VERSION); + IProjectFacetVersion appEngineFacetVersion = + appEngineFacet.getVersion(APP_ENGINE_FACET_VERSION); workingCopy.addProjectFacet(appEngineFacetVersion); workingCopy.commitChanges(monitor); } diff --git a/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPreferencePage.java b/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPreferencePage.java index 90ff124c5b..1f3280249d 100644 --- a/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPreferencePage.java +++ b/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPreferencePage.java @@ -36,7 +36,6 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.browser.IWorkbenchBrowserSupport; -import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Path; diff --git a/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPrompter.java b/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPrompter.java index 76ca9ab95e..7c37627542 100644 --- a/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPrompter.java +++ b/plugins/com.google.cloud.tools.eclipse.sdk.ui/src/com/google/cloud/tools/eclipse/sdk/ui/preferences/CloudSdkPrompter.java @@ -61,11 +61,7 @@ public static CloudSdk getCloudSdk(Shell shell) { * @return the Cloud SDK, or {@code null} if unspecified */ public static CloudSdk getCloudSdk(IShellProvider shellProvider) { - // Not sure I understand what's going on here... - if (CLOUD_SDK != null) { - return CLOUD_SDK; - } - if (promptForSdk(shellProvider)) { + if (CLOUD_SDK != null || promptForSdk(shellProvider)) { return CLOUD_SDK; } return null; diff --git a/plugins/com.google.cloud.tools.eclipse.sdk/src/com/google/cloud/tools/eclipse/sdk/CloudSdkProvider.java b/plugins/com.google.cloud.tools.eclipse.sdk/src/com/google/cloud/tools/eclipse/sdk/CloudSdkProvider.java index b2b4c48065..99f173d18c 100644 --- a/plugins/com.google.cloud.tools.eclipse.sdk/src/com/google/cloud/tools/eclipse/sdk/CloudSdkProvider.java +++ b/plugins/com.google.cloud.tools.eclipse.sdk/src/com/google/cloud/tools/eclipse/sdk/CloudSdkProvider.java @@ -17,15 +17,12 @@ package com.google.cloud.tools.eclipse.sdk; import com.google.cloud.tools.appengine.cloudsdk.CloudSdk; -import com.google.cloud.tools.appengine.cloudsdk.PathResolver; import com.google.cloud.tools.eclipse.sdk.internal.PreferenceConstants; import com.google.cloud.tools.eclipse.sdk.internal.PreferenceInitializer; import org.eclipse.e4.core.contexts.ContextFunction; import org.eclipse.jface.preference.IPreferenceStore; -import java.io.File; -import java.nio.file.Path; import java.nio.file.Paths; /** @@ -46,7 +43,8 @@ public CloudSdk getCloudSdk() { String configuredPath = preferences.getString(PreferenceConstants.CLOUDSDK_PATH); - // Let's use the configured path, if there is one. Otherwise, the lib will try to discover the path. + // Let's use the configured path, if there is one. Otherwise, the lib will try to discover the + // path. if (configuredPath != null && !configuredPath.isEmpty()) { // TODO(joaomartins): What happens when the provided path is invalid? Tools lib isn't // calling validate().