Skip to content

Commit

Permalink
Some style changes and fixed an issue with SDK path.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoandremartins committed Jul 11, 2016
1 parent f5e533b commit ffac7bd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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 */);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.google.cloud.tools.eclipse.appengine.newproject;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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().
Expand Down

0 comments on commit ffac7bd

Please sign in to comment.