diff --git a/build.gradle b/build.gradle index 5bb52c21..f799e806 100644 --- a/build.gradle +++ b/build.gradle @@ -5,13 +5,15 @@ buildscript { repositories { + gradlePluginPortal() jcenter() maven { url "https://plugins.gradle.org/m2/" } } + dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' + classpath 'com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.1.2' classpath 'com.github.alisiikh:gradle-scalastyle-plugin:3.4.1' classpath "io.github.gradle-nexus:publish-plugin:1.0.0" classpath "org.shipkit:shipkit-auto-version:1.1.1" diff --git a/transportable-udfs-examples/build.gradle b/transportable-udfs-examples/build.gradle index fa7d26de..e507511d 100644 --- a/transportable-udfs-examples/build.gradle +++ b/transportable-udfs-examples/build.gradle @@ -25,8 +25,9 @@ allprojects { subprojects { buildscript { repositories { - mavenCentral() + gradlePluginPortal() jcenter() + mavenCentral() } } repositories { diff --git a/transportable-udfs-plugin/build.gradle b/transportable-udfs-plugin/build.gradle index cd6370c6..84216265 100644 --- a/transportable-udfs-plugin/build.gradle +++ b/transportable-udfs-plugin/build.gradle @@ -4,12 +4,16 @@ plugins { id 'signing' } +repositories { + gradlePluginPortal() +} + dependencies { implementation project(':transportable-udfs-api') implementation project(':transportable-udfs-codegen') implementation ('com.google.guava:guava:24.1-jre') implementation ('com.google.code.gson:gson:2.8.5') - implementation ('com.github.jengelman.gradle.plugins:shadow:5.2.0') + implementation ('com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.1.2') testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') { exclude group: 'org.codehaus.groovy' } diff --git a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/TransportPlugin.java b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/TransportPlugin.java index ec911c5f..986b3afc 100644 --- a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/TransportPlugin.java +++ b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/TransportPlugin.java @@ -57,7 +57,7 @@ public void apply(Project project) { project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> { project.getPlugins().apply(ScalaPlugin.class); project.getPlugins().apply(DistributionPlugin.class); - project.getConfigurations().create(ShadowBasePlugin.getCONFIGURATION_NAME()); + project.getConfigurations().create(ShadowBasePlugin.CONFIGURATION_NAME); JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(extension.mainSourceSetName); diff --git a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/DistributionPackaging.java b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/DistributionPackaging.java index 6805c126..c5ea27d1 100644 --- a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/DistributionPackaging.java +++ b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/DistributionPackaging.java @@ -57,9 +57,9 @@ public List> configurePackagingTasks(Project projec // Explicitly set classifiers for the created distributions or else leads to Maven packaging issues due to multiple // artifacts with the same classifier project.getTasks().named(platform.getName() + "DistTar", Tar.class, tar -> tar.setClassifier(platform.getName())); - project.getArtifacts().add(ShadowBasePlugin.getCONFIGURATION_NAME(), project.getTasks().named(platform.getName() + "DistTar", Tar.class)); + project.getArtifacts().add(ShadowBasePlugin.CONFIGURATION_NAME, project.getTasks().named(platform.getName() + "DistTar", Tar.class)); project.getTasks().named(platform.getName() + "DistZip", Zip.class, zip -> zip.setClassifier(platform.getName())); - project.getArtifacts().add(ShadowBasePlugin.getCONFIGURATION_NAME(), project.getTasks().named(platform.getName() + "DistZip", Zip.class)); + project.getArtifacts().add(ShadowBasePlugin.CONFIGURATION_NAME, project.getTasks().named(platform.getName() + "DistZip", Zip.class)); return ImmutableList.of(project.getTasks().named(platform.getName() + "DistTar", Tar.class), project.getTasks().named(platform.getName() + "DistZip", Zip.class)); } diff --git a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ShadedJarPackaging.java b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ShadedJarPackaging.java index a34c7df2..92914cb6 100644 --- a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ShadedJarPackaging.java +++ b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ShadedJarPackaging.java @@ -69,7 +69,7 @@ private TaskProvider createShadeTask(Project project, Platform platfo SourceSet mainSourceSet) { TaskProvider shadeTask = project.getTasks().register(sourceSet.getTaskName("shade", "Jar"), ShadeTask.class, task -> { - task.setGroup(ShadowJavaPlugin.getSHADOW_GROUP()); + task.setGroup(ShadowJavaPlugin.SHADOW_GROUP); task.setDescription("Create a combined JAR of " + platform.getName() + " output and runtime dependencies"); task.setClassifier(platform.getName()); task.getManifest() @@ -79,7 +79,7 @@ private TaskProvider createShadeTask(Project project, Platform platfo task.exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA"); }); - String configuration = ShadowBasePlugin.getCONFIGURATION_NAME(); + String configuration = ShadowBasePlugin.CONFIGURATION_NAME; project.getArtifacts().add(configuration, shadeTask); AdhocComponentWithVariants java = project.getComponents().withType(AdhocComponentWithVariants.class).getByName("java"); java.addVariantsFromConfiguration(project.getConfigurations().getByName(configuration), v -> v.mapToOptional()); diff --git a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ThinJarPackaging.java b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ThinJarPackaging.java index 68f3ee49..48db5f35 100644 --- a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ThinJarPackaging.java +++ b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/packaging/ThinJarPackaging.java @@ -42,11 +42,10 @@ public List> configurePackagingTasks(Project projec task.from(platformSourceSet.getOutput()); task.from(platformSourceSet.getResources()); }); - - String configuration = ShadowBasePlugin.getCONFIGURATION_NAME(); - project.getArtifacts().add(configuration, thinJarTask); + + project.getArtifacts().add(ShadowBasePlugin.CONFIGURATION_NAME, thinJarTask); AdhocComponentWithVariants java = project.getComponents().withType(AdhocComponentWithVariants.class).getByName("java"); - java.addVariantsFromConfiguration(project.getConfigurations().getByName(configuration), v -> v.mapToOptional()); + java.addVariantsFromConfiguration(project.getConfigurations().getByName(ShadowBasePlugin.CONFIGURATION_NAME), v -> v.mapToOptional()); return ImmutableList.of(thinJarTask); } diff --git a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/tasks/ShadeTask.java b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/tasks/ShadeTask.java index 16f6e6ef..4eae5a24 100644 --- a/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/tasks/ShadeTask.java +++ b/transportable-udfs-plugin/src/main/java/com/linkedin/transport/plugin/tasks/ShadeTask.java @@ -5,8 +5,6 @@ */ package com.linkedin.transport.plugin.tasks; -import com.github.jengelman.gradle.plugins.shadow.relocation.RelocateClassContext; -import com.github.jengelman.gradle.plugins.shadow.relocation.RelocatePathContext; import com.github.jengelman.gradle.plugins.shadow.relocation.SimpleRelocator; import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar; import com.google.common.collect.ImmutableList; @@ -107,7 +105,7 @@ protected void copy() { Set classPathsToShade = new HashSet<>(); List configurations = - getConfigurations().stream().map(this::setupConfiguration).collect(Collectors.toList()); + getConfigurations().stream().map(files -> this.setupConfiguration((Configuration) files)).collect(Collectors.toList()); // Collect all classes which need to be shaded configurations.forEach(configuration -> classPathsToShade.addAll(classesInConfiguration(configuration))); @@ -119,21 +117,24 @@ protected void copy() { Set classNamesToShade = classPathsToShade.stream().map(path -> path.replace('/', '.')).collect(Collectors.toSet()); // Pass the new updated conf to _shadowJar - setConfigurations(configurations); + setConfigurations(ImmutableList.copyOf(configurations)); // Exclude source files exclude("**/*.java"); // Do not shade classes we have excluded _doNotShade = ImmutableList.builder().addAll(_doNotShade).addAll(getExcludes()).build(); // Relocate base on the above restrictions super.relocate(new SimpleRelocator(null, _shadePrefix + '/', ImmutableList.of("**"), _doNotShade) { - public boolean canRelocatePath(RelocatePathContext context) { + @Override + public boolean canRelocatePath(String path) { // Only relocate those classes present in source project and dependency jars - return classPathsToShade.contains(context.getPath()) && super.canRelocatePath(context); + return classPathsToShade.contains(path) && super.canRelocatePath(path); } - public boolean canRelocateClass(RelocateClassContext context) { + @Override + + public boolean canRelocateClass(String className) { // Only relocate those classes present in source project and dependency jars - return classNamesToShade.contains(context.getClassName()) && super.canRelocateClass(context); + return classNamesToShade.contains(className) && super.canRelocateClass(className); } }); super.copy(); @@ -204,4 +205,4 @@ private static Set classesInJar(File jar) { } return classes; } -} +} \ No newline at end of file