[
https://issues.apache.org/jira/browse/BEAM-3608?focusedWorklogId=160690&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-160690
]
ASF GitHub Bot logged work on BEAM-3608:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Oct/18 15:53
Start Date: 30/Oct/18 15:53
Worklog Time Spent: 10m
Work Description: lukecwik commented on a change in pull request #6809:
[BEAM-3608] Vendor guava 20.0
URL: https://github.com/apache/beam/pull/6809#discussion_r229367001
##########
File path:
buildSrc/src/main/groovy/org/apache/beam/gradle/VendorJavaPlugin.groovy
##########
@@ -0,0 +1,146 @@
+/*
+ * 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/**"
Review comment:
Note, we'll need to exclude META-INF as well since Java 9 adds a "class"
file containing the module info there.
See https://issues.apache.org/jira/browse/BEAM-5919
----------------------------------------------------------------
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: 160690)
Time Spent: 4h 50m (was: 4h 40m)
> 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
> Priority: Major
> Time Spent: 4h 50m
> 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)