Skip to content

Commit

Permalink
KUDU-2066. Add experimental Gradle build support
Browse files Browse the repository at this point in the history
Adds an experimental Gradle build that results in similar
tasks and artifacts as the existing maven build. See the
readme for usage and common commands.

The build is broken out by module with common configurations
in the root build.gradle file. Additionally the gradle
directory contains “drop in” scripts containing functional
pieces of the build configuration to simplify sharing
configurations and the unclutter the main build files.

Includes support for:
- Shaded dependencies that can be used across modules
- Running unit tests before integration tests
- Reporting available dependency updates
- Protobuf and Avro code generation
- Publishing to remote and local maven repositories
- Cross compiling scala
- Code quality checks (checkstyle, findbugs, pmd)

Change-Id: Ib257cdd019a1f383c886b9238bb47d96576c4421
Reviewed-on: http://gerrit.cloudera.org:8080/7258
Reviewed-by: Adar Dembo <[email protected]>
Tested-by: Kudu Jenkins
  • Loading branch information
granthenke authored and adembo committed Aug 3, 2017
1 parent de8b92e commit e5202d3
Show file tree
Hide file tree
Showing 34 changed files with 1,453 additions and 6 deletions.
3 changes: 3 additions & 0 deletions build-support/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pax_global_header
version.txt
build-support/release/rat_exclude_files.txt
docs/support/doxygen/client_api.footer.in
java/gradlew
java/gradle/gradle-wrapper.jar
java/gradle/gradle-wrapper.properties
java/kudu-flume-sink/src/test/avro/testAvroKuduOperationsProducer.avsc
java/kudu-client/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java
java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
Expand Down
6 changes: 6 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

# Eclipse files
.metadata/
.classpath
.project
.settings/
Expand All @@ -24,8 +25,13 @@
target/
dependency-reduced-pom.xml

# Gradle build artifacts
.gradle
build

# IntelliJ
*.ipr
*.iws
*.iml
.idea/
classes
55 changes: 54 additions & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Building the Client

$ mvn package -DskipTests

The client jar will can then be found at kudu-client/target.
The client jar can then be found at kudu-client/target.

Running the Tests
------------------------------------------------------------
Expand Down Expand Up @@ -135,3 +135,56 @@ likely a bug in maven-protoc-plugin.

There's a simple workaround: delete the errant folder within
Eclipse and refresh the kudu-client project.

Building with Gradle
--------------------

