【问题标题】:How can I build Google App Enging Java SDK?如何构建 Google App Engine Java SDK?
【发布时间】:2014-10-17 00:27:58
【问题描述】:

我已经下载了 Google App Engine 的源代码,我想更改此 example 中使用的某些方法(例如,DatastoreService.put(Entity e))的行为:

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

public class LocalDatastoreTest {

    private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());

    @Before
    public void setUp() {
        helper.setUp();
    }

    @After
    public void tearDown() {
        helper.tearDown();
    }

    // run this test twice to prove we're not leaking any state across tests
    private void doTest() {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        assertEquals(0, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
        ds.put(new Entity("yam"));
        ds.put(new Entity("yam"));
        assertEquals(2, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
    }

    @Test
    public void testInsert1() {
        doTest();
    }

    @Test
    public void testInsert2() {
        doTest();
    }
}

问题是我没有看到随源代码提供的 build.xml 文件对源 .java 文件进行了任何编译。例如,当我向其中一个源文件添加一些垃圾并尝试使用 ant dist 构建 SDK 时,它返回 BUILD SUCCESSFUL 而不是编译时错误。

我在哪里可以找到 put(Entity e) 方法的源文件?以及如何编译源代码?

【问题讨论】:

    标签: java ant google-app-engine


    【解决方案1】:

    您不能对 App Engine SDK 进行任何更改。 SDK 公开了与 App Engine 及其数据存储区的内部操作直接相关并依赖于其的方法。您不应将 SDK 与源代码分开编译。

    【讨论】:

    • 但是,他们为什么要分享源代码呢?
    • 在某些情况下,查看内部并了解正在发生的事情可能会很有用。社区还可以帮助修复错误或提出改进建议。
    猜你喜欢
    • 1970-01-01
    • 2012-02-29
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    • 2012-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多