package com.google.cloud.tools.eclipse.appengine.facets;

import com.google.cloud.tools.appengine.api.AppEngineException;
import com.google.cloud.tools.appengine.cloudsdk.CloudSdk;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;

public final class AppEngineSdkClasspathContainer implements IClasspathContainer {

  public static final String CONTAINER_ID = "AppEngineSDK";

  private static final String TOOLS_JAR_NAME = "appengine-tools-api.jar";

  @Override
  public IPath getPath() {
    return new Path(AppEngineSdkClasspathContainer.CONTAINER_ID);
  }

  @Override
  public int getKind() {
    return IClasspathEntry.CPE_CONTAINER;
  }

  @Override
  public String getDescription() {
    return "App Engine SDKs";
  }

  @Override
  public IClasspathEntry[] getClasspathEntries() {
    try {
      CloudSdk cloudSdk = new CloudSdk.Builder().build();
      if (cloudSdk != null) {
        java.nio.file.Path jarFile = cloudSdk.getJarPath(TOOLS_JAR_NAME);
        if (jarFile != null) {
          //@formatter:off
          IClasspathEntry appEngineToolsEntry = JavaCore.newLibraryEntry(
              new Path(jarFile.toString()),
              null /* sourceAttachmentPath */,
              null /* sourceAttachmentRootPath */, 
              true /* isExported */);
          //@formatter:on
          return new IClasspathEntry[] {appEngineToolsEntry};
        }
      }
    } catch (AppEngineException ex) {
      /* fall through */
    }
    return new IClasspathEntry[0];
  }

}

@@ -248,24 +248,73 @@
 ntime.Path;%0A
+import org.eclipse.jdt.core.IClasspathAttribute;%0A
 import org.e
@@ -613,49 +613,152 @@
 ing 
-TOOLS_JAR_NAME = %22appengine-tools-api.jar
+API_JAR = %22impl/appengine-api.jar%22;%0A  private static final String API_JAVADOC_URL =%0A      %22https://cloud.google.com/appengine/docs/java/javadoc/
 %22;%0A%0A
@@ -1249,28 +1249,44 @@
 etJa
-rPath(TOOLS_JAR_NAME
+vaAppEngineSdkPath().resolve(API_JAR
 );%0A 
@@ -1342,16 +1342,182 @@
 ter:off%0A
+          IClasspathAttribute javadocAttribute = %0A              JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, API_JAVADOC_URL);%0A
         
@@ -1539,28 +1539,27 @@
 ry appEngine
-Tool
+Api
 sEntry = Jav
@@ -1722,17 +1722,116 @@
 Path */,
- 
+%0A              null /* accessRules */,%0A              new IClasspathAttribute%5B%5D %7B javadocAttribute %7D,
 %0A       
@@ -1940,12 +1940,11 @@
 gine
-Tool
+Api
 sEnt

Fix new project setup to use appengine-api.jar and online javadocs (#423)