Skip to content

Commit

Permalink
Merge pull request #84 from rspieldenner/runtimeScopeInGradle4
Browse files Browse the repository at this point in the history
Update to try runtimeClasspath since runtime scope auto move to compi…
  • Loading branch information
rspieldenner authored Oct 24, 2017
2 parents 35c937d + e1f3a85 commit 152164b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,27 @@ abstract class AbstractResolvedDependenciesPlugin implements Plugin<Project> {
if (exclude) {
throw new GradleException("Direct dependency \"${group}:${name}\" is excluded, delete direct dependency or stop excluding it")
}
ResolvedDependencyResult result = lookupDependency(project, scope, group, name)
if (!result) {
if (scope == 'compile') {
result = lookupDependency(project, 'runtime', group, name)
}
if (!result) {
return null
}
}
result.selected.moduleVersion
}

private ResolvedDependencyResult lookupDependency(Project project, String scope, String group, String name) {
def resolvedDependencies = resolvedDependencyByConfiguration(project)[scope]
def result = resolvedDependencies.find { r ->
def requested = r.requested
(requested instanceof ModuleComponentSelector) &&
(requested.group == group) &&
(requested.module == name)
}
if (!result) {
return null
}
result.selected.moduleVersion
result
}

@Memoized
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package nebula.plugin.publishing.ivy.interaction

import nebula.test.IntegrationTestKitSpec
import nebula.test.dependencies.DependencyGraphBuilder
import nebula.test.dependencies.GradleDependencyGenerator

class IvyPublishRecommenderInteractionSpec extends IntegrationTestKitSpec {
def 'dependencies in runtime provided by recommender are not put in ivy file'() {
keepFiles = true
def graph = new DependencyGraphBuilder().addModule('test:foo:1.0.0').build()
def generator = new GradleDependencyGenerator(graph, "$projectDir/repo")
generator.generateTestMavenRepo()

settingsFile.text = 'rootProject.name=\'mytest\''

buildFile << """\
plugins {
id 'java'
id 'nebula.ivy-publish'
id 'nebula.dependency-recommender' version '5.0.0'
}
group = 'test.nebula'
version = '0.1.0'
repositories {
${generator.mavenRepositoryBlock}
}
dependencyRecommendations {
map recommendations: ['test:foo': '1.0.0']
}
dependencies {
runtime 'test:foo'
}
publishing {
repositories {
ivy {
name 'testlocal'
url 'build/testlocal'
}
}
}
""".stripIndent()

when:
def results = runTasks('publishNebulaIvyPublicationToTestlocalRepository')

then:
def ivy = new XmlSlurper().parse(new File(projectDir, 'build/testlocal/test.nebula/mytest/0.1.0/ivy-0.1.0.xml'))
ivy.dependencies.dependency[0].@rev == '1.0.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import spock.lang.Ignore

class MavenPublishPluginIntegrationSpec extends IntegrationTestKitSpec {
def setup() {
debug = true
keepFiles = true
buildFile << """\
plugins {
Expand Down

0 comments on commit 152164b

Please sign in to comment.