Unify build properties.

- Switch all system properties to project properties.
- Use the ``javaLocalNamingStyle`` instead of the
  ``dot.delimited.style`` for property names, so that it can be directly
  referenced by ``rootProject.propertyName``.
- Recommend users to put GRPC-specific properties in project-level
  ``build.properties`` instead of the user-level.
This commit is contained in:
Kun Zhang 2015-05-06 13:10:28 -07:00
parent c5b94c7525
commit 2f7497133d
6 changed files with 34 additions and 40 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# Gradle # Gradle
build build
gradle.properties
.gradle .gradle
# IntelliJ IDEA # IntelliJ IDEA

View File

@ -175,7 +175,7 @@ it and the architecture of your JVM. For a fully fledged deployment, you will
need to deploy the codegen for all other supported OSes and architectures. need to deploy the codegen for all other supported OSes and architectures.
To deploy the codegen for an OS and architecture, you must run the following To deploy the codegen for an OS and architecture, you must run the following
commands on that OS and specify the architecture by the flag ``-Darch=<arch>``. commands on that OS and specify the architecture by the flag ``-PtargetArch=<arch>``.
We currently distribute the following OSes and architectures: We currently distribute the following OSes and architectures:
- Linux: ``x86_32``, ``x86_64`` - Linux: ``x86_32``, ``x86_64``
@ -184,13 +184,13 @@ We currently distribute the following OSes and architectures:
If you are doing a snapshot deployment: If you are doing a snapshot deployment:
``` ```
grpc-java$ ./gradlew clean grpc-compiler:uploadArchives -Darch=<arch> grpc-java$ ./gradlew clean grpc-compiler:uploadArchives -PtargetArch=<arch>
``` ```
If you are doing a release deployment: If you are doing a release deployment:
``` ```
grpc-java$ ./gradlew clean grpc-compiler:uploadArchives -Darch=<arch> \ grpc-java$ ./gradlew clean grpc-compiler:uploadArchives -PtargetArch=<arch> \
-DrepositoryId=<repository-id> -PrepositoryId=<repository-id>
``` ```
where ``<repository-id>`` is the ID of the staging repository that you have where ``<repository-id>`` is the ID of the staging repository that you have
found from the OSSRH UI after the first deployment, usually in the form of found from the OSSRH UI after the first deployment, usually in the form of

View File

@ -19,8 +19,8 @@ $ mvn install -pl codec-http2 -am -DskipTests=true
The codegen plugin is C++ code and requires protobuf 3.0.0-alpha-2. The codegen plugin is C++ code and requires protobuf 3.0.0-alpha-2.
If you are not changing the codegen plugin, nor any of the ``.proto`` files in If you are not changing the codegen plugin, nor any of the ``.proto`` files in
the source tree, you can skip this chapter and add ``grpc.skip.codegen=true`` the source tree, you can skip this chapter and add ``skipCodegen=true``
to ``$HOME/.gradle/gradle.properties``. It will make the build script skip the to ``<project-root>/gradle.properties``. It will make the build script skip the
build and invocation of the codegen, and use generated code that has been build and invocation of the codegen, and use generated code that has been
checked in. checked in.
@ -73,15 +73,15 @@ When building on Windows and VC++, you need to specify project properties for
Gradle to find protobuf: Gradle to find protobuf:
``` ```
.\gradlew install ^ .\gradlew install ^
-Pvc.protobuf.include=C:\path\to\protobuf-3.0.0-alpha-2\src ^ -PvcProtobufInclude=C:\path\to\protobuf-3.0.0-alpha-2\src ^
-Pvc.protobuf.libs=C:\path\to\protobuf-3.0.0-alpha-2\vsprojects\Release -PvcProtobufLibs=C:\path\to\protobuf-3.0.0-alpha-2\vsprojects\Release
``` ```
Since specifying those properties every build is bothersome, you can instead Since specifying those properties every build is bothersome, you can instead
create ``%HOMEDRIVE%%HOMEPATH%\.gradle\gradle.properties`` with contents like: create ``<project-root>\gradle.properties`` with contents like:
``` ```
vc.protobuf.include=C:\\path\\to\\protobuf-3.0.0-alpha-2\\src vcProtobufInclude=C:\\path\\to\\protobuf-3.0.0-alpha-2\\src
vc.protobuf.libs=C:\\path\\to\\protobuf-3.0.0-alpha-2\\vsprojects\\Release vcProtobufLibs=C:\\path\\to\\protobuf-3.0.0-alpha-2\\vsprojects\\Release
``` ```
The build script will build the codegen for the same architecture as the Java The build script will build the codegen for the same architecture as the Java
@ -90,8 +90,9 @@ be compiled for 64-bit, that means you must have compiled Protobuf in 64-bit.
### Notes for MinGW on Windows ### Notes for MinGW on Windows
If you have both MinGW and VC++ installed on Windows, VC++ will be used by If you have both MinGW and VC++ installed on Windows, VC++ will be used by
default. To override this default and use MinGW, add ``-Dvc.disable`` to your default. To override this default and use MinGW, add ``-PvcDisable=true``
Gradle command line. to your Gradle command line or add ``vcDisable=true`` to your
``<project-root>\gradle.properties``.
Navigating Around the Source Navigating Around the Source
---------------------------- ----------------------------

View File

@ -153,24 +153,19 @@ subprojects {
uploadArchives.repositories.mavenDeployer { uploadArchives.repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
String stagingUrl String stagingUrl
if (System.getProperty('repositoryId')) { if (rootProject.hasProperty('repositoryId')) {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + System.getProperty('repositoryId') stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
rootProject.repositoryId
} else { } else {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
} }
repository(url: stagingUrl) { def configureAuth = {
if (rootProject.hasProperty("ossrhUsername") if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
&& rootProject.hasProperty("ossrhPassword")) { authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
authentication(userName: ossrhUsername, password: ossrhPassword) }
}
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
if (rootProject.hasProperty("ossrhUsername")
&& rootProject.hasProperty("ossrhPassword")) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
} }
repository(url: stagingUrl, configureAuth)
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
} }
[ [

View File

@ -35,16 +35,14 @@ def addLibraryIfNotLinked = { libName, argList ->
} }
} }
def String arch = osdetector.arch def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch
if (System.getProperty('arch')) { def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDisable : false
arch = System.getProperty('arch')
}
model { model {
toolChains { toolChains {
// If you have both VC and Gcc installed, VC will be selected, unless you // If you have both VC and Gcc installed, VC will be selected, unless you
// use '-Dvc.disable' // set 'vcDisable=true'
if (System.getProperty('vc.disable') == null) { if (!vcDisable) {
visualCpp(VisualCpp) { visualCpp(VisualCpp) {
} }
} }
@ -101,12 +99,12 @@ binaries.all {
addEnvArgs("LDFLAGS", linker.args) addEnvArgs("LDFLAGS", linker.args)
} else if (toolChain in VisualCpp) { } else if (toolChain in VisualCpp) {
cppCompiler.args "/EHsc", "/MD" cppCompiler.args "/EHsc", "/MD"
if (rootProject.hasProperty('vc.protobuf.include')) { if (rootProject.hasProperty('vcProtobufInclude')) {
cppCompiler.args "/I" + rootProject.properties['vc.protobuf.include'] cppCompiler.args "/I${rootProject.vcProtobufInclude}"
} }
linker.args "libprotobuf.lib", "libprotoc.lib" linker.args "libprotobuf.lib", "libprotoc.lib"
if (rootProject.hasProperty('vc.protobuf.libs')) { if (rootProject.hasProperty('vcProtobufLibs')) {
linker.args "/LIBPATH:" + rootProject.properties['vc.protobuf.libs'] linker.args "/LIBPATH:${rootProject.vcProtobufLibs}"
} }
} }
} }

View File

@ -25,9 +25,8 @@ project(':grpc-all').projectDir = "$rootDir/all" as File
project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File
project(':grpc-examples').projectDir = "$rootDir/examples" as File project(':grpc-examples').projectDir = "$rootDir/examples" as File
if (settings.hasProperty('grpc.skip.codegen') if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) {
&& settings.getProperty('grpc.skip.codegen').toBoolean()) { println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true'
println '*** Skipping the build of codegen and compilation of proto files because grpc.skip.codegen=true'
} else { } else {
include ":grpc-compiler" include ":grpc-compiler"
project(':grpc-compiler').projectDir = "$rootDir/compiler" as File project(':grpc-compiler').projectDir = "$rootDir/compiler" as File