Created
July 31, 2017 16:17
-
-
Save mkobit/6ff2aee426c895c8d8b926d936941dcb to your computer and use it in GitHub Desktop.
Gradle - Pin Groovy version in codenarc configuration CodeNarc
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
// The 'codenarc' plugin has a configuration with a dynamic Groovy dependency. | |
// This can be different that the actual version you are using. | |
// codenarc - The CodeNarc libraries to be used for this project. | |
// \--- org.codenarc:CodeNarc:0.27.0 | |
// +--- org.gmetrics:GMetrics:0.7 | |
// | +--- org.codehaus.groovy:groovy:[2.1.0,) -> 2.5.0-beta-1 | |
// | +--- org.codehaus.groovy:groovy-xml:[2.1.0,) -> 2.5.0-beta-1 | |
// | | \--- org.codehaus.groovy:groovy:2.5.0-beta-1 | |
// | \--- org.codehaus.groovy:groovy-ant:[2.1.0,) -> 2.5.0-beta-1 | |
// | +--- org.codehaus.groovy:groovy:2.5.0-beta-1 | |
// | +--- org.codehaus.groovy:groovy-groovydoc:2.5.0-beta-1 | |
// | | +--- org.codehaus.groovy:groovy:2.5.0-beta-1 | |
// | | \--- org.codehaus.groovy:groovy-templates:2.5.0-beta-1 | |
// | | +--- org.codehaus.groovy:groovy:2.5.0-beta-1 | |
// | | \--- org.codehaus.groovy:groovy-xml:2.5.0-beta-1 (*) | |
// | +--- org.apache.ant:ant-junit:1.9.9 | |
// | \--- org.apache.ant:ant-antlr:1.9.9 | |
// +--- junit:junit:4.8.1 | |
// +--- org.codehaus.groovy:groovy-ant:2.1.8 -> 2.5.0-beta-1 (*) | |
// +--- org.codehaus.groovy:groovy-xml:2.1.8 -> 2.5.0-beta-1 (*) | |
// \--- org.codehaus.groovy:groovy:2.1.8 -> 2.5.0-beta-1 | |
// To use the same Groovy version, you can modify the configuration. | |
final groovyVersion = '2.4.11' | |
configurations.getByName('codenarc').resolutionStrategy.dependencySubstitution.all { | |
if (it.requested instanceof org.gradle.api.artifacts.component.ModuleComponentSelector) { | |
final module = it.requested as org.gradle.api.artifacts.component.ModuleComponentSelector | |
if (module.group == 'org.codehaus.groovy') { | |
it.useTarget("${module.group}:${module.module}:${groovyVersion}") | |
} | |
} | |
} | |
// codenarc - The CodeNarc libraries to be used for this project. | |
// \--- org.codenarc:CodeNarc:0.27.0 | |
// +--- org.gmetrics:GMetrics:0.7 | |
// | +--- org.codehaus.groovy:groovy:[2.1.0,) -> 2.4.11 | |
// | +--- org.codehaus.groovy:groovy-xml:[2.1.0,) -> 2.4.11 | |
// | | \--- org.codehaus.groovy:groovy:2.4.11 | |
// | \--- org.codehaus.groovy:groovy-ant:[2.1.0,) -> 2.4.11 | |
// | +--- org.apache.ant:ant-antlr:1.9.4 | |
// | +--- org.apache.ant:ant-junit:1.9.4 | |
// | +--- org.codehaus.groovy:groovy-groovydoc:2.4.11 | |
// | | +--- org.codehaus.groovy:groovy-templates:2.4.11 | |
// | | | +--- org.codehaus.groovy:groovy-xml:2.4.11 (*) | |
// | | | \--- org.codehaus.groovy:groovy:2.4.11 | |
// | | \--- org.codehaus.groovy:groovy:2.4.11 | |
// | \--- org.codehaus.groovy:groovy:2.4.11 | |
// +--- junit:junit:4.8.1 | |
// +--- org.codehaus.groovy:groovy-ant:2.1.8 -> 2.4.11 (*) | |
// +--- org.codehaus.groovy:groovy-xml:2.1.8 -> 2.4.11 (*) | |
// \--- org.codehaus.groovy:groovy:2.1.8 -> 2.4.11 |
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
// Gradle Kotlin DSL version | |
val groovyVersion = "2.4.11" | |
configurations["codenarc"].resolutionStrategy.dependencySubstitution.all { | |
if (requested is org.gradle.api.artifacts.component.ModuleComponentSelector | |
&& requested.group == "org.codehaus.groovy") { | |
useTarget("$group:$module:$groovyVersion") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet can still be used with latest release of CodeNarc, but the dynamic versions should be gone in both GMetrics 1.0 and CodeNarc 1.0 so it may not entirely be needed.