Compare commits

...
Sign in to create a new pull request.

34 commits

Author SHA1 Message Date
Feng Xiao
45ff30697a Add build targets for Java lite runtime. (#3288)
* Add a protobuf_java_lite target for lite runtime.

* Add a cc_binary for javalite plugin.

* Add proto_lang_toolchain for Java lite.
2017-06-30 13:51:58 -07:00
Jisi Liu
432a7559c1 Merge pull request #2823 from pherl/javalitewarning
Fix lint warnings in the javalite branch.
2017-03-09 16:23:19 -08:00
Jisi Liu
f5cc370dee Merge pull request #2816 from pherl/javalitebzl
Update bazel and build for javalite branch
2017-03-09 16:04:42 -08:00
Jisi Liu
09b707a2a1 Fix lint warnings in the javalite branch. 2017-03-09 15:56:29 -08:00
Jisi Liu
84bc5fc41e Update bazel and build for javalite branch 2017-03-09 12:29:42 -08:00
Jisi Liu
c9274a3800 Merge pull request #2808 from pherl/javalite-autogen
Update gmock links.
2017-03-09 11:17:05 -08:00
Feng Xiao
381ed97490 Update links in appveyor.yml
Change-Id: I3d44e3c6877e00cfea5a903568fde1e6f597aac1
2017-03-08 16:03:52 -08:00
Adrian Ludwin
71c475f97b Update repo to use google test 2017-03-08 15:42:41 -08:00
Feng Xiao
97cdd6e677 Update gmock links.
The original link is no longer available.

Change-Id: I2976d3f19c8e818689549fb31ff20af8eae92a07
2017-03-08 15:25:37 -08:00
Feng Xiao
8f2d5f07aa Merge pull request #2761 from cgrushko/patch-4
Update protobuf.bzl for recent versions of Bazel
2017-02-28 15:21:33 -08:00
cgrushko
8d92ae8bd4 Update protobuf.bzl for recent versions of Bazel
HOST_CFG has been deprecated in favor of "host".
2017-02-25 16:44:38 -05:00
Jisi Liu
82809aaebf Merge pull request #1886 from pherl/javalite
Remove travis config for javalite
2016-07-29 10:49:46 -07:00
Jisi Liu
0095b250f9 Remove travis config for javalite 2016-07-29 10:13:18 -07:00
Jisi Liu
b0f5cf02f8 Merge pull request #1877 from pherl/javalite
Bump lite version 3.0.1
2016-07-29 09:54:31 -07:00
Jisi Liu
a4f65cde70 Bump lite version 3.0.1 2016-07-28 15:30:20 -07:00
Jisi Liu
19015e344c Merge pull request #1876 from pherl/javalite
Include javadoc/source in Java release packages.
2016-07-28 14:58:58 -07:00
Feng Xiao
635bd681d8 Include javadoc/source in Java release packages.
Also fixed javadoc errors.

[ci skip]
2016-07-28 14:53:09 -07:00
Jisi Liu
c28192e1a3 Merge pull request #1873 from pherl/javalite
Fix Javalite Pom
2016-07-28 13:43:51 -07:00
Jisi Liu
ae895a5783 Update maven to call the plugin to generate javalite code. 2016-07-28 13:30:58 -07:00
Jisi Liu
8afbb84c48 update javalite versions. 2016-07-28 13:21:41 -07:00
Jisi Liu
1f71f8bbf8 Merge pull request #1872 from pherl/fixwin-javalite
Fix build protoc script for windows
2016-07-28 13:13:46 -07:00
Jisi Liu
d608b376cf Fix build protoc script for windows 2016-07-28 19:52:04 +00:00
Jisi Liu
a1a718123f Merge pull request #1856 from pherl/javalite
Add protoc-gen-javalite pom file in javalite branch.
2016-07-26 17:56:11 -07:00
Jisi Liu
236fb11189 Change documentation for javalite release 2016-07-26 17:32:31 -07:00
Jisi Liu
e8ede18912 Move the protoc pom to protoc-pom.xml in the lite.
This avoid accidental release the protoc using the lite branch.
2016-07-26 17:11:30 -07:00
Jisi Liu
1daef9c0eb Add a pom for javalite plugin 2016-07-26 16:58:19 -07:00
Jisi Liu
9c8f603b70 Merge pull request #1854 from pherl/javalite
Cherry pick protoc-artifacts change into the javalite branch
2016-07-26 16:53:39 -07:00
Jisi Liu
6ebb1b219c fix comments. 2016-07-26 16:52:14 -07:00
Jisi Liu
44248d72a6 Fix the script comments. 2016-07-26 16:43:58 -07:00
Jisi Liu
4261c67b73 Make protoc-artifacts able to build plugin. 2016-07-26 16:43:49 -07:00
Jisi Liu
9c8c7ea675 Merge pull request #1840 from pherl/javalite
Add lite plugin output to gitignore
2016-07-25 12:03:48 -07:00
Jisi Liu
9b4a6259b3 Add lite plugin output to gitignore 2016-07-25 11:50:59 -07:00
Jisi Liu
0c011c4c3c Merge pull request #1793 from pherl/javalite
Add a javalite plugin.
2016-07-15 12:39:34 -07:00
Jisi Liu
b702a16f27 Add a javalite plugin. 2016-07-15 12:30:10 -07:00
28 changed files with 549 additions and 199 deletions

1
.gitignore vendored
View file

@ -61,6 +61,7 @@ python/google/protobuf/compiler/
python/google/protobuf/util/
src/protoc
src/protoc-gen-javalite
src/unittest_proto_middleman
# Generated test scaffolding

View file

@ -1,92 +0,0 @@
sudo: required
# Note: travis currently does not support listing more than one language so
# this cheats and claims to only be cpp. If they add multiple language
# support, this should probably get updated to install steps and/or
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
language: cpp
os:
- linux
- osx
# The Objective C build needs Xcode 7.0 or later.
osx_image: xcode7.3
script:
- ./tests.sh $CONFIG
env:
- CONFIG=cpp
- CONFIG=cpp_distcheck
- CONFIG=golang
- CONFIG=java_jdk6
- CONFIG=java_jdk7
- CONFIG=java_oracle7
- CONFIG=javanano_jdk6
- CONFIG=javanano_jdk7
- CONFIG=javanano_oracle7
- CONFIG=javascript
# iOS build log was starting to choke travis UI, so split to cover the
# Xcode Debug and Release Configurations independently.
- CONFIG=objectivec_ios_debug
- CONFIG=objectivec_ios_release
- CONFIG=objectivec_osx
- CONFIG=objectivec_cocoapods_integration
- CONFIG=python
- CONFIG=python_cpp
- CONFIG=ruby19
- CONFIG=ruby20
- CONFIG=ruby21
- CONFIG=ruby22
- CONFIG=jruby
matrix:
exclude:
# It's nontrivial to programmatically install a new JDK from the command
# line on OS X, so we rely on testing on Linux for Java code.
- os: osx
env: CONFIG=java_jdk6
- os: osx
env: CONFIG=java_jdk7
- os: osx
env: CONFIG=java_oracle7
- os: osx
env: CONFIG=javanano_jdk6
- os: osx
env: CONFIG=javanano_jdk7
- os: osx
env: CONFIG=javanano_oracle7
# Requires installing golang, currently travis.sh is doing that with apt-get
# which doesn't work on OS X.
- os: osx
env: CONFIG=golang
# OS X/iOS tests of Objective C (needs Xcode, so it won't work on other
# platforms).
- os: linux
env: CONFIG=objectivec_ios_debug
- os: linux
env: CONFIG=objectivec_ios_release
- os: linux
env: CONFIG=objectivec_osx
- os: linux
env: CONFIG=objectivec_cocoapods_integration
# The dotnet environment requires Ubuntu 14.04 or 16.04. This
# configuration is effectively an "extra" one, outside the
# autogenerated matrix.
include:
- os: linux
env: CONFIG=csharp
dist: trusty
allow_failures:
# These currently do not work on OS X but are being worked on by @haberman.
- os: osx
env: CONFIG=ruby22
- os: osx
env: CONFIG=jruby
# https://github.com/google/protobuf/issues/1253 - Started failing when
# we moved to an OS X image that is 10.11.
- os: osx
env: CONFIG=python_cpp
# Mark the iOS test as flakey as xcodebuild some times fails to start the
# iOS Simulator.
- os: osx
env: CONFIG=objectivec_ios_debug
- os: osx
env: CONFIG=objectivec_ios_release
notifications:
email: false

153
BUILD
View file

@ -2,6 +2,8 @@
licenses(["notice"])
exports_files(["LICENSE"])
################################################################################
# Protobuf Runtime Library
################################################################################
@ -12,7 +14,7 @@ COPTS = [
"-Wwrite-strings",
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Wno-error=unused-function",
"-Wno-unused-function",
]
config_setting(
@ -25,11 +27,11 @@ config_setting(
# Android builds do not need to link in a separate pthread library.
LINK_OPTS = select({
":android": [],
"//conditions:default": ["-lpthread"],
"//conditions:default": ["-lpthread", "-lm"],
})
load(
"protobuf",
":protobuf.bzl",
"cc_proto_library",
"py_proto_library",
"internal_copied_filegroup",
@ -179,6 +181,17 @@ cc_library(
deps = [":protobuf_lite"],
)
# This provides just the header files for use in projects that need to build
# shared libraries for dynamic loading. This target is available until Bazel
# adds native support for such use cases.
# TODO(keveman): Remove this target once the support gets added to Bazel.
cc_library(
name = "protobuf_headers",
hdrs = glob(["src/**/*.h"]),
includes = ["src/"],
visibility = ["//visibility:public"],
)
objc_library(
name = "protobuf_objc",
hdrs = ["objectivec/GPBProtocolBuffers.h"],
@ -526,13 +539,100 @@ internal_gen_well_known_protos_java(
srcs = WELL_KNOWN_PROTOS,
)
java_library(
name = "protobuf_java_lite",
srcs = [
"java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java",
"java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java",
"java/core/src/main/java/com/google/protobuf/AbstractParser.java",
"java/core/src/main/java/com/google/protobuf/BooleanArrayList.java",
"java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java",
"java/core/src/main/java/com/google/protobuf/ByteOutput.java",
"java/core/src/main/java/com/google/protobuf/ByteString.java",
"java/core/src/main/java/com/google/protobuf/CodedInputStream.java",
"java/core/src/main/java/com/google/protobuf/CodedOutputStream.java",
"java/core/src/main/java/com/google/protobuf/DoubleArrayList.java",
"java/core/src/main/java/com/google/protobuf/ExperimentalApi.java",
"java/core/src/main/java/com/google/protobuf/ExtensionLite.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java",
"java/core/src/main/java/com/google/protobuf/FieldSet.java",
"java/core/src/main/java/com/google/protobuf/FloatArrayList.java",
"java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java",
"java/core/src/main/java/com/google/protobuf/IntArrayList.java",
"java/core/src/main/java/com/google/protobuf/Internal.java",
"java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java",
"java/core/src/main/java/com/google/protobuf/LazyField.java",
"java/core/src/main/java/com/google/protobuf/LazyFieldLite.java",
"java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java",
"java/core/src/main/java/com/google/protobuf/LazyStringList.java",
"java/core/src/main/java/com/google/protobuf/LongArrayList.java",
"java/core/src/main/java/com/google/protobuf/MapEntryLite.java",
"java/core/src/main/java/com/google/protobuf/MapFieldLite.java",
"java/core/src/main/java/com/google/protobuf/MessageLite.java",
"java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java",
"java/core/src/main/java/com/google/protobuf/MessageLiteToString.java",
"java/core/src/main/java/com/google/protobuf/MutabilityOracle.java",
"java/core/src/main/java/com/google/protobuf/NioByteString.java",
"java/core/src/main/java/com/google/protobuf/Parser.java",
"java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java",
"java/core/src/main/java/com/google/protobuf/ProtocolStringList.java",
"java/core/src/main/java/com/google/protobuf/RopeByteString.java",
"java/core/src/main/java/com/google/protobuf/SmallSortedMap.java",
"java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java",
"java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java",
"java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java",
"java/core/src/main/java/com/google/protobuf/UnsafeUtil.java",
"java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java",
"java/core/src/main/java/com/google/protobuf/Utf8.java",
"java/core/src/main/java/com/google/protobuf/WireFormat.java",
],
visibility = ["//visibility:public"],
)
cc_binary(
name = "protoc_gen_javalite",
srcs = ["src/google/protobuf/compiler/java/java_lite_main.cc"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protoc_lib"],
)
java_library(
name = "protobuf_java",
srcs = glob([
"java/core/src/main/java/com/google/protobuf/*.java",
]) + [
srcs = [
"java/core/src/main/java/com/google/protobuf/AbstractMessage.java",
"java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java",
"java/core/src/main/java/com/google/protobuf/BlockingService.java",
"java/core/src/main/java/com/google/protobuf/Descriptors.java",
"java/core/src/main/java/com/google/protobuf/DynamicMessage.java",
"java/core/src/main/java/com/google/protobuf/Extension.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java",
"java/core/src/main/java/com/google/protobuf/GeneratedMessage.java",
"java/core/src/main/java/com/google/protobuf/MapEntry.java",
"java/core/src/main/java/com/google/protobuf/MapField.java",
"java/core/src/main/java/com/google/protobuf/Message.java",
"java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java",
"java/core/src/main/java/com/google/protobuf/MessageReflection.java",
"java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java",
"java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java",
"java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java",
"java/core/src/main/java/com/google/protobuf/RpcCallback.java",
"java/core/src/main/java/com/google/protobuf/RpcChannel.java",
"java/core/src/main/java/com/google/protobuf/RpcController.java",
"java/core/src/main/java/com/google/protobuf/RpcUtil.java",
"java/core/src/main/java/com/google/protobuf/Service.java",
"java/core/src/main/java/com/google/protobuf/ServiceException.java",
"java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java",
"java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java",
"java/core/src/main/java/com/google/protobuf/TextFormat.java",
"java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java",
"java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java",
"java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java",
"java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java",
":gen_well_known_protos_java",
],
deps = [":protobuf_java_lite"],
visibility = ["//visibility:public"],
)
@ -541,12 +641,12 @@ java_library(
srcs = glob([
"java/util/src/main/java/com/google/protobuf/util/*.java",
]),
visibility = ["//visibility:public"],
deps = [
"protobuf_java",
"//external:gson",
"//external:guava",
],
visibility = ["//visibility:public"],
)
################################################################################
@ -567,12 +667,12 @@ py_library(
"python/google/protobuf/internal/test_util.py",
],
),
srcs_version = "PY2AND3",
imports = ["python"],
srcs_version = "PY2AND3",
)
cc_binary(
name = "internal/_api_implementation.so",
name = "python/google/protobuf/internal/_api_implementation.so",
srcs = ["python/google/protobuf/internal/api_implementation.cc"],
copts = COPTS + [
"-DPYTHON_PROTO2_CPP_IMPL_V2",
@ -586,7 +686,7 @@ cc_binary(
)
cc_binary(
name = "pyext/_message.so",
name = "python/google/protobuf/pyext/_message.so",
srcs = glob([
"python/google/protobuf/pyext/*.cc",
"python/google/protobuf/pyext/*.h",
@ -633,8 +733,8 @@ config_setting(
internal_copied_filegroup(
name = "protos_python",
srcs = WELL_KNOWN_PROTOS,
strip_prefix = "src",
dest = "python",
strip_prefix = "src",
)
# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
@ -648,15 +748,15 @@ py_proto_library(
data = select({
"//conditions:default": [],
":use_fast_cpp_protos": [
":internal/_api_implementation.so",
":pyext/_message.so",
":python/google/protobuf/internal/_api_implementation.so",
":python/google/protobuf/pyext/_message.so",
],
}),
default_runtime = "",
protoc = ":protoc",
py_libs = [
":python_srcs",
"//external:six"
"//external:six",
],
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
@ -670,13 +770,14 @@ py_proto_library(
internal_copied_filegroup(
name = "protos_python_test",
srcs = LITE_TEST_PROTOS + TEST_PROTOS,
strip_prefix = "src",
dest = "python",
strip_prefix = "src",
)
# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
# which case we can simply add :protos_python_test in srcs.
COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
py_proto_library(
@ -744,3 +845,25 @@ internal_protobuf_py_tests(
],
deps = [":python_tests"],
)
proto_lang_toolchain(
name = "cc_toolchain",
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "java_toolchain",
command_line = "--java_out=$(OUT)",
runtime = ":protobuf_java",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "javalite_toolchain",
command_line = "--$(PLUGIN_OUT)=$(OUT)",
plugin = ":protoc_gen_javalite",
runtime = ":protobuf_java_lite",
visibility = ["//visibility:public"],
)

View file

@ -1,15 +1,15 @@
new_http_archive(
name = "gmock_archive",
url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
new_git_repository(
name = "googletest",
build_file = "gmock.BUILD",
remote = "https://github.com/google/googletest",
tag = "release-1.8.0",
)
new_http_archive(
name = "six_archive",
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
build_file = "six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
)
bind(
@ -19,12 +19,12 @@ bind(
bind(
name = "gtest",
actual = "@gmock_archive//:gtest",
actual = "@googletest//:gtest",
)
bind(
name = "gtest_main",
actual = "@gmock_archive//:gtest_main",
actual = "@googletest//:gtest_main",
)
bind(
@ -33,8 +33,8 @@ bind(
)
maven_jar(
name = "guava_maven",
artifact = "com.google.guava:guava:18.0",
name = "guava_maven",
artifact = "com.google.guava:guava:18.0",
)
bind(
@ -43,8 +43,8 @@ bind(
)
maven_jar(
name = "gson_maven",
artifact = "com.google.code.gson:gson:2.3",
name = "gson_maven",
artifact = "com.google.code.gson:gson:2.3",
)
bind(

View file

@ -19,9 +19,15 @@ environment:
test: off
install:
- ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
- 7z x gmock-1.7.0.zip
- rename gmock-1.7.0 gmock
- ps: Start-FileDownload https://github.com/google/googlemock/archive/release-1.7.0.zip
- 7z x release-1.7.0.zip
- del /Q release-1.7.0.zip
- rename googlemock-release-1.7.0 gmock
- ps: Start-FileDownload https://github.com/google/googletest/archive/release-1.7.0.zip
- 7z x release-1.7.0.zip
- del /Q release-1.7.0.zip
- rename googletest-release-1.7.0 gtest
- move gtest gmock
- ps: Start-FileDownload https://go.microsoft.com/fwlink/?LinkID=809122 -FileName dotnetsdk.exe
- dotnetsdk.exe /install /quiet /norestart

View file

@ -31,10 +31,15 @@ fi
# directory is set up as an SVN external.
if test ! -e gmock; then
echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
unzip -q gmock-1.7.0.zip
rm gmock-1.7.0.zip
mv gmock-1.7.0 gmock
curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
unzip -q release-1.7.0.zip
rm release-1.7.0.zip
mv googlemock-release-1.7.0 gmock
curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
unzip -q release-1.7.0.zip
rm release-1.7.0.zip
mv googletest-release-1.7.0 gmock/gtest
fi
set -ex

View file

@ -1,19 +1,19 @@
cc_library(
name = "gtest",
srcs = [
"gmock-1.7.0/gtest/src/gtest-all.cc",
"gmock-1.7.0/src/gmock-all.cc",
"googletest/src/gtest-all.cc",
"googlemock/src/gmock-all.cc",
],
hdrs = glob([
"gmock-1.7.0/**/*.h",
"gmock-1.7.0/gtest/src/*.cc",
"gmock-1.7.0/src/*.cc",
"**/*.h",
"googletest/src/*.cc",
"googlemock/src/*.cc",
]),
includes = [
"gmock-1.7.0",
"gmock-1.7.0/gtest",
"gmock-1.7.0/gtest/include",
"gmock-1.7.0/include",
"googlemock",
"googletest",
"googletest/include",
"googlemock/include",
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
@ -21,7 +21,7 @@ cc_library(
cc_library(
name = "gtest_main",
srcs = ["gmock-1.7.0/src/gmock_main.cc"],
srcs = ["googlemock/src/gmock_main.cc"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
deps = [":gtest"],

View file

@ -490,7 +490,7 @@ public abstract class AbstractMessage
/**
* Used to support nested builders and called to mark this builder as clean.
* Clean builders will propagate the {@link BuildParent#markDirty()} event
* Clean builders will propagate the {@link BuilderParent#markDirty()} event
* to their parent builders, while dirty builders will not, as their parents
* should be dirty already.
*

View file

@ -37,11 +37,11 @@ import java.nio.ByteBuffer;
* An output target for raw bytes. This interface provides semantics that support two types of
* writing:
*
* <p/><b>Traditional write operations:</b>
* <p><b>Traditional write operations:</b>
* (as defined by {@link java.io.OutputStream}) where the target method is responsible for either
* copying the data or completing the write before returning from the method call.
*
* <p/><b>Lazy write operations:</b> where the caller guarantees that it will never modify the
* <p><b>Lazy write operations:</b> where the caller guarantees that it will never modify the
* provided buffer and it can therefore be considered immutable. The target method is free to
* maintain a reference to the buffer beyond the scope of the method call (e.g. until the write
* operation completes).

View file

@ -854,6 +854,7 @@ public abstract class GeneratedMessage extends AbstractMessage
/** Check if a singular extension is present. */
@Override
@SuppressWarnings("unchecked")
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
@ -863,6 +864,7 @@ public abstract class GeneratedMessage extends AbstractMessage
/** Get the number of elements in a repeated extension. */
@Override
@SuppressWarnings("unchecked")
public final <Type> int getExtensionCount(
final ExtensionLite<MessageType, List<Type>> extensionLite) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
@ -2555,6 +2557,7 @@ public abstract class GeneratedMessage extends AbstractMessage
}
@Override
@SuppressWarnings("unchecked")
public Object get(GeneratedMessage message) {
List result = new ArrayList();
for (int i = 0; i < getRepeatedCount(message); i++) {
@ -2564,6 +2567,7 @@ public abstract class GeneratedMessage extends AbstractMessage
}
@Override
@SuppressWarnings("unchecked")
public Object get(Builder builder) {
List result = new ArrayList();
for (int i = 0; i < getRepeatedCount(builder); i++) {

View file

@ -221,6 +221,7 @@ public abstract class GeneratedMessageLite<
}
@Override
@SuppressWarnings("unchecked")
public final BuilderType toBuilder() {
BuilderType builder = (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
builder.mergeFrom((MessageType) this);
@ -454,6 +455,7 @@ public abstract class GeneratedMessageLite<
*/
protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet();
@SuppressWarnings("unchecked")
protected final void mergeExtensionFields(final MessageType other) {
if (extensions.isImmutable()) {
extensions = extensions.clone();

View file

@ -611,12 +611,12 @@ public final class Internal {
int getInt(int index);
/**
* Like {@link #add(Integer)} but more efficient in that it doesn't box the element.
* Like {@link #add(Object)} but more efficient in that it doesn't box the element.
*/
void addInt(int element);
/**
* Like {@link #set(int, Integer)} but more efficient in that it doesn't box the element.
* Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
*/
int setInt(int index, int element);
@ -639,12 +639,12 @@ public final class Internal {
boolean getBoolean(int index);
/**
* Like {@link #add(Boolean)} but more efficient in that it doesn't box the element.
* Like {@link #add(Object)} but more efficient in that it doesn't box the element.
*/
void addBoolean(boolean element);
/**
* Like {@link #set(int, Boolean)} but more efficient in that it doesn't box the element.
* Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
*/
boolean setBoolean(int index, boolean element);
@ -667,12 +667,12 @@ public final class Internal {
long getLong(int index);
/**
* Like {@link #add(Long)} but more efficient in that it doesn't box the element.
* Like {@link #add(Object)} but more efficient in that it doesn't box the element.
*/
void addLong(long element);
/**
* Like {@link #set(int, Long)} but more efficient in that it doesn't box the element.
* Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
*/
long setLong(int index, long element);
@ -695,12 +695,12 @@ public final class Internal {
double getDouble(int index);
/**
* Like {@link #add(Double)} but more efficient in that it doesn't box the element.
* Like {@link #add(Object)} but more efficient in that it doesn't box the element.
*/
void addDouble(double element);
/**
* Like {@link #set(int, Double)} but more efficient in that it doesn't box the element.
* Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
*/
double setDouble(int index, double element);
@ -723,12 +723,12 @@ public final class Internal {
float getFloat(int index);
/**
* Like {@link #add(Float)} but more efficient in that it doesn't box the element.
* Like {@link #add(Object)} but more efficient in that it doesn't box the element.
*/
void addFloat(float element);
/**
* Like {@link #set(int, Float)} but more efficient in that it doesn't box the element.
* Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
*/
float setFloat(int index, float element);

View file

@ -89,6 +89,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
}
/** Create a MapEntry with the provided key and value. */
@SuppressWarnings("unchecked")
private MapEntry(Metadata metadata, K key, V value) {
this.key = key;
this.value = value;
@ -426,6 +427,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
}
@Override
@SuppressWarnings("unchecked")
public Builder<K, V> clone() {
return new Builder(metadata, key, value);
}

View file

@ -100,6 +100,7 @@ public class MapField<K, V> implements MutabilityOracle {
}
@Override
@SuppressWarnings("unchecked")
public void convertMessageToKeyAndValue(Message message, Map<K, V> map) {
MapEntry<K, V> entry = (MapEntry<K, V>) message;
map.put(entry.getKey(), entry.getValue());

View file

@ -39,7 +39,7 @@ import java.io.InputStream;
*
* <p>All methods may throw {@link InvalidProtocolBufferException}. In the event of invalid data,
* like an encoding error, the cause of the thrown exception will be {@code null}. However, if an
* I/O problem occurs, an exception is thrown with an {@link IOException} cause.
* I/O problem occurs, an exception is thrown with an {@link java.io.IOException} cause.
*
* @author liujisi@google.com (Pherl Liu)
*/

View file

@ -45,7 +45,7 @@ import java.util.Map.Entry;
*
* <p>The locations of primary fields values are retrieved by {@code getLocation} or
* {@code getLocations}. The locations of sub message values are within nested
* {@code TextFormatParseInfoTree}s and are retrieve by {@getNestedTree} or {code @getNestedTrees}.
* {@code TextFormatParseInfoTree}s and are retrieve by {@code getNestedTree} or {@code getNestedTrees}.
*
* <p>The {@code TextFormatParseInfoTree} is created by a Builder.
*/
@ -197,7 +197,7 @@ public class TextFormatParseInfoTree {
* Set for a sub message.
*
* <p>A new builder is created for a sub message. The builder that is returned is a new builder.
* The return is <emph>not</emph> the invoked {@code builder.getBuilderForSubMessageField}.
* The return is <em>not</em> the invoked {@code builder.getBuilderForSubMessageField}.
*
* @param fieldDescriptor the field whose value is the submessage
* @return a new Builder for the sub message

View file

@ -2,8 +2,9 @@
<echo message="Running protoc ..."/>
<mkdir dir="${generated.sources.lite.dir}"/>
<exec executable="${protoc}">
<arg value="--java_out=lite:${generated.sources.lite.dir}"/>
<arg value="--javalite_out=${generated.sources.lite.dir}"/>
<arg value="--proto_path=${protobuf.source.dir}"/>
<arg value="--plugin=protoc-gen-javalite=${protoc-gen-javalite}"/>
<arg value="${protobuf.source.dir}/google/protobuf/any.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/api.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/descriptor.proto"/>

View file

@ -6,9 +6,10 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.0.0-beta-3</version>
<version>3.0.0</version>
</parent>
<version>3.0.1</version>
<artifactId>protobuf-lite</artifactId>
<packaging>bundle</packaging>
@ -33,6 +34,7 @@
<properties>
<core.root>../core</core.root>
<test.proto.dir>${core.root}/src/test/proto</test.proto.dir>
<protoc-gen-javalite>${protobuf.source.dir}/protoc-gen-javalite</protoc-gen-javalite>
</properties>
<build>

View file

@ -11,7 +11,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.0.0-beta-3</version>
<version>3.0.0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>
@ -151,6 +151,32 @@
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>

View file

@ -1,12 +1,27 @@
# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED
def _GetPath(ctx, path):
if ctx.label.workspace_root:
return ctx.label.workspace_root + '/' + path
else:
return path
def _IsNewExternal(ctx):
# Bazel 0.4.4 and older have genfiles paths that look like:
# bazel-out/local-fastbuild/genfiles/external/repo/foo
# After the exec root rearrangement, they look like:
# ../repo/bazel-out/local-fastbuild/genfiles/foo
return ctx.label.workspace_root.startswith("../")
def _GenDir(ctx):
if _IsNewExternal(ctx):
# We are using the fact that Bazel 0.4.4+ provides repository-relative paths
# for ctx.genfiles_dir.
return ctx.genfiles_dir.path + (
"/" + ctx.attr.includes[0] if ctx.attr.includes and ctx.attr.includes[0] else "")
# This means that we're either in the old version OR the new version in the local repo.
# Either way, appending the source path to the genfiles dir works.
return ctx.var["GENDIR"] + "/" + _SourceDir(ctx)
def _SourceDir(ctx):
if not ctx.attr.includes:
return ctx.label.workspace_root
if not ctx.attr.includes[0]:
@ -15,14 +30,21 @@ def _GenDir(ctx):
return _GetPath(ctx, ctx.attr.includes[0])
return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])
def _CcOuts(srcs, use_grpc_plugin=False):
ret = [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
[s[:-len(".proto")] + ".pb.cc" for s in srcs]
def _CcHdrs(srcs, use_grpc_plugin=False):
ret = [s[:-len(".proto")] + ".pb.h" for s in srcs]
if use_grpc_plugin:
ret += [s[:-len(".proto")] + ".grpc.pb.h" for s in srcs] + \
[s[:-len(".proto")] + ".grpc.pb.cc" for s in srcs]
ret += [s[:-len(".proto")] + ".grpc.pb.h" for s in srcs]
return ret
def _CcSrcs(srcs, use_grpc_plugin=False):
ret = [s[:-len(".proto")] + ".pb.cc" for s in srcs]
if use_grpc_plugin:
ret += [s[:-len(".proto")] + ".grpc.pb.cc" for s in srcs]
return ret
def _CcOuts(srcs, use_grpc_plugin=False):
return _CcHdrs(srcs, use_grpc_plugin) + _CcSrcs(srcs, use_grpc_plugin)
def _PyOuts(srcs):
return [s[:-len(".proto")] + "_pb2.py" for s in srcs]
@ -46,9 +68,10 @@ def _proto_gen_impl(ctx):
srcs = ctx.files.srcs
deps = []
deps += ctx.files.srcs
source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx)
if gen_dir:
import_flags = ["-I" + gen_dir, "-I" + ctx.var["GENDIR"] + "/" + gen_dir]
if source_dir:
import_flags = ["-I" + source_dir, "-I" + gen_dir]
else:
import_flags = ["-I."]
@ -58,20 +81,33 @@ def _proto_gen_impl(ctx):
args = []
if ctx.attr.gen_cc:
args += ["--cpp_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
args += ["--cpp_out=" + gen_dir]
if ctx.attr.gen_py:
args += ["--python_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
args += ["--python_out=" + gen_dir]
if ctx.executable.grpc_cpp_plugin:
args += ["--plugin=protoc-gen-grpc=" + ctx.executable.grpc_cpp_plugin.path]
args += ["--grpc_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
inputs = srcs + deps
if ctx.executable.plugin:
plugin = ctx.executable.plugin
lang = ctx.attr.plugin_language
if not lang and plugin.basename.startswith('protoc-gen-'):
lang = plugin.basename[len('protoc-gen-'):]
if not lang:
fail("cannot infer the target language of plugin", "plugin_language")
outdir = gen_dir
if ctx.attr.plugin_options:
outdir = ",".join(ctx.attr.plugin_options) + ":" + outdir
args += ["--plugin=protoc-gen-%s=%s" % (lang, plugin.path)]
args += ["--%s_out=%s" % (lang, outdir)]
inputs += [plugin]
if args:
ctx.action(
inputs=srcs + deps,
inputs=inputs,
outputs=ctx.outputs.outs,
arguments=args + import_flags + [s.path for s in srcs],
executable=ctx.executable.protoc,
mnemonic="ProtoCompile",
)
return struct(
@ -82,22 +118,24 @@ def _proto_gen_impl(ctx):
),
)
_proto_gen = rule(
proto_gen = rule(
attrs = {
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = ["proto"]),
"includes": attr.string_list(),
"protoc": attr.label(
cfg = HOST_CFG,
cfg = "host",
executable = True,
single_file = True,
mandatory = True,
),
"grpc_cpp_plugin": attr.label(
cfg = HOST_CFG,
"plugin": attr.label(
cfg = "host",
allow_files = True,
executable = True,
single_file = True,
),
"plugin_language": attr.string(),
"plugin_options": attr.string_list(),
"gen_cc": attr.bool(),
"gen_py": attr.bool(),
"outs": attr.output_list(),
@ -105,6 +143,26 @@ _proto_gen = rule(
output_to_genfiles = True,
implementation = _proto_gen_impl,
)
"""Generates codes from Protocol Buffers definitions.
This rule helps you to implement Skylark macros specific to the target
language. You should prefer more specific `cc_proto_library `,
`py_proto_library` and others unless you are adding such wrapper macros.
Args:
srcs: Protocol Buffers definition files (.proto) to run the protocol compiler
against.
deps: a list of dependency labels; must be other proto libraries.
includes: a list of include paths to .proto files.
protoc: the label of the protocol compiler to generate the sources.
plugin: the label of the protocol compiler plugin to be passed to the protocol
compiler.
plugin_language: the language of the generated sources
plugin_options: a list of options to be passed to the plugin
gen_cc: generates C++ sources in addition to the ones from the plugin.
gen_py: generates Python sources in addition to the ones from the plugin.
outs: a list of labels of the expected outputs from the protocol compiler.
"""
def cc_proto_library(
name,
@ -150,7 +208,7 @@ def cc_proto_library(
if internal_bootstrap_hack:
# For pre-checked-in generated files, we add the internal_bootstrap_hack
# which will skip the codegen action.
_proto_gen(
proto_gen(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
@ -168,15 +226,18 @@ def cc_proto_library(
if use_grpc_plugin:
grpc_cpp_plugin = "//external:grpc_cpp_plugin"
outs = _CcOuts(srcs, use_grpc_plugin)
gen_srcs = _CcSrcs(srcs, use_grpc_plugin)
gen_hdrs = _CcHdrs(srcs, use_grpc_plugin)
outs = gen_srcs + gen_hdrs
_proto_gen(
proto_gen(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
includes=includes,
protoc=protoc,
grpc_cpp_plugin=grpc_cpp_plugin,
plugin=grpc_cpp_plugin,
plugin_language="grpc",
gen_cc=1,
outs=outs,
visibility=["//visibility:public"],
@ -189,12 +250,12 @@ def cc_proto_library(
native.cc_library(
name=name,
srcs=outs,
srcs=gen_srcs,
hdrs=gen_hdrs,
deps=cc_libs + deps,
includes=includes,
**kargs)
def internal_gen_well_known_protos_java(srcs):
"""Bazel rule to generate the gen_well_known_protos_java genrule
@ -202,10 +263,11 @@ def internal_gen_well_known_protos_java(srcs):
srcs: the well known protos
"""
root = Label("%s//protobuf_java" % (REPOSITORY_NAME)).workspace_root
pkg = PACKAGE_NAME + "/" if PACKAGE_NAME else ""
if root == "":
include = " -Isrc "
include = " -I%ssrc " % pkg
else:
include = " -I%s/src " % root
include = " -I%s/%ssrc " % (root, pkg)
native.genrule(
name = "gen_well_known_protos_java",
srcs = srcs,
@ -218,7 +280,6 @@ def internal_gen_well_known_protos_java(srcs):
tools = [":protoc"],
)
def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs):
"""Macro to copy files to a different directory and then create a filegroup.
@ -248,7 +309,6 @@ def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs):
srcs = outs,
**kwargs)
def py_proto_library(
name,
srcs=[],
@ -258,6 +318,7 @@ def py_proto_library(
include=None,
default_runtime="//:protobuf_python",
protoc="//:protoc",
use_grpc_plugin=False,
**kargs):
"""Bazel rule to create a Python protobuf library from proto source files
@ -277,6 +338,8 @@ def py_proto_library(
default_runtime: the implicitly default runtime which will be depended on by
the generated py_library target.
protoc: the label of the protocol compiler to generate the sources.
use_grpc_plugin: a flag to indicate whether to call the Python C++ plugin
when processing the proto files.
**kargs: other keyword arguments that are passed to cc_library.
"""
@ -286,7 +349,14 @@ def py_proto_library(
if include != None:
includes = [include]
_proto_gen(
grpc_python_plugin = None
if use_grpc_plugin:
grpc_python_plugin = "//external:grpc_python_plugin"
# Note: Generated grpc code depends on Python grpc module. This dependency
# is not explicitly listed in py_libs. Instead, host system is assumed to
# have grpc installed.
proto_gen(
name=name + "_genproto",
srcs=srcs,
deps=[s + "_genproto" for s in deps],
@ -295,6 +365,8 @@ def py_proto_library(
gen_py=1,
outs=outs,
visibility=["//visibility:public"],
plugin=grpc_python_plugin,
plugin_language="grpc"
)
if default_runtime and not default_runtime in py_libs + deps:

View file

@ -1,3 +1,14 @@
# Special notes about building pre-compiled protoc-gen-javalite
This section is only visible from the javalite branch, which is forked from the
master branch to provide a stable java lite support. The ``protoc-gen-javalite``
plugin can only be built and published in this branch.
The sections below in this README are branched from the master, with all the mvn
commands changed to have an extra ``-f javalite-pom.xml`` parameter to load the
correct configuration for plugins. The original ``pom.xml`` in this branch is
renamed to ``protoc-pom.xml`` to prevent the protoc from being accidentally
published using this branch.
# Build scripts that publish pre-compiled protoc artifacts
``protoc`` is the compiler for ``.proto`` files. It generates language bindings
for the messages and/or RPC services from ``.proto`` files.
@ -36,7 +47,7 @@ $ ./autogen.sh && ./configure && make
## To install artifacts locally
The following command will install the ``protoc`` artifact to your local Maven repository.
```
$ mvn install
$ mvn -f javalite-pom.xml install
```
## Cross-compilation
@ -57,7 +68,7 @@ Frequently used values are:
For example, MinGW32 only ships with 32-bit compilers, but you can still build
32-bit protoc under 64-bit Windows, with the following command:
```
$ mvn install -Dos.detected.arch=x86_32
$ mvn -f javalite-pom.xml install -Dos.detected.arch=x86_32
```
## To push artifacts to Maven Central
@ -81,7 +92,7 @@ Windows.
Use the following command to deploy artifacts for the host platform to a
staging repository.
```
$ mvn clean deploy -P release
$ mvn -f javalite-pom.xml clean deploy -P release
```
It creates a new staging repository. Go to
https://oss.sonatype.org/#stagingRepositories and find the repository, usually
@ -92,7 +103,7 @@ subsequent deployments you will need to provide the repository name that you
have found in the first deployment so that all artifacts go to the same
repository:
```
$ mvn clean deploy -P release -Dstaging.repository=comgoogle-123
$ mvn -f javalite-pom.xml clean deploy -P release -Dstaging.repository=comgoogle-123
```
A 32-bit artifact can be deployed from a 64-bit host with

View file

@ -1,17 +1,30 @@
#!/bin/bash
# Builds protoc executable into target/protoc.exe
# Builds protoc executable into target/protoc.exe; optionally build protoc
# plugins into target/protoc-gen-*.exe
# To be run from Maven.
# Usage: build-protoc.sh <OS> <ARCH>
# Usage: build-protoc.sh <OS> <ARCH> <TARGET>
# <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin
# <TARGET> can be "protoc" or "protoc-gen-javalite"
OS=$1
ARCH=$2
MAKE_TARGET=$3
if [[ $# < 2 ]]; then
if [[ $# < 3 ]]; then
echo "No arguments provided. This script is intended to be run from Maven."
exit 1
fi
case $MAKE_TARGET in
protoc-gen-javalite)
;;
protoc)
;;
*)
echo "Target ""$TARGET"" invalid."
exit 1
esac
# Under Cygwin, bash doesn't have these in PATH when called from Maven which
# runs in Windows version of Java.
export PATH="/bin:/usr/bin:$PATH"
@ -126,7 +139,7 @@ checkDependencies ()
}
############################################################################
echo "Building protoc, OS=$OS ARCH=$ARCH"
echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET"
# Nested double quotes are unintuitive, but it works.
cd "$(dirname "$0")"
@ -134,7 +147,7 @@ cd "$(dirname "$0")"
WORKING_DIR=$(pwd)
CONFIGURE_ARGS="--disable-shared"
MAKE_TARGET="protoc"
TARGET_FILE=target/$MAKE_TARGET.exe
if [[ "$OS" == windows ]]; then
MAKE_TARGET="${MAKE_TARGET}.exe"
fi
@ -209,12 +222,10 @@ fi
export CXXFLAGS LDFLAGS
TARGET_FILE=target/protoc.exe
cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS &&
cd src && make clean && make $MAKE_TARGET &&
cd "$WORKING_DIR" && mkdir -p target &&
(cp ../src/protoc $TARGET_FILE || cp ../src/protoc.exe $TARGET_FILE) ||
cp ../src/$MAKE_TARGET $TARGET_FILE ||
exit 1
if [[ "$OS" == osx ]]; then

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google</groupId>
<artifactId>google</artifactId>
<version>1</version>
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc-gen-javalite</artifactId>
<version>3.0.0</version>
<packaging>pom</packaging>
<name>Protobuf Java Lite Compiler Plugin</name>
<description>
The Protobuf Compiler (protoc) compiler plugin to generate Java Lite files.
</description>
<inceptionYear>2008</inceptionYear>
<url>https://developers.google.com/protocol-buffers/</url>
<licenses>
<license>
<name>New BSD license</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/google/protobuf</url>
<connection>
scm:git:https://github.com/google/protobuf.git
</connection>
</scm>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.2.3.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>bash</executable>
<arguments>
<argument>build-protoc.sh</argument>
<argument>${os.detected.name}</argument>
<argument>${os.detected.arch}</argument>
<argument>protoc-gen-javalite</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/protoc-gen-javalite.exe</file>
<classifier>${os.detected.name}-${os.detected.arch}</classifier>
<type>exe</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<properties>
<!-- Specify the staging repository to deploy to. This can be left
empty for the first deployment, and Sonatype will create one. For
subsequent deployments it should be set to what Sonatype has
created, so that all deployments will go to the same repository.
-->
<staging.repository></staging.repository>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<stagingRepositoryId>${staging.repository}</stagingRepositoryId>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -59,6 +59,7 @@
<argument>build-protoc.sh</argument>
<argument>${os.detected.name}</argument>
<argument>${os.detected.arch}</argument>
<argument>protoc</argument>
</arguments>
</configuration>
</plugin>

View file

@ -472,9 +472,11 @@ libprotoc_la_SOURCES = \
google/protobuf/compiler/csharp/csharp_wrapper_field.cc \
google/protobuf/compiler/csharp/csharp_wrapper_field.h
bin_PROGRAMS = protoc
bin_PROGRAMS = protoc protoc-gen-javalite
protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
protoc_SOURCES = google/protobuf/compiler/main.cc
protoc_gen_javalite_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
protoc_gen_javalite_SOURCES = google/protobuf/compiler/java/java_lite_main.cc
# Tests ==============================================================
@ -677,6 +679,7 @@ COMMON_TEST_SOURCES = \
check_PROGRAMS = protoc protobuf-test protobuf-lazy-descriptor-test \
protobuf-lite-test test_plugin protobuf-lite-arena-test \
protoc-gen-javalite \
$(GZCHECKPROGRAMS)
protobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \
../gmock/gtest/lib/libgtest.la \

View file

@ -0,0 +1,34 @@
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/compiler/java/java_generator.h>
#include <google/protobuf/compiler/plugin.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace java {
class JavaLiteGenerator : public CodeGenerator {
public:
JavaLiteGenerator() {}
~JavaLiteGenerator() {}
bool Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* context,
string* error) const {
// Only pass 'lite' as the generator parameter.
return generator_.Generate(file, "lite", context, error);
}
private:
JavaGenerator generator_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaLiteGenerator);
};
} // namespace java
} // namespace compiler
} // namespace protobuf
} // namespace google
int main(int argc, char* argv[]) {
google::protobuf::compiler::java::JavaLiteGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}

View file

@ -1431,6 +1431,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
"\n"
"private volatile com.google.protobuf.Message cachedUnpackValue;\n"
"\n"
"@java.lang.SuppressWarnings(\"unchecked\")\n"
"public <T extends com.google.protobuf.Message> T unpack(\n"
" java.lang.Class<T> clazz)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"

View file

@ -339,6 +339,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
}
printer->Print(
"@java.lang.SuppressWarnings(\"unchecked\")\n"
"protected final Object dynamicMethod(\n"
" com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n"
" Object arg0, Object arg1) {\n"
@ -391,6 +392,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
"}\n"
"// fall through\n"
"case GET_DEFAULT_INSTANCE: {\n"
" return DEFAULT_INSTANCE;\n"
"}\n"