Permalink
Browse files

Isolation of gradle's classpath from pegasus plugin's classpath.

This is a follow up on RB# 742894 and RB# 677995.

- Change from RB# 742894: for GenerateAvroSchemaTask.groovy, choose not to input avroTranslateOptionalDefault if it is null (as it leads to compilation error for a couple of MPs during container PCL).

- Possible impact: MPs that use gradle-plugins of pegasus, but most of them should be fine as they use it in the toolchain section. Only 3 MPs use the gradle-plugins in the product section: resource-identity, ligradle-pegasus and client-typed-urn-generator. From local mint build, only resource-identity requires change due to the pegasus API change. RB will be submitted to resource-identity to pick up this RB.

- Details of the motivation (as stated in RB# 742894):

The driver behind this is that there is no isolation
between gradle's classpath and the classpath of the pegasus
plugin. Since the plugin relies on things not being on the
classpath, we need better isolation. An added benefit with
this change is that the plugin dependencies won't be required
to be present at runtime. This means that when you load
the pegasus plugin it won't have to resolve everything
that it uses and we can delay the resolution until later.

Another benifit is that by the version being part of
the project configurations it will then be part of
our forcing strategy.

RB=815196
G=si-dev
R=ethall,kjin,dhoa,xma,dmajumde
A=kjin
  • Loading branch information...
1 parent 07022f3 commit 90e0d944836efbcba364f4655f629b757e0849e9 Yiming Wang committed Sep 15, 2016
Showing with 1,585 additions and 1,069 deletions.
  1. +1 −1 .gitignore
  2. +6 −0 build.gradle
  3. +4 −14 buildSrc/src/main/groovy/com/linkedin/pegasus/gradle/PegasusPluginLoader.groovy
  4. +5 −5 gradle-plugins/build.gradle
  5. +6 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/FileCompatibilityType.java
  6. +8 −5 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/PegasusOptions.java
  7. +152 −987 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/PegasusPlugin.groovy
  8. +59 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/PropertyUtil.java
  9. +26 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/SharedFileUtils.groovy
  10. +110 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/internal/CompatibilityLogChecker.java
  11. +22 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/internal/FileExtensionFilter.groovy
  12. +99 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/ChangedFileReportTask.java
  13. +98 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/CheckIdlTask.groovy
  14. +126 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/CheckRestModelTask.groovy
  15. +100 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/CheckSnapshotTask.groovy
  16. +103 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/GenerateAvroSchemaTask.groovy
  17. +78 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/GenerateDataTemplateTask.groovy
  18. +142 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/GenerateRestClientTask.groovy
  19. +173 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/GenerateRestModelTask.groovy
  20. +44 −0 gradle-plugins/src/main/groovy/com/linkedin/pegasus/gradle/tasks/PublishRestModelTask.groovy
  21. +1 −0 gradle-plugins/src/main/resources/pegasus-version.properties
  22. +1 −0 gradle-plugins/src/test/groovy/com/linkedin/pegasus/gradle/TestPegasusPlugin.groovy
  23. +1 −1 gradle.properties
  24. +40 −0 restli-tools/src/main/java/com/linkedin/restli/internal/tools/AdditionalDocProvidersUtil.java
  25. +22 −1 restli-tools/src/main/java/com/linkedin/restli/tools/clientgen/RestRequestBuilderGenerator.java
  26. +52 −0 restli-tools/src/main/java/com/linkedin/restli/tools/compatibility/CompatibilityReport.java
  27. +25 −13 ...ols/src/main/java/com/linkedin/restli/tools/idlcheck/RestLiResourceModelCompatibilityChecker.java
  28. +21 −11 ...i-tools/src/main/java/com/linkedin/restli/tools/idlgen/RestLiResourceModelExporterCmdLineApp.java
  29. +33 −19 ...ls/src/main/java/com/linkedin/restli/tools/snapshot/check/RestLiSnapshotCompatibilityChecker.java
  30. +27 −12 ...-tools/src/main/java/com/linkedin/restli/tools/snapshot/gen/RestLiSnapshotExporterCmdLineApp.java
View
@@ -18,5 +18,5 @@ codegen/
test-output/
examples/*/api/src/main/idl
examples/*/api/src/main/snapshot
-*gradle/
ligradle/
+
View
@@ -152,6 +152,12 @@ subprojects {
pluginsRuntime project(':gradle-plugins')
dataTemplateCompile project(':data')
restClientCompile project(':restli-client')
+
+ //Providing the required dependencies for the plugin to execute under a configuration
+ pegasusPlugin project(':data')
+ pegasusPlugin project(':data-avro-generator')
+ pegasusPlugin project(':generator')
+ pegasusPlugin project(':restli-tools')
}
}
else
@@ -28,21 +28,10 @@ class PegasusPluginLoader implements Plugin<Project>
{
final PegasusPlugin plugin = new PegasusPlugin()
plugin.setPluginType(this.class)
- plugin._isRestli1BuildersDeprecated = false;
plugin.apply(project)
- project.afterEvaluate {
- final URL[] classpathUrls = project.configurations.pluginsRuntime.collect { it.toURI().toURL() } as URL[]
- final ClassLoader parent = null // in some versions of java URLClassLoader's ctor is overloaded, by assigning type to the parent we avoid ambiguity
- project.ext.set(PegasusPlugin.GENERATOR_CLASSLOADER_NAME, new URLClassLoader(classpathUrls, parent as ClassLoader))
-
- project.tasks.each {
- // each Gradle task class is dynamically generated as subclass of the original task type
- // use Class.getSuperclass() to get the original task type
- if (it.class.superclass.enclosingClass == PegasusPlugin)
- {
- it.dependsOn(project.configurations.pluginsRuntime)
- }
+ project.afterEvaluate { proj ->
+ proj.tasks.withType(Class.forName('com.linkedin.pegasus.gradle.tasks.GenerateRestClientTask')) { task -> task._isRestli1BuildersDeprecated = false
}
}
}
@@ -52,7 +41,8 @@ class PegasusPluginLoader implements Plugin<Project>
exported by this loader to be accessible to external gradle files.
This method is needed by restli-int-test-server/build.gradle
- */
+ */
+
public static String getGeneratedDirPath(Project project, SourceSet sourceSet, String genType)
{
PegasusPlugin.getGeneratedDirPath(project, sourceSet, genType)
@@ -4,10 +4,10 @@ dependencies {
compile gradleApi()
compile localGroovy()
- runtime project(':data')
- runtime project(':data-avro-generator')
- runtime project(':generator')
- runtime project(':restli-tools')
-
testCompile externalDependency.testng
}
+
+// This is done so that the plugin can know which version of restli should be used when creating the pegasus configuration.
+processResources {
+ filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: ['version': project.version as String])
+}
@@ -0,0 +1,6 @@
+package com.linkedin.pegasus.gradle;
+
+public enum FileCompatibilityType {
+ SNAPSHOT,
+ IDL,
+}
@@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,8 +71,8 @@ public boolean hasGenerationMode(GenerationMode mode)
public static class IdlItem
{
// Input options for pegasus IDL Generation
- String apiName;
- String[] packageNames;
+ public String apiName;
+ public String[] packageNames;
public IdlItem(String inApiName, List<String> inPackageNames)
{
@@ -106,10 +107,10 @@ public void addIdlItem(List<String> inPackageNames)
public static class ClientItem
{
// Input options for pegasus Client Stub (Builder) generation
- String defaultPackage;
- String restModelFileName;
+ public String defaultPackage;
+ public String restModelFileName;
// will be used in the future
- boolean keepDataTemplates = false;
+ public boolean keepDataTemplates = false;
public ClientItem(String inRestModelFileName, String inDefaultPackage, boolean inKeepDataTemplates)
{
@@ -140,7 +141,9 @@ public boolean hasRestModelFileName(String fileName)
for (ClientItem item : clientOptionsList)
{
if (item.restModelFileName.equals(fileName))
+ {
return true;
+ }
}
return false;
}
Oops, something went wrong.

0 comments on commit 90e0d94

Please sign in to comment.