-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from nebula-plugins/deprecation-logger-util
Deprecation logger util for Gradle 6.2+ compatibility
- Loading branch information
Showing
8 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/groovy/com/netflix/gradle/plugins/utils/DeprecationLoggerUtils.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.netflix.gradle.plugins.utils | ||
|
||
import groovy.transform.CompileDynamic | ||
import org.gradle.api.GradleException | ||
import org.gradle.util.GradleVersion | ||
|
||
import java.lang.reflect.InvocationTargetException | ||
|
||
@CompileDynamic | ||
class DeprecationLoggerUtils { | ||
|
||
private static final String LEGACY_DEPRECATION_LOGGER_CLASS = 'org.gradle.util.DeprecationLogger' | ||
|
||
private static final String DEPRECATION_LOGGER_CLASS = 'org.gradle.internal.deprecation.DeprecationLogger' | ||
|
||
static void whileDisabled(Runnable action) { | ||
String gradleDeprecationLoggerClassName = (GradleVersion.current() >= GradleVersion.version('6.2') || GradleVersion.current().version.startsWith('6.2')) ? DEPRECATION_LOGGER_CLASS : LEGACY_DEPRECATION_LOGGER_CLASS | ||
try { | ||
Class clazz = Class.forName(gradleDeprecationLoggerClassName) | ||
clazz.getMethod("whileDisabled", Runnable).invoke(this, action) | ||
} catch(ClassNotFoundException e) { | ||
throw new GradleException("Could not execute whileDisabled runnable action for $gradleDeprecationLoggerClassName | $e.message", e) | ||
} catch(InvocationTargetException e) { | ||
throw e.targetException | ||
} | ||
} | ||
} |