Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
B
beam
管理
动态
成员
计划
Wiki
代码
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
部署
发布
模型注册表
分析
贡献者分析
仓库分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
oss-mirrors
beam
提交
6067fc9c
提交
6067fc9c
编辑于
7 years ago
作者:
Luke Cwik
浏览文件
操作
下载
补丁
差异文件
Add comments to various parts of build_rules.gradle
Conflicts: build_rules.gradle
上级
fd1f5db3
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
build.gradle
+25
-11
25 个添加, 11 个删除
build.gradle
build_rules.gradle
+125
-19
125 个添加, 19 个删除
build_rules.gradle
有
150 个添加
和
30 个删除
build.gradle
+
25
−
11
浏览文件 @
6067fc9c
...
...
@@ -16,8 +16,16 @@
* limitations under the License.
*/
// See build_rules.gradle for documentation on default build tasks
// and properties that are enabled in addition to natures
// that can be applied to configure a project for certain common
// tasks.
apply
from:
project
(
":"
).
file
(
"build_rules.gradle"
)
// These versions are defined here because they represent
// a dependency version which should match across multiple
// Maven artifacts.
def
google_cloud_bigdataoss_version
=
"1.4.5"
def
bigtable_version
=
"1.0.0-pre3"
def
google_clients_version
=
"1.22.0"
...
...
@@ -35,6 +43,10 @@ def pubsub_grpc_version = "0.1.18"
def
apex_core_version
=
"3.6.0"
def
apex_malhar_version
=
"3.4.0"
// A map of maps containing common libraries used per language. To use:
// dependencies {
// shadow library.java.slf4j_api
// }
ext
.
library
=
[
java:
[
activemq_amqp:
"org.apache.activemq:activemq-amqp:5.13.1"
,
...
...
@@ -134,6 +146,8 @@ ext.library = [
],
]
// Define the set of repositories and dependencies required to
// fetch and enable plugins.
buildscript
{
repositories
{
mavenLocal
()
...
...
@@ -143,16 +157,16 @@ buildscript {
maven
{
url
"http://repo.spring.io/plugins-release"
}
}
dependencies
{
classpath
"net.ltgt.gradle:gradle-apt-plugin:0.12"
classpath
"com.google.protobuf:protobuf-gradle-plugin:0.8.1"
classpath
"io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
classpath
"gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.3.1"
classpath
"com.commercehub.gradle.plugin:gradle-avro-plugin:0.11.0"
classpath
"com.diffplug.spotless:spotless-plugin-gradle:3.6.0"
classpath
"gradle.plugin.com.github.blindpirate:gogradle:0.7.0"
classpath
"gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.13.0"
classpath
"cz.malohlava:visteg:1.0.3"
classpath
"com.github.jengelman.gradle.plugins:shadow:2.0.1"
classpath
"net.ltgt.gradle:gradle-apt-plugin:0.12"
// Enable a Java annotation processor
classpath
"com.google.protobuf:protobuf-gradle-plugin:0.8.1"
// Enable proto code generation
classpath
"io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
// Enable provided and optional configurations
classpath
"gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.3.1"
// Enable Apache license enforcement
classpath
"com.commercehub.gradle.plugin:gradle-avro-plugin:0.11.0"
// Enable Avro code generation
classpath
"com.diffplug.spotless:spotless-plugin-gradle:3.6.0"
// Enable a code formatting plugin
classpath
"gradle.plugin.com.github.blindpirate:gogradle:0.7.0"
// Enable Go code compilation
classpath
"gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.13.0"
// Enable building Docker containers
classpath
"cz.malohlava:visteg:1.0.3"
// Enable generating Gradle task dependencies as ".dot" files
classpath
"com.github.jengelman.gradle.plugins:shadow:2.0.1"
// Enable shading Java dependencies
}
}
...
...
@@ -161,7 +175,7 @@ buildscript {
apply
plugin:
"base"
// Apply one top level rat plugin to perform any required analysis
// Apply one top level rat plugin to perform any required
license enforcement
analysis
apply
plugin:
"org.nosphere.apache.rat"
rat
{
plainOutput
=
true
...
...
此差异已折叠。
点击以展开。
build_rules.gradle
+
125
−
19
浏览文件 @
6067fc9c
...
...
@@ -16,15 +16,29 @@
* limitations under the License.
*/
// This file contains common build rules that are to be applied
// to all projects and also a set of methods called applyXYZNature which
// sets up common build rules for sub-projects with the same needs.
//
// The supported list of natures are:
// * Java - Configures plugins commonly found in Java projects
// * Go - Configures plugins commonly found in Go projects
// * Docker - Configures plugins commonly used to build Docker containers
// * Grpc - Configures plugins commonly used to generate source from protos
// * Avro - Configures plugins commonly used to generate source from Avro specifications
//
// For example, see applyJavaNature below.
println
"Applying build_rules.gradle to $project.name"
/*************************************************************************************************/
// Apply common properties/repositories and tasks to all
build
s.
// Apply common properties/repositories and tasks to all
project
s.
group
=
"org.apache.beam"
version
=
"2.3.0-SNAPSHOT"
// Define the default set of
properties
// Define the default set of
repositories for all builds.
repositories
{
mavenLocal
()
mavenCentral
()
...
...
@@ -41,26 +55,76 @@ repositories {
}
// Provide code coverage
// TODO: Should this only apply to Java projects?
apply
plugin:
"jacoco"
// Provies "htmlDependencyReport" task which spits out a nice page per subproject
// showing all the dependencies per Gradle configuration.
// Apply a plugin which provides tasks for dependency / property / task reports.
// See https://docs.gradle.org/current/userguide/project_reports_plugin.html
// for further details. This is typically very useful to look at the "htmlDependencyReport"
// when attempting to resolve dependency issues.
apply
plugin:
"project-report"
// Apply a task dependency visualization plugin which creates a ".dot" file in the build directory
// giving the task dependencies for that project
// giving the task dependencies for the current build. Unfortunately this creates a ".dot" file
// in each sub-projects report output directory.
// See https://github.com/mmalohlava/gradle-visteg for further details.
apply
plugin:
"cz.malohlava.visteg"
/*************************************************************************************************/
/** Used as configuration within the applyJavaNature closure. */
// A class defining the set of configurable properties accepted by applyJavaNature
class
JavaNatureConfiguration
{
double
javaVersion
=
1.7
boolean
enableFindbugs
=
true
boolean
enableShadow
=
true
double
javaVersion
=
1.7
// Controls the JDK source language and target compatibility
boolean
enableFindbugs
=
true
// Controls whether the findbugs plugin is enabled and configured
boolean
enableShadow
=
true
// Controls whether the shadow plugin is enabled and configured
}
/** Takes a map of parameters. See JavaNatureConfiguration for the set of parameters allowed. */
// Configures a project with a default set of plugins that should apply to all Java projects.
//
// Users should invoke this method using Groovy map syntax. For example:
// applyJavaNature(javaVersion: 1.8)
//
// See JavaNatureConfiguration for the set of accepted properties.
//
// The following plugins are enabled:
// * java
// * maven
// * net.ltgt.apt (plugin to configure annotation processing tool)
// * propdeps (provide optional and provided dependency configurations)
// * propdeps-maven (configure Maven pom generation to understand optional and provided dependency configurations)
// * checkstyle
// * findbugs
// * shadow
// * com.diffplug.gradle.spotless (code style plugin)
//
// Dependency Management for Java Projects
// ---------------------------------------
//
// By default, the shadow plugin is enabled to perform shading of commonly found dependencies.
// Because of this it is important that dependencies are added to the correct configuration.
// Dependencies should fall into one of these four configurations:
// * compile - Required during compilation or runtime of the main source set.
// This configuration represents all dependencies that much also be shaded away
// otherwise the generated Maven pom will be missing this dependency.
// * shadow - Required during compilation or runtime of the main source set.
// Will become a runtime dependency of the generated Maven pom.
// * testCompile - Required during compilation or runtime of the test source set.
// This must be shaded away in the shaded test jar.
// * testShadow - Required during compilation or runtime of the test source set.
// TODO: Figure out whether this should be a test scope dependency
// of the generated Maven pom.
//
// When creating a cross-project dependency between two Java projects, one should only rely on the shaded configurations.
// This allows for compilation/test execution to occur against the final artifact that will be provided to users.
// This is by done by referencing the "shadow" or "testShadow" configuration as so:
// dependencies {
// shadow project(path: "other:java:project1", configuration: "shadow")
// testShadow project(path: "other:java:project2", configuration: "testShadow")
// }
// This will ensure the correct set of transitive dependencies from those projects are correctly added to the
// main and test source set runtimes.
ext
.
applyJavaNature
=
{
println
"applyJavaNature with "
+
(
it
?
"$it"
:
"default configuration"
)
+
" for project $project.name"
// Use the implicit it parameter of the closure to handle zero argument or one argument map calls.
...
...
@@ -68,15 +132,18 @@ ext.applyJavaNature = {
apply
plugin:
"maven"
apply
plugin:
"java"
// Configure the Java compiler source language and target compatibility levels. Also ensure that
// we configure the Java compiler to use UTF-8.
sourceCompatibility
=
configuration
.
javaVersion
targetCompatibility
=
configuration
.
javaVersion
tasks
.
withType
(
JavaCompile
)
{
options
.
encoding
=
"UTF-8"
}
// Configure the test tasks to always use JUnit and also configure the set of tests executed
// to match the equivalent set that is executed by the maven-surefire-plugin.
// See http://maven.apache.org/components/surefire/maven-surefire-plugin/test-mojo.html
test
{
// Configure the gradle include defaults to be equivalent to the maven-surefire-plugin
// http://maven.apache.org/components/surefire/maven-surefire-plugin/test-mojo.html
include
"**/Test*.class"
include
"**/*Test.class"
include
"**/*Tests.class"
...
...
@@ -84,10 +151,16 @@ ext.applyJavaNature = {
useJUnit
{
}
}
// Configures annotation processing for commonly used annotation processors
// across all Java projects.
apply
plugin:
"net.ltgt.apt"
dependencies
{
// Note that these plugins specifically use the compileOnly and testCompileOnly
// configurations because they are never required to be shaded or become a
// dependency of the output.
def
auto_value
=
"com.google.auto.value:auto-value:1.5.1"
def
auto_service
=
"com.google.auto.service:auto-service:1.0-rc2"
compileOnly
auto_value
apt
auto_value
testCompileOnly
auto_value
...
...
@@ -99,12 +172,15 @@ ext.applyJavaNature = {
testApt
auto_service
}
// Add the optional and provided scopes for dependencies
// Add the optional and provided configurations for dependencies
// TODO: Either remove these plugins and find another way to generate the Maven poms
// with the correct dependency scopes configured.
apply
plugin:
'propdeps'
apply
plugin:
'propdeps-maven'
// Configures a checkstyle plugin enforcing a set of rules and also allows for a set of
// suppressions.
apply
plugin:
'checkstyle'
tasks
.
withType
(
Checkstyle
)
{
configFile
=
project
(
":"
).
file
(
"sdks/java/build-tools/src/main/resources/beam/checkstyle.xml"
)
configProperties
=
[
"checkstyle.suppressions.file"
:
project
(
":"
).
file
(
"sdks/java/build-tools/src/main/resources/beam/suppressions.xml"
)
]
...
...
@@ -112,7 +188,9 @@ ext.applyJavaNature = {
maxErrors
=
0
}
apply
plugin:
'com.diffplug.gradle.spotless'
// Enables a plugin which can apply code formatting to source.
// TODO: Should this plugin be enabled for all projects?
apply
plugin:
"com.diffplug.gradle.spotless"
spotless
{
java
{
target
rootProject
.
fileTree
(
rootProject
.
rootDir
)
{
...
...
@@ -123,6 +201,8 @@ ext.applyJavaNature = {
}
}
// Enables a plugin which performs code analysis for common bugs.
// This plugin is configured to only analyze the "main" source set.
if
(
configuration
.
enableFindbugs
)
{
apply
plugin:
'findbugs'
findbugs
{
...
...
@@ -131,6 +211,12 @@ ext.applyJavaNature = {
}
}
// Enables a plugin which can perform shading of classes. See the general comments
// above about dependency management for Java projects and how the shadow plugin
// is expected to be used for the different Gradle configurations.
//
// TODO: Enforce all relocations are always performed to:
// "org.apache.beam." + project.name.replace("-", ".") + ".repackaged."
if
(
configuration
.
enableShadow
)
{
apply
plugin:
'com.github.johnrengelman.shadow'
...
...
@@ -163,9 +249,16 @@ ext.applyJavaNature = {
}
testCompile
.
extendsFrom
shadowTest
}
// TODO: Figure out how to create ShadowJar task for testShadowJar here
// that is extendable within each sub-project with any additional includes.
// Optimally, a single configuration would apply to both.
// This could mirror the "shadowJar" configuration block.
// Optionally, we could also copy the shading configuration from the main
// source set and apply it here.
//
// Shading the test jar has a lot less need but can still be beneficial for
// resolving class conflicts for tests during test execution or exposing
// test libraries for users.
}
// Ban these dependencies from all configurations
...
...
@@ -183,9 +276,12 @@ ext.applyJavaNature = {
exclude
group:
"org.mockito"
,
module:
"mockito-all"
}
// Force usage of the libraries defined within our common set
// instead of using Gradles default dependency resolution mechanism
// Force usage of the libraries defined within our common set
found in the root
//
build.gradle
instead of using Gradles default dependency resolution mechanism
// which chooses the latest version available.
//
// TODO: Figure out whether we should force all dependency conflict resolution
// to occur in the "shadow" and "testShadow" configurations.
configurations
.
all
{
resolutionStrategy
{
force
library
.
java
.
values
()
...
...
@@ -194,6 +290,8 @@ ext.applyJavaNature = {
}
/*************************************************************************************************/
ext
.
applyGoNature
=
{
println
"applyGoNature with "
+
(
it
?
"$it"
:
"default configuration"
)
+
" for project $project.name"
apply
plugin:
"com.github.blindpirate.gogradle"
...
...
@@ -215,7 +313,6 @@ ext.applyGoNature = {
if
(!
goProjects
.
contains
(
project
.
path
))
{
throw
new
GradleException
(
project
.
path
+
" has not been defined within the list of well known go projects within build_rules.gradle."
)
}
int
index
=
goProjects
.
indexOf
(
project
.
path
)
if
(
index
!=
0
)
{
String
previous
=
goProjects
.
get
(
index
-
1
)
...
...
@@ -230,6 +327,9 @@ ext.applyGoNature = {
}
}
/*************************************************************************************************/
ext
.
applyDockerNature
=
{
println
"applyDockerNature with "
+
(
it
?
"$it"
:
"default configuration"
)
+
" for project $project.name"
apply
plugin:
"com.palantir.docker"
...
...
@@ -238,6 +338,8 @@ ext.applyDockerNature = {
}
}
/*************************************************************************************************/
ext
.
applyGrpcNature
=
{
println
"applyGrpcNature with "
+
(
it
?
"$it"
:
"default configuration"
)
+
" for project $project.name"
apply
plugin:
"com.google.protobuf"
...
...
@@ -269,6 +371,10 @@ ext.applyGrpcNature = {
}
}
/*************************************************************************************************/
// TODO: Decide whether this should be inlined into the one project that relies on it
// or be left here.
ext
.
applyAvroNature
=
{
println
"applyAvroNature with "
+
(
it
?
"$it"
:
"default configuration"
)
+
" for project $project.name"
apply
plugin:
"com.commercehub.gradle.plugin.avro"
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录