[
https://issues.apache.org/jira/browse/BEAM-3608?focusedWorklogId=165184&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-165184
]
ASF GitHub Bot logged work on BEAM-3608:
----------------------------------------
Author: ASF GitHub Bot
Created on: 12/Nov/18 22:42
Start Date: 12/Nov/18 22:42
Worklog Time Spent: 10m
Work Description: lukecwik closed pull request #6809: [BEAM-3608] Vendor
guava 20.0
URL: https://github.com/apache/beam/pull/6809
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
index 18543ced40d..b59925d9aa9 100644
--- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
@@ -270,34 +270,8 @@ class BeamModulePlugin implements Plugin<Project> {
project.version += '-SNAPSHOT'
}
- project.repositories {
- maven { url project.offlineRepositoryRoot }
-
- // To run gradle in offline mode, one must first invoke
- // 'updateOfflineRepository' to create an offline repo
- // inside the root project directory. See the application
- // of the offline repo plugin within build_rules.gradle
- // for further details.
- if (project.gradle.startParameter.isOffline()) {
- return
- }
-
- mavenCentral()
- mavenLocal()
- jcenter()
-
- // Spring for resolving pentaho dependency.
- maven { url "https://repo.spring.io/plugins-release/" }
-
- // Release staging repository
- maven { url "https://oss.sonatype.org/content/repositories/staging/" }
-
- // Apache nightly snapshots
- maven { url "https://repository.apache.org/snapshots" }
-
- // Apache release snapshots
- maven { url
"https://repository.apache.org/content/repositories/releases" }
- }
+ // Register all Beam repositories and configuration tweaks
+ Repositories.register(project)
// Apply a plugin which enables configuring projects imported into
Intellij.
project.apply plugin: "idea"
@@ -613,28 +587,6 @@ class BeamModulePlugin implements Plugin<Project> {
}
project.artifacts.archives project.packageTests
- // Apply a plugin which provides the 'updateOfflineRepository' task that
creates an offline
- // repository. This offline repository satisfies all Gradle build
dependencies and Java
- // project dependencies. The offline repository is placed within
$rootDir/offline-repo
- // but can be overridden by specifying
'-PofflineRepositoryRoot=/path/to/repo'.
- // Note that parallel build must be disabled when executing
'updateOfflineRepository'
- // by specifying '--no-parallel', see
- //
https://github.com/mdietrichstein/gradle-offline-dependencies-plugin/issues/3
- project.apply plugin: "io.pry.gradle.offline_dependencies"
- project.offlineDependencies {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- maven { url "https://plugins.gradle.org/m2/" }
- maven { url "http://repo.spring.io/plugins-release" }
- maven { url project.offlineRepositoryRoot }
- }
- includeSources = false
- includeJavadocs = false
- includeIvyXmls = false
- }
-
// Configures annotation processing for commonly used annotation
processors
// across all Java projects.
project.apply plugin: "net.ltgt.apt"
diff --git
a/buildSrc/src/main/groovy/org/apache/beam/gradle/Repositories.groovy
b/buildSrc/src/main/groovy/org/apache/beam/gradle/Repositories.groovy
new file mode 100644
index 00000000000..8840d4c284a
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/Repositories.groovy
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.beam.gradle
+
+import org.gradle.api.Project
+
+class Repositories {
+
+ static void register(Project project) {
+
+ project.repositories {
+ maven { url project.offlineRepositoryRoot }
+
+ // To run gradle in offline mode, one must first invoke
+ // 'updateOfflineRepository' to create an offline repo
+ // inside the root project directory. See the application
+ // of the offline repo plugin within build_rules.gradle
+ // for further details.
+ if (project.gradle.startParameter.isOffline()) {
+ return
+ }
+
+ mavenCentral()
+ mavenLocal()
+ jcenter()
+
+ // Spring for resolving pentaho dependency.
+ maven { url "https://repo.spring.io/plugins-release/" }
+
+ // Release staging repository
+ maven { url "https://oss.sonatype.org/content/repositories/staging/" }
+
+ // Apache nightly snapshots
+ maven { url "https://repository.apache.org/snapshots" }
+
+ // Apache release snapshots
+ maven { url
"https://repository.apache.org/content/repositories/releases" }
+ }
+
+ // Apply a plugin which provides the 'updateOfflineRepository' task that
creates an offline
+ // repository. This offline repository satisfies all Gradle build
dependencies and Java
+ // project dependencies. The offline repository is placed within
$rootDir/offline-repo
+ // but can be overridden by specifying
'-PofflineRepositoryRoot=/path/to/repo'.
+ // Note that parallel build must be disabled when executing
'updateOfflineRepository'
+ // by specifying '--no-parallel', see
+ //
https://github.com/mdietrichstein/gradle-offline-dependencies-plugin/issues/3
+ project.apply plugin: "io.pry.gradle.offline_dependencies"
+ project.offlineDependencies {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ maven { url "https://plugins.gradle.org/m2/" }
+ maven { url "http://repo.spring.io/plugins-release" }
+ maven { url project.offlineRepositoryRoot }
+ }
+ includeSources = false
+ includeJavadocs = false
+ includeIvyXmls = false
+ }
+ }
+}
+
diff --git
a/buildSrc/src/main/groovy/org/apache/beam/gradle/VendorJavaPlugin.groovy
b/buildSrc/src/main/groovy/org/apache/beam/gradle/VendorJavaPlugin.groovy
new file mode 100644
index 00000000000..d668f092ab2
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/VendorJavaPlugin.groovy
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.beam.gradle
+
+import org.gradle.api.GradleException
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.file.FileTree
+import org.gradle.api.publish.maven.MavenPublication
+
+class VendorJavaPlugin implements Plugin<Project> {
+
+ static class VendorJavaPluginConfig {
+ String dependency
+ List<String> packagesToRelocate
+ String intoPackage
+ String groupId
+ String artifactId
+ String version
+ }
+
+ def isRelease(Project project) {
+ return project.hasProperty('isRelease')
+ }
+
+ void apply(Project project) {
+
+ // Deferred configuration so the extension is available; otherwise it
+ // needs to happen in a task, but not sure where to attach that
+ // task
+ project.ext.vendorJava = {
+ VendorJavaPluginConfig config = it ? it as VendorJavaPluginConfig : new
VendorJavaPluginConfig()
+
+ project.apply plugin: 'com.github.johnrengelman.shadow'
+
+ project.apply plugin: 'java'
+
+ // Register all Beam repositories and configuration tweaks
+ Repositories.register(project)
+
+ // 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.
+ project.apply plugin: "project-report"
+
+ project.dependencies { compile "${config.dependency}" }
+
+ project.shadowJar {
+ config.packagesToRelocate.each { srcNamespace ->
+ relocate(srcNamespace, "${config.intoPackage}.${srcNamespace}")
+ }
+ classifier = null
+ mergeServiceFiles()
+ zip64 true
+ }
+
+ project.task('validateVendoring', dependsOn: 'shadowJar') {
+ inputs.files project.configurations.shadow.artifacts.files
+ doLast {
+ project.configurations.shadow.artifacts.files.each {
+ FileTree exposedClasses = project.zipTree(it).matching {
+ include "**/*.class"
+ exclude "org/apache/beam/vendor/**"
+ // BEAM-5919: Exclude paths for Java 9 multi-release jars.
+ exclude "META-INF/versions/*/module-info.class"
+ exclude "META-INF/versions/*/org/apache/beam/vendor/**"
+ }
+ if (exposedClasses.files) {
+ throw new GradleException("$it exposed classes outside of
org.apache.beam namespace: ${exposedClasses.files}")
+ }
+ }
+ }
+ }
+
+ project.apply plugin: 'maven-publish'
+
+ project.publishing {
+ repositories {
+ maven {
+ name "testPublicationLocal"
+ url "file://${project.rootProject.projectDir}/testPublication/"
+ }
+ maven {
+ url(project.properties['distMgmtSnapshotsUrl'] ?:
isRelease(project)
+ ?
'https://repository.apache.org/service/local/staging/deploy/maven2'
+ :
'https://repository.apache.org/content/repositories/snapshots')
+
+ // We attempt to find and load credentials from ~/.m2/settings.xml
file that a user
+ // has configured with the Apache release and snapshot staging
credentials.
+ // <settings>
+ // <servers>
+ // <server>
+ // <id>apache.releases.https</id>
+ // <username>USER_TOKEN</username>
+ // <password>PASS_TOKEN</password>
+ // </server>
+ // <server>
+ // <id>apache.snapshots.https</id>
+ // <username>USER_TOKEN</username>
+ // <password>PASS_TOKEN</password>
+ // </server>
+ // </servers>
+ // </settings>
+ def settingsXml = new File(System.getProperty('user.home'),
'.m2/settings.xml')
+ if (settingsXml.exists()) {
+ def serverId = (project.properties['distMgmtServerId'] ?:
isRelease(project)
+ ? 'apache.releases.https' : 'apache.snapshots.https')
+ def m2SettingCreds = new
XmlSlurper().parse(settingsXml).servers.server.find { server ->
serverId.equals(server.id.text()) }
+ if (m2SettingCreds) {
+ credentials {
+ username m2SettingCreds.username.text()
+ password m2SettingCreds.password.text()
+ }
+ }
+ }
+ }
+ }
+
+ publications {
+ mavenJava(MavenPublication) {
+ groupId = config.groupId
+ artifactId = config.artifactId
+ version = config.version
+ artifact project.shadowJar
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/settings.gradle b/settings.gradle
index 6f5152e1473..a2a4941e53e 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -186,6 +186,8 @@ include "beam-sdks-java-test-utils"
project(":beam-sdks-java-test-utils").dir =
file("sdks/java/testing/test-utils")
include "beam-vendor-sdks-java-extensions-protobuf"
project(":beam-vendor-sdks-java-extensions-protobuf").dir =
file("vendor/sdks-java-extensions-protobuf")
+include "beam-vendor-guava-20_0"
+project(":beam-vendor-guava-20_0").dir = file("vendor/guava-20_0")
include "beam-website"
project(":beam-website").dir = file("website")
include "beam-runners-google-cloud-dataflow-java-legacy-worker"
diff --git a/vendor/guava-20_0/build.gradle b/vendor/guava-20_0/build.gradle
new file mode 100644
index 00000000000..d6bc6e4f939
--- /dev/null
+++ b/vendor/guava-20_0/build.gradle
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+apply plugin: org.apache.beam.gradle.VendorJavaPlugin
+
+description = "Apache Beam :: Vendored Dependencies :: Guava 20"
+
+group = "org.apache.beam"
+version = "0.1"
+
+
+vendorJava(
+ dependency: "com.google.guava:guava:20.0",
+ packagesToRelocate: ["com.google.common", "com.google.thirdparty"],
+ intoPackage: "org.apache.beam.guava.v20_0",
+ artifactId: "beam-vendor-guava-20_0"
+)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 165184)
Time Spent: 6h (was: 5h 50m)
> Vendor Guava
> ------------
>
> Key: BEAM-3608
> URL: https://issues.apache.org/jira/browse/BEAM-3608
> Project: Beam
> Issue Type: Sub-task
> Components: runner-core, sdk-java-core
> Reporter: Kenneth Knowles
> Assignee: Kenneth Knowles
> Priority: Major
> Time Spent: 6h
> Remaining Estimate: 0h
>
> Instead of shading as part of our build, we can shade before build so that it
> is apparent when reading code, and in IDEs, that a particular class resides
> in a hidden namespace.
> {{import com.google.common.reflect.TypeToken}}
> becomes something like
> {{import org.apache.beam.private.guava21.com.google.common.reflect.TypeToken}}
> So we can very trivially ban `org.apache.beam.private` from public APIs
> unless they are annotated {{@Internal}}, and it makes sharing between our own
> modules never get broken by shading again.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)