Skip to content

Instantly share code, notes, and snippets.

@bigdaz
Last active October 16, 2015 20:13
Show Gist options
  • Save bigdaz/7ef46583ce262e30f1da to your computer and use it in GitHub Desktop.
Save bigdaz/7ef46583ce262e30f1da to your computer and use it in GitHub Desktop.
class JavaLanguageExternalDependencyResolutionIntegrationTest extends AbstractIntegrationSpec {
def "resolved classpath includes transitive api-scoped dependencies of local components"() {
given:
mavenRepo.module("org.gradle", "compileDep").publish()
mavenRepo.module("org.gradle", "apiDep").publish()
buildFile << """
plugins {
id 'jvm-component'
id 'java-lang'
}
repositories {
maven { url '${mavenRepo.uri}' }
}
model {
components {
main(JvmLibrarySpec) {
sources {
java {
dependencies {
library 'other'
}
}
}
}
other(JvmLibrarySpec) {
sources {
java {
dependencies {
library 'org.gradle:apiDep:1.0' exported(true)
library 'org.gradle:compileDep:1.0'
library 'apiLib' exported(true)
library 'compileLib'
}
}
}
}
apiLib(JvmLibrarySpec) {
}
compileLib(JvmLibrarySpec) {
}
}
tasks {
create('copyDeps', Copy) {
into 'mainLibs'
from compileMainJarMainJava.classpath
}
}
}
"""
// Needed to ensure the 'compileMainJarMainJava' task exists
file('src/main/java/TestApp.java') << '''public class TestApp {}'''
when:
succeeds ':copyDeps'
then:
file('mainLibs').assertHasDescendants('other.jar', 'apiLib.jar', 'apiDep-1.0.jar')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment