Rewrite our build as modular maven components
This refactoring splits the code up into different components, with their own per-component CLASSPATH. By moving all of our classes into isolated components we can better isolate the classpaths and try to avoid unexpected dependency problems. It also allows us to more clearly define which components are used by the GWT UI and thus must be compiled under GWT, and which components are run on the server and can therefore use more of the J2SE API. Change-Id: I833cc22bacc5655d1c9099ed7c2b0e0a5b08855a Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<source path='diff' includes='
|
||||
Edit.java
|
||||
Edit_JsonSerializer.java
|
||||
'/>
|
||||
</module>
|
@@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class EditDeserializer implements JsonDeserializer<Edit>,
|
||||
JsonSerializer<Edit> {
|
||||
public Edit deserialize(final JsonElement json, final Type typeOfT,
|
||||
final JsonDeserializationContext context) throws JsonParseException {
|
||||
if (json.isJsonNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!json.isJsonArray()) {
|
||||
throw new JsonParseException("Expected array of 4for Edit type");
|
||||
}
|
||||
|
||||
final JsonArray a = (JsonArray) json;
|
||||
if (a.size() != 4) {
|
||||
throw new JsonParseException("Expected array of 4 for Edit type");
|
||||
}
|
||||
return new Edit(get(a, 0), get(a, 1), get(a, 2), get(a, 3));
|
||||
}
|
||||
|
||||
private static int get(final JsonArray a, final int idx)
|
||||
throws JsonParseException {
|
||||
final JsonElement v = a.get(idx);
|
||||
if (!v.isJsonPrimitive()) {
|
||||
throw new JsonParseException("Expected array of 4 for Edit type");
|
||||
}
|
||||
final JsonPrimitive p = (JsonPrimitive) v;
|
||||
if (!p.isNumber()) {
|
||||
throw new JsonParseException("Expected array of 4 for Edit type");
|
||||
}
|
||||
return p.getAsInt();
|
||||
}
|
||||
|
||||
public JsonElement serialize(final Edit src, final Type typeOfSrc,
|
||||
final JsonSerializationContext context) {
|
||||
if (src == null) {
|
||||
return new JsonNull();
|
||||
}
|
||||
final JsonArray a = new JsonArray();
|
||||
a.add(new JsonPrimitive(src.getBeginA()));
|
||||
a.add(new JsonPrimitive(src.getEndA()));
|
||||
a.add(new JsonPrimitive(src.getBeginB()));
|
||||
a.add(new JsonPrimitive(src.getEndB()));
|
||||
return a;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package org.eclipse.jgit.diff;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwtjsonrpc.client.JsonSerializer;
|
||||
|
||||
public class Edit_JsonSerializer extends JsonSerializer<Edit> {
|
||||
public static final Edit_JsonSerializer INSTANCE = new Edit_JsonSerializer();
|
||||
|
||||
@Override
|
||||
public Edit fromJson(Object jso) {
|
||||
if (jso == null) {
|
||||
return null;
|
||||
}
|
||||
final JavaScriptObject o = (JavaScriptObject) jso;
|
||||
return new Edit(get(o, 0), get(o, 1), get(o, 2), get(o, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printJson(final StringBuilder sb, final Edit o) {
|
||||
sb.append('[');
|
||||
sb.append(o.getBeginA());
|
||||
sb.append(',');
|
||||
sb.append(o.getEndA());
|
||||
sb.append(',');
|
||||
sb.append(o.getBeginB());
|
||||
sb.append(',');
|
||||
sb.append(o.getEndB());
|
||||
sb.append(']');
|
||||
}
|
||||
|
||||
private static native int get(JavaScriptObject jso, int idx)
|
||||
/*-{ return jso[idx]; }-*/;
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import org.eclipse.jgit.util.NB;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class ObjectIdSerialization {
|
||||
public static void writeCanBeNull(final OutputStream out, final AnyObjectId id)
|
||||
throws IOException {
|
||||
if (id != null) {
|
||||
out.write((byte)1);
|
||||
writeNotNull(out, id);
|
||||
} else {
|
||||
out.write((byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeNotNull(final OutputStream out, final AnyObjectId id)
|
||||
throws IOException {
|
||||
id.copyRawTo(out);
|
||||
}
|
||||
|
||||
public static ObjectId readCanBeNull(final InputStream in) throws IOException {
|
||||
switch (in.read()) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return readNotNull(in);
|
||||
default:
|
||||
throw new IOException("Invalid flag before ObjectId");
|
||||
}
|
||||
}
|
||||
|
||||
public static ObjectId readNotNull(final InputStream in) throws IOException {
|
||||
final byte[] b = new byte[20];
|
||||
NB.readFully(in, b, 0, 20);
|
||||
return ObjectId.fromRaw(b);
|
||||
}
|
||||
|
||||
private ObjectIdSerialization() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
// Hack to obtain visibility to package level methods only.
|
||||
// These aren't yet part of the public JGit API.
|
||||
|
||||
public class WindowCacheStatAccessor {
|
||||
public static int getOpenFiles() {
|
||||
return WindowCache.getInstance().getOpenFiles();
|
||||
}
|
||||
|
||||
public static long getOpenBytes() {
|
||||
return WindowCache.getInstance().getOpenBytes();
|
||||
}
|
||||
|
||||
private WindowCacheStatAccessor() {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user