build.gradle 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import org.elasticsearch.gradle.internal.JavaClassPublicifier;
  2. apply plugin: 'elasticsearch.java'
  3. apply plugin: 'com.github.johnrengelman.shadow'
  4. configurations {
  5. originalJar {
  6. transitive = false
  7. }
  8. }
  9. dependencies {
  10. originalJar "com.azure:azure-storage-blob:${project.parent.versions.azure}"
  11. implementation "com.azure:azure-storage-blob:${project.parent.versions.azure}"
  12. }
  13. // We have to rewrite the service classes to make them public to avoid
  14. // granting the permission "java.lang.reflect.ReflectPermission" "newProxyInPackage"
  15. // to this plugin.
  16. //
  17. // There are plans to make those public in the azure sdk side, but in the meanwhile
  18. // we just do this workaround
  19. // https://github.com/Azure/azure-sdk-for-java/issues/12829#issuecomment-736755543
  20. List<String> classesToRewrite = ['com/azure/storage/blob/implementation/AppendBlobsImpl$AppendBlobsService.class',
  21. 'com/azure/storage/blob/implementation/BlobsImpl$BlobsService.class',
  22. 'com/azure/storage/blob/implementation/BlockBlobsImpl$BlockBlobsService.class',
  23. 'com/azure/storage/blob/implementation/ContainersImpl$ContainersService.class',
  24. 'com/azure/storage/blob/implementation/DirectorysImpl$DirectorysService.class',
  25. 'com/azure/storage/blob/implementation/PageBlobsImpl$PageBlobsService.class',
  26. 'com/azure/storage/blob/implementation/ServicesImpl$ServicesService.class']
  27. tasks.register('extractClientClasses', Copy).configure {
  28. from({ zipTree(configurations.originalJar.singleFile) }) {
  29. include "com/azure/storage/blob/implementation/**"
  30. }
  31. into project.file('build/original')
  32. }
  33. def modifiedOutput = project.layout.buildDirectory.dir('modified')
  34. def makePublic = tasks.register('makeClientClassesPublic', JavaClassPublicifier) {
  35. dependsOn 'extractClientClasses'
  36. classFiles = classesToRewrite
  37. inputDir = project.layout.buildDirectory.dir('original')
  38. outputDir = modifiedOutput
  39. }
  40. sourceSets.main.output.dir(modifiedOutput, builtBy: makePublic)