As an experiment a Gradle build definition also exists.
In order to run the Gradle build you must install [Gradle|https://gradle.org/].
If you would rather not install Gradle locally, you can use the
[Gradle Wrapper|https://docs.gradle.org/current/userguide/gradle_wrapper.html]
by replacing all references to gradle with gradlew.

## Running a full build

This will build all modules and run all "checks".

$ gradle buildAll

## Building the Client
$ gradle :kudu-client:assemble

The client jar can then be found at kudu-client/build/libs.

## Running the Tests
$ gradle test

Integration tests, including tests which cover Hadoop integration,
may be run with:

$ gradle integrationTest

*Note:* Integration tests may depend on built Kudu binaries.

## Building the Kudu-Spark integration

Builds with Spark 2.x with Scala 2.11 (the default) or
Spark 1.x with Scala 2.10.

$ gradle :kudu-spark:assemble
$ gradle :kudu-spark:assemble -PscalaVersions=2.10.6

## Installing to local maven repo

$ gradle install

## Clearing cached build state

$ gradle clean

## Discovering other tasks

$ gradle tasks



48 changes: 48 additions & 0 deletions java/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.

// This file is the entry-point for the gradle build and contains
// common logic for the various subprojects in the build.

// Load the buildscript file to apply dependencies needed for the gradle build itself.
buildscript { apply from: file("gradle/buildscript.gradle"), to: buildscript }

// Plugins and scripts applied at the root level only, instead of per module.
apply plugin: "idea"
apply plugin: "eclipse"
apply from: "$rootDir/gradle/properties.gradle"
apply from: "$rootDir/gradle/dependencies.gradle"
apply from: "$rootDir/gradle/wrapper.gradle"

subprojects {
// Plugins and scripts are applied in the natural "build order"
// they are used to ensure there are no dependency issues.
// These are common to all subprojects. However, subprojects may
// include their own plugins and scripts as well.
apply plugin: "java"
apply from: "$rootDir/gradle/scopes.gradle"
apply from: "$rootDir/gradle/compile.gradle"
apply from: "$rootDir/gradle/tests.gradle"
apply from: "$rootDir/gradle/quality.gradle"
apply from: "$rootDir/gradle/artifacts.gradle"
apply from: "$rootDir/gradle/publishing.gradle"

repositories {
mavenCentral()
mavenLocal()
}
}
41 changes: 41 additions & 0 deletions java/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# This file contains project properties.
# More about how to use the gradle.properties file can be read here:
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

group = org.apache.kudu
version = 1.5.0-SNAPSHOT
url = https://kudu.apache.org/
scmUrl = git://git.apache.org/kudu.git
issueTrackerUrl = https://issues.apache.org/jira/projects/KUDU

javaSourceCompatibility = 1.7
encoding = UTF-8

# Maximum parallel forks to use while unit testing.
maxParallelForks = 1

# Flags to speed up the gradle build.
# https://docs.gradle.org/current/userguide/build_environment.html
org.gradle.daemon=true
# The below configurations are experimental but a nice performance boost.
# org.gradle.caching=true
# org.gradle.configureondemand=true
# org.gradle.parallel=true
# org.gradle.workers.max=4
57 changes: 57 additions & 0 deletions java/gradle/artifacts.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.

// This file contains common tasks and configuration for artifact generation.

// Create a configuration so that the test jar can be referenced in other modules.
configurations.create("test")

task testJar(type: Jar, dependsOn: testClasses, group: "Build") {
description = "Assembles a jar archive containing the test classes."
from sourceSets.test.output
classifier = "tests"
extension "jar"
}

task sourcesJar(type: Jar, dependsOn: classes, group: "Build") {
description = "Assembles a jar archive containing the main source."
from sourceSets.main.allSource
classifier "sources"
extension "jar"
}

task testSourcesJar(type: Jar, dependsOn: testJar, group: "Build") {
description = "Assembles a jar archive containing the test source."
from sourceSets.test.allSource
classifier "test-sources"
extension "jar"
}

task javadocJar(type: Jar, dependsOn: javadoc, group: "Build") {
description = "Assembles a jar archive containing the javadoc."
from javadoc.destinationDir
classifier "javadoc"
extension "jar"
}

artifacts {
test testJar
archives testJar
archives sourcesJar
archives testSourcesJar
archives javadocJar
}
37 changes: 37 additions & 0 deletions java/gradle/buildscript.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.

// This file contains the dependencies required for the gradle build itself.

repositories {
mavenCentral()
jcenter()
maven { url "http://clojars.org/repo" } // Only used for the clojure plugin below.
maven { url "http://repo.spring.io/plugins-release" } // Only used for the propdeps plugin below.
maven { url "https://plugins.gradle.org/m2/" }
}

// Manage plugin dependencies since the plugin block can't be used in included build scripts yet.
// For more details see: https://docs.gradle.org/current/userguide/plugins.html#plugins_dsl_limitations
dependencies {
classpath "com.commercehub.gradle.plugin:gradle-avro-plugin:0.9.0"
classpath "com.github.ben-manes:gradle-versions-plugin:0.15.0"
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.1"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.1"
classpath "com.netflix.nebula:nebula-clojure-plugin:4.1.0"
classpath "io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
}
37 changes: 37 additions & 0 deletions java/gradle/compile.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.

// This file contains common compiler configurations.

// Java Configuration
tasks.withType(JavaCompile) {
sourceCompatibility = javaSourceCompatibility
options.encoding = encoding // make sure the encoding is defined by the project and not the system default.
options.incremental = true // enable incremental compilation.
}

// Scala configuration
tasks.withType(ScalaCompile) {
sourceCompatibility = javaSourceCompatibility
scalaCompileOptions.encoding = encoding // make sure the encoding is defined by the project and not the system default.
scalaCompileOptions.additionalParameters = [
// Emit warning and location for usages of features that should be imported explicitly.
"-feature",
// Emit various static analysis warnings.
"-Xlint"
]
}
Loading

0 comments on commit e5202d3

Please sign in to comment.